Skip to content

Commit 09868ba

Browse files
Merge pull request #303 from community-scripts/fix/289
fix: Add 'Delete only from DB' option for duplicate detected scripts
2 parents 8c47478 + b192c46 commit 09868ba

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/app/_components/InstalledScriptsTab.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,26 @@ export function InstalledScriptsTab() {
517517
}
518518
}
519519

520-
const handleDeleteScript = (id: number) => {
521-
if (confirm('Are you sure you want to delete this installation record?')) {
522-
void deleteScriptMutation.mutate({ id });
520+
const handleDeleteScript = (id: number, script?: InstalledScript) => {
521+
const scriptToDelete = script ?? scripts.find(s => s.id === id);
522+
523+
if (scriptToDelete && scriptToDelete.container_id && scriptToDelete.execution_mode === 'ssh') {
524+
// For SSH scripts with container_id, use confirmation modal
525+
setConfirmationModal({
526+
isOpen: true,
527+
variant: 'simple',
528+
title: 'Delete Database Record Only',
529+
message: `This will only delete the database record for "${scriptToDelete.script_name}" (Container ID: ${scriptToDelete.container_id}).\n\nThe container will remain intact and can be re-detected later via auto-detect.`,
530+
onConfirm: () => {
531+
void deleteScriptMutation.mutate({ id });
532+
setConfirmationModal(null);
533+
}
534+
});
535+
} else {
536+
// For non-SSH scripts or scripts without container_id, use simple confirm
537+
if (confirm('Are you sure you want to delete this installation record?')) {
538+
void deleteScriptMutation.mutate({ id });
539+
}
523540
}
524541
};
525542

@@ -1568,6 +1585,14 @@ export function InstalledScriptsTab() {
15681585
>
15691586
{controllingScriptId === script.id ? 'Working...' : 'Destroy'}
15701587
</DropdownMenuItem>
1588+
<DropdownMenuSeparator className="bg-border" />
1589+
<DropdownMenuItem
1590+
onClick={() => handleDeleteScript(script.id, script)}
1591+
disabled={deleteScriptMutation.isPending}
1592+
className="text-muted-foreground hover:text-foreground hover:bg-muted/20 focus:bg-muted/20"
1593+
>
1594+
{deleteScriptMutation.isPending ? 'Deleting...' : 'Delete only from DB'}
1595+
</DropdownMenuItem>
15711596
</>
15721597
)}
15731598
{(!script.container_id || script.execution_mode !== 'ssh') && (

0 commit comments

Comments
 (0)