diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte index a409d85305..5533572511 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItemHeader.svelte @@ -16,13 +16,12 @@ export let enableNaming = true let validRegex = /^[A-Za-z0-9_\s]+$/ let typing = false - const dispatch = createEventDispatcher() $: stepNames = $selectedAutomation?.definition.stepNames $: automationName = stepNames?.[block.id] || block?.name || "" $: automationNameError = getAutomationNameError(automationName) - $: status = updateStatus(testResult, isTrigger) + $: status = updateStatus(testResult) $: isHeaderTrigger = isTrigger || block.type === "TRIGGER" $: { @@ -43,7 +42,7 @@ }) } - function updateStatus(results, isTrigger) { + function updateStatus(results) { if (!results) { return {} } @@ -56,7 +55,6 @@ return { negative: true, message: "Error" } } } - const getAutomationNameError = name => { if (stepNames) { for (const [key, value] of Object.entries(stepNames)) { diff --git a/packages/builder/src/components/automation/AutomationBuilder/TestDisplay.svelte b/packages/builder/src/components/automation/AutomationBuilder/TestDisplay.svelte index 2cad22c820..8487b7a519 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/TestDisplay.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/TestDisplay.svelte @@ -12,14 +12,31 @@ let blocks function prepTestResults(results) { - return results?.steps.filter(x => x.stepId !== ActionStepID.LOOP || []) + if (results.message) { + return [ + { + inputs: {}, + outputs: { + success: results.outputs?.success || false, + status: results.outputs?.status || "unknown", + message: results.message, + }, + }, + ] + } else { + return results?.steps?.filter(x => x.stepId !== ActionStepID.LOOP) || [] + } } $: filteredResults = prepTestResults(testResults) $: { - blocks = [] - if (automation) { + if (testResults.message) { + blocks = automation?.definition?.trigger + ? [automation.definition.trigger] + : [] + } else if (automation) { + blocks = [] if (automation.definition.trigger) { blocks.push(automation.definition.trigger) } @@ -46,7 +63,9 @@ open={!!openBlocks[block.id]} on:toggle={() => (openBlocks[block.id] = !openBlocks[block.id])} isTrigger={idx === 0} - testResult={filteredResults?.[idx]} + testResult={testResults.message + ? testResults + : filteredResults?.[idx]} showTestStatus {block} {idx} @@ -68,7 +87,9 @@
- {#if filteredResults?.[idx]?.inputs} + {#if testResults.message} + No input + {:else if filteredResults?.[idx]?.inputs} {:else} No input @@ -77,13 +98,22 @@
- {#if filteredResults?.[idx]?.outputs} + {#if testResults.message} + + {:else if filteredResults?.[idx]?.outputs} {:else} - No input + No output {/if}
diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index 283bd14fc0..8a9d1e59ea 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -17,7 +17,9 @@ Helpers, Toggle, Divider, + Icon, } from "@budibase/bbui" + import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import { automationStore, selectedAutomation, tables } from "stores/builder" import { environment, licensing } from "stores/portal" @@ -365,41 +367,74 @@ /** * Handler for row trigger automation updates. - @param {object} update - An automation block.inputs update object - @example - onRowTriggerUpdate({ - "tableId" : "ta_bb_employee" - }) + * @param {object} update - An automation block.inputs update object + * @param {string} [update.tableId] - The ID of the table + * @param {object} [update.filters] - Filter configuration for the row trigger + * @param {object} [update.filters-def] - Filter definitions for the row trigger + * @example + * // Example with tableId + * onRowTriggerUpdate({ + * "tableId" : "ta_bb_employee" + * }) + * @example + * // Example with filters + * onRowTriggerUpdate({ + * filters: { + * equal: { "1:Approved": "true" } + * }, + * "filters-def": [{ + * id: "oH1T4S49n", + * field: "1:Approved", + * operator: "equal", + * value: "true", + * valueType: "Value", + * type: "string" + * }] + * }) */ const onRowTriggerUpdate = async update => { if ( - Object.hasOwn(update, "tableId") && - $selectedAutomation.testData?.row?.tableId !== update.tableId + ["tableId", "filters", "meta"].some(key => Object.hasOwn(update, key)) ) { try { - const reqSchema = getSchemaForDatasourcePlus(update.tableId, { - searchableSchema: true, - }).schema + let updatedAutomation - // Parse the block inputs as usual - const updatedAutomation = - await automationStore.actions.processBlockInputs(block, { - schema: reqSchema, - ...update, - }) + if ( + Object.hasOwn(update, "tableId") && + $selectedAutomation.testData?.row?.tableId !== update.tableId + ) { + const reqSchema = getSchemaForDatasourcePlus(update.tableId, { + searchableSchema: true, + }).schema - // Save the entire automation and reset the testData - await automationStore.actions.save({ - ...updatedAutomation, - testData: { - // Reset Core fields - row: { tableId: update.tableId }, - oldRow: { tableId: update.tableId }, - meta: {}, - id: "", - revision: "", - }, - }) + updatedAutomation = await automationStore.actions.processBlockInputs( + block, + { + schema: reqSchema, + ...update, + } + ) + + // Reset testData when tableId changes + updatedAutomation = { + ...updatedAutomation, + testData: { + row: { tableId: update.tableId }, + oldRow: { tableId: update.tableId }, + meta: {}, + id: "", + revision: "", + }, + } + } else { + // For filters update, just process block inputs without resetting testData + updatedAutomation = await automationStore.actions.processBlockInputs( + block, + update + ) + } + + await automationStore.actions.save(updatedAutomation) return } catch (e) { @@ -408,7 +443,6 @@ } } } - /** * Handler for App trigger automation updates. * Ensure updates to the field list are reflected in testData @@ -743,6 +777,7 @@ value.customType !== "triggerSchema" && value.customType !== "automationFields" && value.customType !== "fields" && + value.customType !== "trigger_filter_setting" && value.type !== "signature_single" && value.type !== "attachment" && value.type !== "attachment_single" @@ -807,13 +842,23 @@ {@const label = getFieldLabel(key, value)}
{#if key !== "fields" && value.type !== "boolean" && shouldRenderField(value)} - +
+ + {#if value.customType === "trigger_filter"} + + window.open( + "https://docs.budibase.com/docs/row-trigger-filters", + "_blank" + )} + size="XS" + name="InfoOutline" + /> + {/if} +
{/if}
{#if value.type === "string" && value.enum && canShowField(key, value)} @@ -932,8 +977,12 @@ {/if}
- {:else if value.customType === "filters"} - Define filters + {:else if value.customType === "filters" || value.customType === "trigger_filter"} + {filters.length > 0 + ? "Update Filter" + : "No Filter set"}