From 789df301cb2ce4bc3e94a73a35611997f758fa40 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Sep 2024 15:05:13 +0100 Subject: [PATCH] Enable renaming row actions and improve row actions in grids --- .../ButtonGroup/CollapsedButtonGroup.svelte | 10 ++- .../FlowChart/FlowItem.svelte | 2 +- .../AutomationPanel/AutomationNavItem.svelte | 23 ++++- .../UpdateRowActionModal.svelte | 85 +++++++++++++++++++ .../grid/GridColumnsSettingButton.svelte | 8 +- .../buttons/grid/GridRowActionsButton.svelte | 8 +- .../table/[tableId]/[viewId]/index.svelte | 3 +- .../builder/src/stores/portal/licensing.js | 3 + packages/frontend-core/src/api/rowActions.js | 2 +- .../grid/layout/ButtonColumn.svelte | 1 + .../server/src/sdk/app/automations/utils.ts | 2 +- 11 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 packages/builder/src/components/automation/AutomationPanel/UpdateRowActionModal.svelte diff --git a/packages/bbui/src/ButtonGroup/CollapsedButtonGroup.svelte b/packages/bbui/src/ButtonGroup/CollapsedButtonGroup.svelte index e8362efc4b..42e2451ad4 100644 --- a/packages/bbui/src/ButtonGroup/CollapsedButtonGroup.svelte +++ b/packages/bbui/src/ButtonGroup/CollapsedButtonGroup.svelte @@ -9,6 +9,7 @@ export let size = "M" export let align = "left" export let offset + export let animate let anchor let popover @@ -28,7 +29,14 @@ > {text || "Action"} - + {#each buttons as button} handleClick(button)} disabled={button.disabled}> diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index c88317c79f..aca3e950c3 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -190,7 +190,7 @@ {#if isTrigger && triggerInfo} {/if} {#if lastStep} diff --git a/packages/builder/src/components/automation/AutomationPanel/AutomationNavItem.svelte b/packages/builder/src/components/automation/AutomationPanel/AutomationNavItem.svelte index 8ab9851ff0..ec9b956190 100644 --- a/packages/builder/src/components/automation/AutomationPanel/AutomationNavItem.svelte +++ b/packages/builder/src/components/automation/AutomationPanel/AutomationNavItem.svelte @@ -9,6 +9,7 @@ import { sdk } from "@budibase/shared-core" import ConfirmDialog from "components/common/ConfirmDialog.svelte" import UpdateAutomationModal from "components/automation/AutomationPanel/UpdateAutomationModal.svelte" + import UpdateRowActionModal from "components/automation/AutomationPanel/UpdateRowActionModal.svelte" import NavItem from "components/common/NavItem.svelte" export let automation @@ -16,6 +17,9 @@ let confirmDeleteDialog let updateAutomationDialog + let updateRowActionDialog + + $: isRowAction = sdk.automations.isRowAction(automation) async function deleteAutomation() { try { @@ -37,7 +41,6 @@ } const getContextMenuItems = () => { - const isRowAction = sdk.automations.isRowAction(automation) const pause = { icon: automation.disabled ? "CheckmarkCircle" : "Cancel", name: automation.disabled ? "Activate" : "Pause", @@ -83,7 +86,16 @@ del, ] } else { - return [del] + return [ + { + icon: "Edit", + name: "Edit", + keyBind: null, + visible: true, + callback: updateRowActionDialog.show, + }, + del, + ] } } @@ -122,4 +134,9 @@ {automation.name}? This action cannot be undone. - + +{#if isRowAction} + +{:else} + +{/if} diff --git a/packages/builder/src/components/automation/AutomationPanel/UpdateRowActionModal.svelte b/packages/builder/src/components/automation/AutomationPanel/UpdateRowActionModal.svelte new file mode 100644 index 0000000000..af754d7ca9 --- /dev/null +++ b/packages/builder/src/components/automation/AutomationPanel/UpdateRowActionModal.svelte @@ -0,0 +1,85 @@ + + + + + + + + Learn about automations + + + + + diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte index 11109c0f78..c75c1b8568 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridColumnsSettingButton.svelte @@ -2,8 +2,7 @@ import { getContext } from "svelte" import { ActionButton, Popover } from "@budibase/bbui" import ColumnsSettingContent from "./ColumnsSettingContent.svelte" - - export let allowViewReadonlyColumns = false + import { licensing } from "stores/portal" const { columns } = getContext("grid") @@ -29,5 +28,8 @@ - + diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte index 193a977a46..9adbca7603 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridRowActionsButton.svelte @@ -22,7 +22,7 @@ $: ds = $datasource $: tableId = ds?.tableId $: isView = ds?.type === "viewV2" - $: fetchRowActions(tableId) + $: fetchRowActions(ds) $: actionCount = rowActions.filter(action => !isView || action.enabled).length const rowActionUrl = derived([url, appStore], ([$url, $appStore]) => { @@ -31,12 +31,12 @@ } }) - const fetchRowActions = async tableId => { - if (!tableId) { + const fetchRowActions = async datasource => { + if (!datasource?.tableId) { rowActions = [] return } - const res = await API.rowActions.fetch(tableId) + const res = await API.rowActions.fetch(datasource.tableId) rowActions = Object.values(res || {}).map(action => ({ ...action, enabled: !isView || action.allowedViews?.includes(ds.id), diff --git a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte index 798d1e0b51..e3020394df 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/table/[tableId]/[viewId]/index.svelte @@ -1,6 +1,6 @@