From 508a865ea5927f387772dee52417d708bf38b38b Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 8 Jul 2022 09:09:21 +0100 Subject: [PATCH] Action drawer updates. Actions now grouped by type and filterable in the action drawer --- .../ButtonActionDrawer.svelte | 110 +++++++++++++++--- .../ButtonActionEditor.svelte | 12 ++ .../ButtonActionEditor/manifest.json | 19 ++- 3 files changed, 124 insertions(+), 17 deletions(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionDrawer.svelte index 5b0ab4a6a3..c78611c950 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionDrawer.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionDrawer.svelte @@ -6,8 +6,8 @@ Button, Layout, DrawerContent, - ActionMenu, - MenuItem, + ActionButton, + Search, } from "@budibase/bbui" import { getAvailableActions } from "./index" import { generate } from "shortid" @@ -22,8 +22,24 @@ export let actions export let bindings = [] + let showAvailableActions = false + + let actionQuery + $: parsedQuery = + typeof actionQuery === "string" ? actionQuery.toLowerCase().trim() : "" + let selectedAction = actions?.length ? actions[0] : null + $: mappedActionTypes = actionTypes.reduce((acc, action) => { + let parsedName = action.name.toLowerCase().trim() + if (parsedQuery.length && parsedName.indexOf(parsedQuery) < 0) { + return acc + } + acc[action.type] = acc[action.type] || [] + acc[action.type].push(action) + return acc + }, {}) + // These are ephemeral bindings which only exist while executing actions $: buttonContextBindings = getButtonContextBindings( $currentAsset, @@ -61,7 +77,12 @@ actions = actions } - const addAction = actionType => () => { + const toggleActionList = () => { + actionQuery = null + showAvailableActions = !showAvailableActions + } + + const addAction = actionType => { const newAction = { parameters: {}, [EVENT_TYPE_KEY]: actionType.name, @@ -78,6 +99,11 @@ selectedAction = action } + const onAddAction = actionType => { + addAction(actionType) + toggleActionList() + } + function handleDndConsider(e) { actions = e.detail.items } @@ -88,7 +114,29 @@ - {#if actions && actions.length > 0} + {#if showAvailableActions} +
+ + Back + +
+ + {#each Object.entries(mappedActionTypes) as [categoryId, category]} +
{categoryId}
+
    + {#each category as actionType} +
  • + {actionType.name} +
  • + {/each} +
+ {/each} + {/if} + + {#if actions && actions.length > 0 && !showAvailableActions} +
+ +
{/if} - - - {#each actionTypes as actionType} - - {actionType.name} - - {/each} - - {#if selectedActionComponent} + {#if selectedActionComponent && !showAvailableActions} {#key selectedAction.id}
diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionEditor.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionEditor.svelte index 550d982013..8e5954f078 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionEditor.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/ButtonActionEditor.svelte @@ -69,9 +69,15 @@ notifications.error("Error creating automation") } } + + $: actionCount = value?.length + $: actionText = `${actionCount || "No"} action${ + actionCount !== 1 ? "s" : "" + } set` Define actions +
{actionText}
Define what actions to run. @@ -85,3 +91,9 @@ {key} /> + + diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json index cf18fee3a6..40aa606f88 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json @@ -2,6 +2,7 @@ "actions": [ { "name": "Save Row", + "type": "data", "component": "SaveRow", "context": [ { @@ -12,6 +13,7 @@ }, { "name": "Duplicate Row", + "type": "data", "component": "DuplicateRow", "context": [ { @@ -22,14 +24,17 @@ }, { "name": "Delete Row", + "type": "data", "component": "DeleteRow" }, { "name": "Navigate To", + "type": "ui/ux", "component": "NavigateTo" }, { "name": "Execute Query", + "type": "data", "component": "ExecuteQuery", "context": [ { @@ -40,43 +45,53 @@ }, { "name": "Trigger Automation", + "type": "ui/ux", "component": "TriggerAutomation" }, { "name": "Update Field Value", + "type": "form", "component": "UpdateFieldValue" }, { "name": "Validate Form", + "type": "form", "component": "ValidateForm" }, { "name": "Change Form Step", + "type": "form", "component": "ChangeFormStep" }, { "name": "Clear Form", + "type": "form", "component": "ClearForm" }, { "name": "Log Out", + "type": "ui/ux", "component": "LogOut" }, { "name": "Close Screen Modal", + "type": "ui/ux", "component": "CloseScreenModal" }, { "name": "Refresh Data Provider", + "type": "data", "component": "RefreshDataProvider" }, { "name": "Update State", + "type": "data", "component": "UpdateState", "dependsOnFeature": "state" }, { "name": "Upload File to S3", + "type": "data", "component": "S3Upload", "context": [ { @@ -87,12 +102,14 @@ }, { "name": "Export Data", + "type": "data", "component": "ExportData" }, { "name": "Continue if / Stop if", + "type": "ui/ux", "component": "ContinueIf", "dependsOnFeature": "continueIfAction" } ] -} +} \ No newline at end of file