Skip to content

Commit

Permalink
Add confirm dialog when deleting server
Browse files Browse the repository at this point in the history
  • Loading branch information
flebel9 committed Dec 7, 2024
1 parent 94bbc84 commit 534c7b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/controllers/session/selectServer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
});
}

Expand Down
1 change: 1 addition & 0 deletions src/strings/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 534c7b6

Please sign in to comment.