Skip to content

Commit d9e071b

Browse files
feat: Replace update script alerts with custom confirmation modal
- Replace browser alert() with custom ErrorModal for validation errors - Replace browser confirm() with custom ConfirmationModal for update confirmation - Add type-to-confirm safety feature requiring container ID input - Include data loss warning and backup recommendation in confirmation message - Consistent UI/UX with other confirmation dialogs - Better error messaging with detailed information
1 parent 89588c8 commit d9e071b

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

src/app/_components/InstalledScriptsTab.tsx

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -481,29 +481,44 @@ export function InstalledScriptsTab() {
481481

482482
const handleUpdateScript = (script: InstalledScript) => {
483483
if (!script.container_id) {
484-
alert('No Container ID available for this script');
484+
setErrorModal({
485+
isOpen: true,
486+
title: 'Update Failed',
487+
message: 'No Container ID available for this script',
488+
details: 'This script does not have a valid container ID and cannot be updated.'
489+
});
485490
return;
486491
}
487492

488-
if (confirm(`Are you sure you want to update ${script.script_name}?`)) {
489-
// Get server info if it's SSH mode
490-
let server = null;
491-
if (script.server_id && script.server_user && script.server_password) {
492-
server = {
493-
id: script.server_id,
494-
name: script.server_name,
495-
ip: script.server_ip,
496-
user: script.server_user,
497-
password: script.server_password
498-
};
493+
// Show confirmation modal with type-to-confirm for update
494+
setConfirmationModal({
495+
isOpen: true,
496+
title: 'Confirm Script Update',
497+
message: `Are you sure you want to update "${script.script_name}"?\n\n⚠️ WARNING: This will re-run the script installation process and may overwrite existing data. Consider backing up your data beforehand.`,
498+
variant: 'danger',
499+
confirmText: script.container_id,
500+
confirmButtonText: 'Update Script',
501+
onConfirm: () => {
502+
// Get server info if it's SSH mode
503+
let server = null;
504+
if (script.server_id && script.server_user && script.server_password) {
505+
server = {
506+
id: script.server_id,
507+
name: script.server_name,
508+
ip: script.server_ip,
509+
user: script.server_user,
510+
password: script.server_password
511+
};
512+
}
513+
514+
setUpdatingScript({
515+
id: script.id,
516+
containerId: script.container_id!,
517+
server: server
518+
});
519+
setConfirmationModal(null);
499520
}
500-
501-
setUpdatingScript({
502-
id: script.id,
503-
containerId: script.container_id,
504-
server: server
505-
});
506-
}
521+
});
507522
};
508523

509524
const handleCloseUpdateTerminal = () => {
@@ -525,7 +540,12 @@ export function InstalledScriptsTab() {
525540

526541
const handleSaveEdit = () => {
527542
if (!editFormData.script_name.trim()) {
528-
alert('Script name is required');
543+
setErrorModal({
544+
isOpen: true,
545+
title: 'Validation Error',
546+
message: 'Script name is required',
547+
details: 'Please enter a valid script name before saving.'
548+
});
529549
return;
530550
}
531551

0 commit comments

Comments
 (0)