From 21b28a3de85c8fc4aac0c9f3e042d0b4d979b0de Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 Jul 2024 12:05:56 +0100 Subject: [PATCH 1/4] Added new Generate automation button and added it to the table --- .../backend/DataTable/TableDataTable.svelte | 4 + .../grid/GridCreateAutomationButton.svelte | 112 ++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte diff --git a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte index e8e1008e3c..525421f996 100644 --- a/packages/builder/src/components/backend/DataTable/TableDataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/TableDataTable.svelte @@ -5,6 +5,7 @@ import { TableNames } from "constants" import { Grid } from "@budibase/frontend-core" import { API } from "api" + import GridCreateAutomationButton from "./buttons/grid/GridCreateAutomationButton.svelte" import GridAddColumnModal from "components/backend/DataTable/modals/grid/GridCreateColumnModal.svelte" import GridCreateEditRowModal from "components/backend/DataTable/modals/grid/GridCreateEditRowModal.svelte" import GridEditUserModal from "components/backend/DataTable/modals/grid/GridEditUserModal.svelte" @@ -81,6 +82,9 @@ {/if} + {#if !isUsersTable} + + {/if} {#if relationshipsEnabled} {/if} diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte new file mode 100644 index 0000000000..60aae9e195 --- /dev/null +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte @@ -0,0 +1,112 @@ + + +
+ (open = !open)} + selected={open} + > + Generate + +
+ + + + { + open = false + createAutomation(TriggerStepID.ROW_SAVED) + console.log("create") + }} + > + Automation: when row is created + + { + open = false + createAutomation(TriggerStepID.ROW_UPDATED) + console.log("update") + }} + > + Automation: when row is updated + + + + + From a764bfb6a54ac1fda4be86ff295ce8136ffce0e5 Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 4 Jul 2024 14:30:51 +0100 Subject: [PATCH 2/4] Tidying up debugging console statements and comments --- .../grid/GridCreateAutomationButton.svelte | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte index 60aae9e195..3ee1edc4b6 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte @@ -7,22 +7,15 @@ notifications, } from "@budibase/bbui" import { getContext } from "svelte" - import { automationStore } from "stores/builder" + import { automationStore, tables } from "stores/builder" import { TriggerStepID } from "constants/backend/automations" - import { tables } from "stores/builder" import { goto } from "@roxi/routify" const { datasource } = getContext("grid") - // ROW_SAVED - // ROW_UPDATED - $: console.log($datasource) $: triggers = $automationStore.blockDefinitions.TRIGGER $: table = $tables.list.find(table => table._id === $datasource.tableId) - $: console.log("table", table) - // $: rowCreateTrigger = triggers[TriggerStepID.ROW_SAVED] - // $: rowUpdateTrigger = triggers[TriggerStepID.ROW_UPDATED] async function createAutomation(type) { const triggerType = triggers[type] @@ -48,13 +41,7 @@ triggerBlock.inputs = { tableId: $datasource.tableId } - // need to set inputs to { "tableId": "ta_bb_employee" }, - try { - console.log("REQ", { - automationName, - triggerBlock, - }) const response = await automationStore.actions.create( automationName, triggerBlock @@ -90,7 +77,6 @@ on:click={() => { open = false createAutomation(TriggerStepID.ROW_SAVED) - console.log("create") }} > Automation: when row is created @@ -100,7 +86,6 @@ on:click={() => { open = false createAutomation(TriggerStepID.ROW_UPDATED) - console.log("update") }} > Automation: when row is updated From 9518680d1277f1b5cbf9733dd63a5c6102bd9311 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 5 Jul 2024 14:33:09 +0100 Subject: [PATCH 3/4] Update the topnav history when navigating to the automation sections on create --- .../buttons/grid/GridCreateAutomationButton.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte index 3ee1edc4b6..94ac41fd24 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte @@ -7,9 +7,9 @@ notifications, } from "@budibase/bbui" import { getContext } from "svelte" - import { automationStore, tables } from "stores/builder" + import { automationStore, tables, builderStore } from "stores/builder" import { TriggerStepID } from "constants/backend/automations" - import { goto } from "@roxi/routify" + import { goto, layout, isActive } from "@roxi/routify" const { datasource } = getContext("grid") @@ -46,10 +46,14 @@ automationName, triggerBlock ) - + builderStore.setPreviousTopNavPath( + "/builder/app/:application/data", + window.location.pathname + ) $goto(`/builder/app/${response.appId}/automation/${response.id}`) notifications.success(`Automation created`) - } catch { + } catch (e) { + console.error("Error creating automation", e) notifications.error("Error creating automation") } } From 4d11f62e007899abb8317e305ea057f27160aa08 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 5 Jul 2024 14:36:20 +0100 Subject: [PATCH 4/4] Lint --- .../DataTable/buttons/grid/GridCreateAutomationButton.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte index 94ac41fd24..8e3d90be41 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridCreateAutomationButton.svelte @@ -9,7 +9,7 @@ import { getContext } from "svelte" import { automationStore, tables, builderStore } from "stores/builder" import { TriggerStepID } from "constants/backend/automations" - import { goto, layout, isActive } from "@roxi/routify" + import { goto } from "@roxi/routify" const { datasource } = getContext("grid")