Merge pull request #6603 from mslourens/duplicate_automation
6512 - duplicate automation
This commit is contained in:
commit
e49a9f640b
|
@ -68,7 +68,19 @@ const automationActions = store => ({
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
duplicate: async automation => {
|
||||||
|
const response = await API.createAutomation({
|
||||||
|
...automation,
|
||||||
|
name: `${automation.name} - copy`,
|
||||||
|
_id: undefined,
|
||||||
|
_ref: undefined,
|
||||||
|
})
|
||||||
|
store.update(state => {
|
||||||
|
state.automations = [...state.automations, response.automation]
|
||||||
|
store.actions.select(response.automation)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
},
|
||||||
save: async automation => {
|
save: async automation => {
|
||||||
const response = await API.updateAutomation(automation)
|
const response = await API.updateAutomation(automation)
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
|
|
@ -19,12 +19,23 @@
|
||||||
notifications.error("Error deleting automation")
|
notifications.error("Error deleting automation")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function duplicateAutomation() {
|
||||||
|
try {
|
||||||
|
await automationStore.actions.duplicate(automation)
|
||||||
|
notifications.success("Automation has been duplicated successfully")
|
||||||
|
$goto(`./${$automationStore.selectedAutomation.automation._id}`)
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error duplicating automation")
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ActionMenu>
|
<ActionMenu>
|
||||||
<div slot="control" class="icon">
|
<div slot="control" class="icon">
|
||||||
<Icon s hoverable name="MoreSmallList" />
|
<Icon s hoverable name="MoreSmallList" />
|
||||||
</div>
|
</div>
|
||||||
|
<MenuItem icon="Duplicate" on:click={duplicateAutomation}>Duplicate</MenuItem>
|
||||||
<MenuItem icon="Edit" on:click={updateAutomationDialog.show}>Edit</MenuItem>
|
<MenuItem icon="Edit" on:click={updateAutomationDialog.show}>Edit</MenuItem>
|
||||||
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
|
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem>
|
||||||
</ActionMenu>
|
</ActionMenu>
|
||||||
|
|
Loading…
Reference in New Issue