Skip to content

Commit 7523f5b

Browse files
committed
add duplicate config feature to dashboard
1 parent ce9ef95 commit 7523f5b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/routes/dashboard/+page.svelte

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,24 @@
303303
}
304304
}
305305
306+
async function duplicateConfig(slug: string) {
307+
try {
308+
const response = await fetch(`/api/configs/${slug}`);
309+
const data = await response.json();
310+
const source = data.config;
311+
openModal({
312+
...source,
313+
id: '',
314+
slug: '',
315+
name: source.name + ' (Copy)',
316+
alias: null
317+
});
318+
editingSlug = '';
319+
} catch (e) {
320+
alert('Failed to duplicate configuration');
321+
}
322+
}
323+
306324
function copyToClipboard(text: string, configId: string) {
307325
navigator.clipboard.writeText(text);
308326
copiedId = configId;
@@ -451,6 +469,7 @@
451469
</div>
452470
<div class="config-actions" onclick={(e) => e.stopPropagation()}>
453471
<Button variant="secondary" onclick={() => editConfig(config.slug)}>Edit</Button>
472+
<Button variant="secondary" onclick={() => duplicateConfig(config.slug)}>Duplicate</Button>
454473
<Button variant="danger" onclick={() => deleteConfig(config.slug)}>Delete</Button>
455474
</div>
456475
</div>

0 commit comments

Comments
 (0)