Add a confirmation prompt when deleting folders and labels #1785

This commit is contained in:
Ben Gotow 2020-02-16 10:33:02 -06:00
parent b0387da59c
commit ef9ed3368f

View file

@ -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);
},