From ef9ed3368f08e0e6a667a87e70dfb25d80cdd6b5 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 16 Feb 2020 10:33:02 -0600 Subject: [PATCH] Add a confirmation prompt when deleting folders and labels #1785 --- .../account-sidebar/lib/sidebar-item.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/internal_packages/account-sidebar/lib/sidebar-item.ts b/app/internal_packages/account-sidebar/lib/sidebar-item.ts index 3592da770..b1cf591ee 100644 --- a/app/internal_packages/account-sidebar/lib/sidebar-item.ts +++ b/app/internal_packages/account-sidebar/lib/sidebar-item.ts @@ -1,4 +1,5 @@ import _ from 'underscore'; +import { remote } from 'electron'; import _str from 'underscore.string'; import { OutlineViewItem } from 'mailspring-component-kit'; import { @@ -9,6 +10,7 @@ import { CategoryStore, Actions, RegExpUtils, + localized, } from 'mailspring-exports'; import * as SidebarActions from './sidebar-actions'; @@ -42,7 +44,6 @@ const toggleItemCollapsed = function(item) { }; const onDeleteItem = function(item) { - // TODO Delete multiple categories at once if (item.deleted === true) { return; } @@ -51,6 +52,20 @@ const onDeleteItem = function(item) { return; } + const chosen = remote.dialog.showMessageBox({ + type: 'info', + message: localized('Are you sure?'), + detail: localized( + 'Deleting folders and labels cannot be undone and it may take a few minutes for changes to sync to Mailspring.' + ), + buttons: [localized('Delete'), localized('Cancel')], + defaultId: 0, + }); + + if (chosen !== 0) { + return; + } + Actions.queueTask( new DestroyCategoryTask({ path: category.path, @@ -147,7 +162,9 @@ export default class SidebarItem { // We can't inspect the drag payload until drop, so we use a dataTransfer // type to encode the account IDs of threads currently being dragged. - const accountsType = event.dataTransfer.types.find(t => t.startsWith('mailspring-accounts=')); + const accountsType = event.dataTransfer.types.find(t => + t.startsWith('mailspring-accounts=') + ); const accountIds = (accountsType || '').replace('mailspring-accounts=', '').split(','); return target.canReceiveThreadsFromAccountIds(accountIds); },