From 4d564365cf1380331efe9149756405d2c3524ae2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 13 May 2021 12:30:45 +0100 Subject: [PATCH] Clean up data source context and remove explicit button actions for pagination --- .../EventsEditor/actions/NextPage.svelte | 38 ------------------- .../EventsEditor/actions/PrevPage.svelte | 38 ------------------- .../EventsEditor/actions/index.js | 10 ----- packages/client/src/constants.js | 2 - packages/client/src/utils/buttonActions.js | 33 ++++------------ packages/standard-components/manifest.json | 1 - .../src/DataProvider.svelte | 19 +--------- 7 files changed, 8 insertions(+), 133 deletions(-) delete mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/NextPage.svelte delete mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/PrevPage.svelte diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/NextPage.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/NextPage.svelte deleted file mode 100644 index a96e1bd3d..000000000 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/NextPage.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - x._instanceName} - getOptionValue={(x) => x._id} - /> -
- - diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js index 95c92a3f6..4700ea5c8 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/index.js @@ -6,8 +6,6 @@ import TriggerAutomation from "./TriggerAutomation.svelte" import ValidateForm from "./ValidateForm.svelte" import LogIn from "./LogIn.svelte" import LogOut from "./LogOut.svelte" -import NextPage from "./NextPage.svelte" -import PrevPage from "./PrevPage.svelte" // defines what actions are available, when adding a new one // the component is the setup panel for the action @@ -47,12 +45,4 @@ export default [ name: "Log Out", component: LogOut, }, - { - name: "Next Page", - component: NextPage, - }, - { - name: "Previous Page", - component: PrevPage, - }, ] diff --git a/packages/client/src/constants.js b/packages/client/src/constants.js index fc69ac212..3aa302bec 100644 --- a/packages/client/src/constants.js +++ b/packages/client/src/constants.js @@ -5,6 +5,4 @@ export const TableNames = { export const ActionTypes = { ValidateForm: "ValidateForm", RefreshDatasource: "RefreshDatasource", - NextPage: "NextPage", - PrevPage: "PrevPage", } diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index f78ac1773..4d2865d58 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -16,27 +16,27 @@ const saveRowHandler = async (action, context) => { } } -const deleteRowHandler = async (action) => { +const deleteRowHandler = async action => { const { tableId, revId, rowId } = action.parameters if (tableId && revId && rowId) { await deleteRow({ tableId, rowId, revId }) } } -const triggerAutomationHandler = async (action) => { +const triggerAutomationHandler = async action => { const { fields } = action.parameters if (fields) { await triggerAutomation(action.parameters.automationId, fields) } } -const navigationHandler = (action) => { +const navigationHandler = action => { if (action.parameters.url) { routeStore.actions.navigate(action.parameters.url) } } -const queryExecutionHandler = async (action) => { +const queryExecutionHandler = async action => { const { datasourceId, queryId, queryParams } = action.parameters await executeQuery({ datasourceId, @@ -68,23 +68,7 @@ const refreshDatasourceHandler = async (action, context) => { ) } -const nextPageHandler = async (action, context) => { - return await executeActionHandler( - context, - action.parameters.componentId, - ActionTypes.NextPage - ) -} - -const prevPageHandler = async (action, context) => { - return await executeActionHandler( - context, - action.parameters.componentId, - ActionTypes.PrevPage - ) -} - -const loginHandler = async (action) => { +const loginHandler = async action => { const { email, password } = action.parameters await authStore.actions.logIn({ email, password }) } @@ -103,8 +87,6 @@ const handlerMap = { ["Refresh Datasource"]: refreshDatasourceHandler, ["Log In"]: loginHandler, ["Log Out"]: logoutHandler, - ["Next Page"]: nextPageHandler, - ["Previous Page"]: prevPageHandler, } /** @@ -114,10 +96,9 @@ const handlerMap = { export const enrichButtonActions = (actions, context) => { // Prevent button actions in the builder preview if (get(builderStore).inBuilder) { - // TODO uncomment - // return () => {} + return () => {} } - const handlers = actions.map((def) => handlerMap[def["##eventHandlerType"]]) + const handlers = actions.map(def => handlerMap[def["##eventHandlerType"]]) return async () => { for (let i = 0; i < handlers.length; i++) { try { diff --git a/packages/standard-components/manifest.json b/packages/standard-components/manifest.json index c19deb9d7..dab68f41c 100644 --- a/packages/standard-components/manifest.json +++ b/packages/standard-components/manifest.json @@ -1384,7 +1384,6 @@ "icon": "Data", "styleable": false, "hasChildren": true, - "actions": ["NextPage", "PrevPage"], "settings": [ { "type": "dataSource", diff --git a/packages/standard-components/src/DataProvider.svelte b/packages/standard-components/src/DataProvider.svelte index 80ddffede..64e387462 100644 --- a/packages/standard-components/src/DataProvider.svelte +++ b/packages/standard-components/src/DataProvider.svelte @@ -54,25 +54,8 @@ callback: () => fetchData(dataSource), metadata: { dataSource }, }, - { - type: ActionTypes.NextPage, - callback: () => nextPage(), - }, - { - type: ActionTypes.PrevPage, - callback: () => prevPage(), - }, ] - $: dataContext = { - rows, - schema, - rowsLength: rows.length, - loading, - loaded, - pageNumber: pageNumber + 1, - hasNextPage, - hasPrevPage, - } + $: dataContext = { rows, schema, rowsLength: rows.length } const getSortType = (schema, sortColumn) => { if (!schema || !sortColumn || !schema[sortColumn]) {