Merge branch 'master' into fix/hide-row-actions
This commit is contained in:
commit
2486497a6c
|
@ -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>
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,6 @@ const automationActions = store => ({
|
||||||
disabled: false,
|
disabled: false,
|
||||||
}
|
}
|
||||||
const response = await store.actions.save(automation)
|
const response = await store.actions.save(automation)
|
||||||
await store.actions.fetch()
|
|
||||||
store.actions.select(response._id)
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
duplicate: async automation => {
|
duplicate: async automation => {
|
||||||
|
@ -98,14 +96,13 @@ const automationActions = store => ({
|
||||||
_id: undefined,
|
_id: undefined,
|
||||||
_ref: undefined,
|
_ref: undefined,
|
||||||
})
|
})
|
||||||
await store.actions.fetch()
|
|
||||||
store.actions.select(response._id)
|
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
save: async automation => {
|
save: async automation => {
|
||||||
const response = await API.updateAutomation(automation)
|
const response = await API.updateAutomation(automation)
|
||||||
|
|
||||||
await store.actions.fetch()
|
await store.actions.fetch()
|
||||||
|
store.actions.select(response._id)
|
||||||
return response.automation
|
return response.automation
|
||||||
},
|
},
|
||||||
delete: async automation => {
|
delete: async automation => {
|
||||||
|
@ -113,18 +110,22 @@ const automationActions = store => ({
|
||||||
automationId: automation?._id,
|
automationId: automation?._id,
|
||||||
automationRev: automation?._rev,
|
automationRev: automation?._rev,
|
||||||
})
|
})
|
||||||
|
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
// Remove the automation
|
// Remove the automation
|
||||||
state.automations = state.automations.filter(
|
state.automations = state.automations.filter(
|
||||||
x => x._id !== automation._id
|
x => x._id !== automation._id
|
||||||
)
|
)
|
||||||
|
|
||||||
// Select a new automation if required
|
// Select a new automation if required
|
||||||
if (automation._id === state.selectedAutomationId) {
|
if (automation._id === state.selectedAutomationId) {
|
||||||
store.actions.select(state.automations[0]?._id)
|
state.selectedAutomationId = state.automations[0]?._id || null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear out automationDisplayData for the automation
|
||||||
|
delete state.automationDisplayData[automation._id]
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
await store.actions.fetch()
|
|
||||||
},
|
},
|
||||||
toggleDisabled: async automationId => {
|
toggleDisabled: async automationId => {
|
||||||
let automation
|
let automation
|
||||||
|
@ -381,7 +382,7 @@ export const selectedAutomation = derived(automationStore, $automationStore => {
|
||||||
export const selectedAutomationDisplayData = derived(
|
export const selectedAutomationDisplayData = derived(
|
||||||
[automationStore, selectedAutomation],
|
[automationStore, selectedAutomation],
|
||||||
([$automationStore, $selectedAutomation]) => {
|
([$automationStore, $selectedAutomation]) => {
|
||||||
if (!$selectedAutomation._id) {
|
if (!$selectedAutomation?._id) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return $automationStore.automationDisplayData[$selectedAutomation._id]
|
return $automationStore.automationDisplayData[$selectedAutomation._id]
|
||||||
|
|
Loading…
Reference in New Issue