From 534c7b616cf8ae45acaa7797a7ffad7b5a87d75a Mon Sep 17 00:00:00 2001 From: flebel9 <175349397+flebel9@users.noreply.github.com> Date: Sat, 7 Dec 2024 11:37:00 +0000 Subject: [PATCH] Add confirm dialog when deleting server --- src/controllers/session/selectServer/index.js | 20 +++++++++++++++---- src/strings/en-us.json | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/controllers/session/selectServer/index.js b/src/controllers/session/selectServer/index.js index 1c9fdf9ae31..8af9054edb3 100644 --- a/src/controllers/session/selectServer/index.js +++ b/src/controllers/session/selectServer/index.js @@ -7,6 +7,7 @@ import appSettings from '../../../scripts/settings/appSettings'; import focusManager from '../../../components/focusManager'; import globalize from '../../../lib/globalize'; import actionSheet from '../../../components/actionSheet/actionSheet'; +import confirm from '../../../components/confirm/confirm'; import dom from '../../../scripts/dom'; import browser from '../../../scripts/browser'; import 'material-design-icons-iconfont'; @@ -136,10 +137,21 @@ export default function (view, params) { } function deleteServer(server) { - loading.show(); - ServerConnections.deleteServer(server.Id).then(function () { - loading.hide(); - loadServers(); + confirm({ + title: globalize.translate('DeleteName', server.Name), + text: globalize.translate('DeleteServerConfirmation'), + confirmText: globalize.translate('Delete'), + primary: 'delete' + }).then(function () { + loading.show(); + ServerConnections.deleteServer(server.Id).then(function () { + loading.hide(); + loadServers(); + }).catch(err => { + console.error('[selectServer] failed to delete server', err); + }); + }).catch(() => { + // confirm dialog closed }); } diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 5095b109afc..d278c111a42 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -215,6 +215,7 @@ "DeleteName": "Delete {0}", "DeleteUser": "Delete User", "DeleteUserConfirmation": "Are you sure you wish to delete this user?", + "DeleteServerConfirmation": "Are you sure you wish to delete this server?", "Depressed": "Depressed", "Descending": "Descending", "Desktop": "Desktop",