提交 edba4536 编写于 作者: B Benjamin Pasero

files - tweak delete confirmation on error

上级 04fe3370
......@@ -51,7 +51,7 @@ import { IListService, ListWidget } from 'vs/platform/list/browser/listService';
import { RawContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { distinctParents, basenameOrAuthority } from 'vs/base/common/resources';
import { Schemas } from 'vs/base/common/network';
import { IConfirmationService, IConfirmationResult, IConfirmation, IChoiceService } from 'vs/platform/dialogs/common/dialogs';
import { IConfirmationService, IConfirmationResult, IConfirmation } from 'vs/platform/dialogs/common/dialogs';
import { getConfirmMessage } from 'vs/workbench/services/dialogs/electron-browser/dialogs';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
......@@ -568,8 +568,7 @@ class BaseDeleteFileAction extends BaseFileAction {
@INotificationService notificationService: INotificationService,
@IConfirmationService private confirmationService: IConfirmationService,
@ITextFileService textFileService: ITextFileService,
@IConfigurationService private configurationService: IConfigurationService,
@IChoiceService private choiceService: IChoiceService
@IConfigurationService private configurationService: IConfigurationService
) {
super('moveFileToTrash', MOVE_FILE_TO_TRASH_LABEL, fileService, notificationService, textFileService);
......@@ -647,7 +646,7 @@ class BaseDeleteFileAction extends BaseFileAction {
: nls.localize('confirmMoveTrashMessageFile', "Are you sure you want to delete '{0}'?", distinctElements[0].name);
confirmDeletePromise = this.confirmationService.confirmWithCheckbox({
message,
detail: isWindows ? nls.localize('undoBin', "You can restore from the recycle bin.") : nls.localize('undoTrash', "You can restore from the trash."),
detail: isWindows ? nls.localize('undoBin', "You can restore from the Recycle Bin.") : nls.localize('undoTrash', "You can restore from the Trash."),
primaryButton,
checkbox: {
label: nls.localize('doNotAskAgain', "Do not ask me again")
......@@ -690,36 +689,38 @@ class BaseDeleteFileAction extends BaseFileAction {
this.tree.setFocus(distinctElements[0].parent); // move focus to parent
}
}, (error: any) => {
const choices = [nls.localize('retry', "Retry"), nls.localize('cancel', "Cancel")];
// Handle error to delete file(s) from a modal confirmation dialog
let errorMessage: string;
let detailMessage: string;
let primaryButton: string;
if (this.useTrash) {
choices.unshift(nls.localize('permDelete', "Delete Permanently"));
errorMessage = isWindows ? nls.localize('binFailed', "Failed to delete using the Recycle Bin. Do you want to permanently delete instead?") : nls.localize('trashFailed', "Failed to delete using the Trash. Do you want to permanently delete instead?");
detailMessage = nls.localize('irreversible', "This action is irreversible!");
primaryButton = nls.localize({ key: 'deletePermanentlyButtonLabel', comment: ['&& denotes a mnemonic'] }, "&&Delete Permanently");
} else {
errorMessage = toErrorMessage(error, false);
primaryButton = nls.localize({ key: 'retryButtonLabel', comment: ['&& denotes a mnemonic'] }, "&&Retry");
}
return this.choiceService.choose(Severity.Error, toErrorMessage(error, false), choices, choices.length - 1, true).then(choice => {
return this.confirmationService.confirm({
message: errorMessage,
detail: detailMessage,
type: 'warning',
primaryButton
}).then(confirmed => {
// Focus back to tree
this.tree.domFocus();
if (this.useTrash) {
switch (choice) {
case 0: /* Delete Permanently*/
this.useTrash = false;
this.skipConfirm = true;
return this.run();
case 1: /* Retry */
this.skipConfirm = true;
return this.run();
if (confirmed) {
if (this.useTrash) {
this.useTrash = false; // Delete Permanently
}
} else {
switch (choice) {
case 0: /* Retry */
this.skipConfirm = true;
return this.run();
}
this.skipConfirm = true;
return this.run();
}
return TPromise.as(void 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册