feat(ui): add Clone option to automations 3-dots menu (#25790)
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
let loading = false;
|
||||
|
||||
let showCreateModal = false;
|
||||
let cloneFrom: AutomationResponse | null = null;
|
||||
|
||||
let showDeleteConfirm = false;
|
||||
let deleteTarget: AutomationResponse | null = null;
|
||||
@@ -69,6 +70,10 @@
|
||||
getAutomationList();
|
||||
}
|
||||
|
||||
$: if (!showCreateModal) {
|
||||
cloneFrom = null;
|
||||
}
|
||||
|
||||
const getAutomationList = async () => {
|
||||
if (!loaded) return;
|
||||
|
||||
@@ -143,6 +148,14 @@
|
||||
getAutomationList();
|
||||
};
|
||||
|
||||
const cloneHandler = (automation: AutomationResponse) => {
|
||||
cloneFrom = {
|
||||
...automation,
|
||||
name: `${automation.name} (Clone)`
|
||||
};
|
||||
showCreateModal = true;
|
||||
};
|
||||
|
||||
const formatRRule = (rrule: string): string => {
|
||||
// Detect one-time schedule (ONCE)
|
||||
if (rrule.includes('COUNT=1')) {
|
||||
@@ -229,6 +242,7 @@
|
||||
<AutomationModal
|
||||
bind:show={showCreateModal}
|
||||
automation={null}
|
||||
{cloneFrom}
|
||||
on:save={(e) => {
|
||||
getAutomationList();
|
||||
if (e.detail?.id) {
|
||||
@@ -275,6 +289,7 @@
|
||||
<button
|
||||
class="px-2 py-1.5 rounded-xl bg-black text-white dark:bg-white dark:text-black transition font-medium text-sm flex items-center"
|
||||
on:click={() => {
|
||||
cloneFrom = null;
|
||||
showCreateModal = true;
|
||||
}}
|
||||
>
|
||||
@@ -434,6 +449,9 @@
|
||||
editHandler={() => {
|
||||
goto(`/automations/${automation.id}`);
|
||||
}}
|
||||
cloneHandler={() => {
|
||||
cloneHandler(automation);
|
||||
}}
|
||||
runHandler={() => {
|
||||
runNowHandler(automation);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user