fix: Add 'Delete only from DB' option for duplicate detected scripts
- Add 'Delete only from DB' option in Actions dropdown for SSH scripts with container_id - Place option after 'Destroy' with separator to distinguish from destructive action - Update handleDeleteScript to use confirmation modal for SSH scripts - Modal clearly states it only deletes database record, container remains intact - Allows users to clean up duplicate script entries without destroying containers - Fixes issue where duplicates could only be removed by destroying the host
This commit is contained in:
@@ -517,9 +517,26 @@ export function InstalledScriptsTab() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDeleteScript = (id: number) => {
|
const handleDeleteScript = (id: number, script?: InstalledScript) => {
|
||||||
if (confirm('Are you sure you want to delete this installation record?')) {
|
const scriptToDelete = script ?? scripts.find(s => s.id === id);
|
||||||
void deleteScriptMutation.mutate({ id });
|
|
||||||
|
if (scriptToDelete && scriptToDelete.container_id && scriptToDelete.execution_mode === 'ssh') {
|
||||||
|
// For SSH scripts with container_id, use confirmation modal
|
||||||
|
setConfirmationModal({
|
||||||
|
isOpen: true,
|
||||||
|
variant: 'simple',
|
||||||
|
title: 'Delete Database Record Only',
|
||||||
|
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.`,
|
||||||
|
onConfirm: () => {
|
||||||
|
void deleteScriptMutation.mutate({ id });
|
||||||
|
setConfirmationModal(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// For non-SSH scripts or scripts without container_id, use simple confirm
|
||||||
|
if (confirm('Are you sure you want to delete this installation record?')) {
|
||||||
|
void deleteScriptMutation.mutate({ id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1568,6 +1585,14 @@ export function InstalledScriptsTab() {
|
|||||||
>
|
>
|
||||||
{controllingScriptId === script.id ? 'Working...' : 'Destroy'}
|
{controllingScriptId === script.id ? 'Working...' : 'Destroy'}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuSeparator className="bg-border" />
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => handleDeleteScript(script.id, script)}
|
||||||
|
disabled={deleteScriptMutation.isPending}
|
||||||
|
className="text-muted-foreground hover:text-foreground hover:bg-muted/20 focus:bg-muted/20"
|
||||||
|
>
|
||||||
|
{deleteScriptMutation.isPending ? 'Deleting...' : 'Delete only from DB'}
|
||||||
|
</DropdownMenuItem>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{(!script.container_id || script.execution_mode !== 'ssh') && (
|
{(!script.container_id || script.execution_mode !== 'ssh') && (
|
||||||
|
|||||||
Reference in New Issue
Block a user