Skip to content

Commit d31909d

Browse files
authored
Merge pull request #16605 from Budibase/feature/automation-state-block
Automation State block
2 parents 995bdde + b669941 commit d31909d

File tree

24 files changed

+678
-102
lines changed

24 files changed

+678
-102
lines changed

packages/builder/src/components/automation/AutomationBuilder/FlowChart/BranchNode.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
export let branchIdx
3434
export let step
3535
export let isLast
36-
export let bindings
36+
export let bindings = []
3737
export let automation
3838
export let executed = false
3939
export let unexecuted = false
@@ -53,7 +53,7 @@
5353
$: editableConditionUI = branch.conditionUI || {}
5454
5555
// Parse all the bindings into fields for the condition builder
56-
$: schemaFields = bindings.map(binding => {
56+
$: schemaFields = bindings?.map(binding => {
5757
return {
5858
name: `{{${binding.runtimeBinding}}}`,
5959
displayName: `${binding.category} - ${binding.display.name}`,

packages/builder/src/components/automation/AutomationBuilder/FlowChart/SelectStepSidePanel.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
AutomationActionStepId.EXECUTE_BASH,
115115
AutomationActionStepId.EXECUTE_SCRIPT_V2,
116116
AutomationActionStepId.SERVER_LOG,
117+
AutomationActionStepId.EXTRACT_STATE,
117118
].includes(k as AutomationActionStepId)
118119
),
119120
},

packages/builder/src/components/automation/AutomationBuilder/FlowChart/StepNode.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@
6868
6969
$: userBindings = automationStore.actions.buildUserBindings()
7070
$: settingBindings = automationStore.actions.buildSettingBindings()
71+
$: stateBindings =
72+
($automationStore.selectedNodeId,
73+
automationStore.actions.buildStateBindings())
7174
7275
// Combine all bindings for the step
7376
$: bindings = [
7477
...availableBindings,
7578
...environmentBindings,
7679
...userBindings,
7780
...settingBindings,
81+
...stateBindings,
7882
]
7983
8084
onMount(() => {

packages/builder/src/components/automation/AutomationBuilder/StepPanel.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</div>
117117
{#if isStep}
118118
<div class="step-actions">
119-
{#if $memoBlock && !isBranchStep($memoBlock) && ($memoBlock.features?.[AutomationFeature.LOOPING] || !$memoBlock.features)}
119+
{#if $memoBlock && !isBranchStep($memoBlock) && $memoBlock.features?.[AutomationFeature.LOOPING]}
120120
<ActionButton
121121
quiet
122122
noPadding

packages/builder/src/components/automation/SetupPanel/BlockData.svelte

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,30 @@
111111
const loopMax = Number(inputs.iterations)
112112
const loopOutputs = blockResults?.outputs
113113
114-
let loopMessage = "There was an error"
115-
116-
// Not technically failed as it continues to run
117-
if (loopOutputs?.status === AutomationStepStatus.MAX_ITERATIONS) {
118-
loopMessage = `The maximum number of iterations (${loopMax}) has been reached.`
119-
} else if (
120-
loopOutputs?.status === AutomationStepStatus.FAILURE_CONDITION
121-
) {
122-
loopMessage = `The failure condition for the loop was hit: ${inputs.failure}.
114+
if (!loopOutputs.success) {
115+
let loopMessage = "There was an error"
116+
117+
// Not technically failed as it continues to run
118+
if (loopOutputs?.status === AutomationStepStatus.MAX_ITERATIONS) {
119+
loopMessage = `The maximum number of iterations (${loopMax}) has been reached.`
120+
} else if (
121+
loopOutputs?.status === AutomationStepStatus.FAILURE_CONDITION
122+
) {
123+
loopMessage = `The failure condition for the loop was hit: ${inputs.failure}.
123124
The loop was terminated`
124-
} else if (loopOutputs?.status === AutomationStepStatus.INCORRECT_TYPE) {
125-
loopMessage = `An 'Input Type' of '${inputs.option}' was configured which does
125+
} else if (
126+
loopOutputs?.status === AutomationStepStatus.INCORRECT_TYPE
127+
) {
128+
loopMessage = `An 'Input Type' of '${inputs.option}' was configured which does
126129
not match the value supplied`
127-
}
130+
}
128131
129-
issues.push({
130-
message: loopMessage,
131-
type: BlockStatusType.ERROR,
132-
source: BlockStatusSource.AUTOMATION_RESULTS,
133-
})
132+
issues.push({
133+
message: loopMessage,
134+
type: BlockStatusType.ERROR,
135+
source: BlockStatusSource.AUTOMATION_RESULTS,
136+
})
137+
}
134138
}
135139
136140
// Process filtered row issues

packages/builder/src/components/automation/SetupPanel/BlockProperties.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@
3434
}
3535
$: userBindings = automationStore.actions.buildUserBindings()
3636
$: settingBindings = automationStore.actions.buildSettingBindings()
37+
$: stateBindings =
38+
($automationStore.selectedNodeId,
39+
automationStore.actions.buildStateBindings())
3740
3841
// Combine all bindings for the step
3942
$: bindings = [
4043
...availableBindings,
4144
...environmentBindings,
4245
...userBindings,
4346
...settingBindings,
47+
...stateBindings,
4448
]
4549
4650
// Store for any UX related data

packages/builder/src/components/common/bindings/BindingSidePanel.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
popoverAnchor = target
135135
hoverTarget = {
136136
type: "binding",
137-
code: binding.valueHTML,
137+
code: binding.valueHTML || "",
138138
}
139139
popover.show()
140140
}

0 commit comments

Comments
 (0)