Merge pull request #14274 from Budibase/fix/accomodate-missing-auto-trigger

Fix to accomodate automations without triggers
This commit is contained in:
deanhannigan 2024-07-30 15:01:49 +01:00 committed by GitHub
commit 17c96f7e41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View File

@ -54,6 +54,7 @@
</div> </div>
<div class="controls"> <div class="controls">
<div <div
class:disabled={!$selectedAutomation?.definition?.trigger}
on:click={() => { on:click={() => {
testDataModal.show() testDataModal.show()
}} }}
@ -80,6 +81,7 @@
automation._id, automation._id,
automation.disabled automation.disabled
)} )}
disabled={!$selectedAutomation?.definition?.trigger}
value={!automation.disabled} value={!automation.disabled}
/> />
</div> </div>

View File

@ -54,7 +54,7 @@
name: "Edit", name: "Edit",
keyBind: null, keyBind: null,
visible: true, visible: true,
disabled: false, disabled: !automation.definition.trigger,
callback: updateAutomationDialog.show, callback: updateAutomationDialog.show,
}, },
{ {
@ -62,7 +62,9 @@
name: "Duplicate", name: "Duplicate",
keyBind: null, keyBind: null,
visible: true, visible: true,
disabled: automation.definition.trigger.name === "Webhook", disabled:
!automation.definition.trigger ||
automation.definition.trigger?.name === "Webhook",
callback: duplicateAutomation, callback: duplicateAutomation,
}, },
] ]
@ -74,7 +76,7 @@
name: automation.disabled ? "Activate" : "Pause", name: automation.disabled ? "Activate" : "Pause",
keyBind: null, keyBind: null,
visible: true, visible: true,
disabled: false, disabled: !automation.definition.trigger,
callback: () => { callback: () => {
automationStore.actions.toggleDisabled( automationStore.actions.toggleDisabled(
automation._id, automation._id,

View File

@ -30,12 +30,13 @@
}) })
$: groupedAutomations = filteredAutomations.reduce((acc, auto) => { $: groupedAutomations = filteredAutomations.reduce((acc, auto) => {
acc[auto.definition.trigger.event] ??= { const catName = auto.definition?.trigger?.event || "No Trigger"
icon: auto.definition.trigger.icon, acc[catName] ??= {
name: (auto.definition.trigger?.name || "").toUpperCase(), icon: auto.definition?.trigger?.icon || "AlertCircle",
name: (auto.definition?.trigger?.name || "No Trigger").toUpperCase(),
entries: [], entries: [],
} }
acc[auto.definition.trigger.event].entries.push(auto) acc[catName].entries.push(auto)
return acc return acc
}, {}) }, {})