From d7a50a1b48ff6fda6b13ef102829a644394bbf47 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Thu, 3 Oct 2019 17:33:49 -0400 Subject: [PATCH] Desktop: Resolves #1662: Set cancel as the default in dangerous operations (#1934) * set cancel as the default in dangerous operations, rename buttons (delete, remove) and context menu (for tags) fixes #1662 (partially, because I can't fix the upstream issue, unless we update Electron) * add default value for buttonLabel --- ElectronClient/app/gui/SideBar.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ElectronClient/app/gui/SideBar.jsx b/ElectronClient/app/gui/SideBar.jsx index c690bf76e..1290a62b1 100644 --- a/ElectronClient/app/gui/SideBar.jsx +++ b/ElectronClient/app/gui/SideBar.jsx @@ -267,9 +267,11 @@ class SideBarComponent extends React.Component { if (!itemId || !itemType) throw new Error('No data on element'); let deleteMessage = ''; + let buttonLabel = _('Remove'); if (itemType === BaseModel.TYPE_FOLDER) { const folder = await Folder.load(itemId); deleteMessage = _('Delete notebook "%s"?\n\nAll notes and sub-notebooks within this notebook will also be deleted.', substrWithEllipsis(folder.title, 0, 32)); + buttonLabel = _('Delete'); } else if (itemType === BaseModel.TYPE_TAG) { const tag = await Tag.load(itemId); deleteMessage = _('Remove tag "%s" from all notes?', substrWithEllipsis(tag.title, 0, 32)); @@ -286,9 +288,12 @@ class SideBarComponent extends React.Component { menu.append( new MenuItem({ - label: _('Delete'), + label: buttonLabel, click: async () => { - const ok = bridge().showConfirmMessageBox(deleteMessage); + const ok = bridge().showConfirmMessageBox(deleteMessage, { + buttons: [buttonLabel, _('Cancel')], + defaultId: 1, + }); if (!ok) return; if (itemType === BaseModel.TYPE_FOLDER) {