Skip to content

Commit

Permalink
Desktop: Resolves laurent22#1662: Set cancel as the default in danger…
Browse files Browse the repository at this point in the history
…ous operations (laurent22#1934)

* set cancel as the  default in dangerous operations, rename buttons (delete, remove) and context menu (for tags)

fixes laurent22#1662 (partially, because I can't fix the upstream issue, unless we update Electron)

* add default value for buttonLabel
  • Loading branch information
tessus authored and scoroi committed Nov 10, 2019
1 parent 7670831 commit c395ba6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ElectronClient/app/gui/SideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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) {
Expand Down

0 comments on commit c395ba6

Please sign in to comment.