From 71be3b3641329d5f22b54f9223deba436b47ee03 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 15 Jun 2021 08:21:37 +0200 Subject: [PATCH] dialogs - fill in proper options used elsewhere --- src/vs/code/electron-main/app.ts | 6 ++++- src/vs/code/electron-main/main.ts | 1 + .../issue/electron-main/issueMainService.ts | 25 +++++++++++++------ .../electron-main/nativeHostMainService.ts | 17 +++++++++++-- .../platform/windows/electron-main/window.ts | 20 +++++++++++---- .../electron-main/windowsMainService.ts | 5 ++-- .../workspacesManagementMainService.ts | 6 +++-- 7 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index a6099e46121..006c4b79713 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -851,6 +851,7 @@ export class CodeApplication extends Disposable { mnemonicButtonLabel(localize({ key: 'open', comment: ['&& denotes a mnemonic'] }, "&&Yes")), mnemonicButtonLabel(localize({ key: 'cancel', comment: ['&& denotes a mnemonic'] }, "&&No")), ], + defaultId: 0, cancelId: 1, message: localize('confirmOpenMessage', "An external application wants to open '{0}' in {1}. Do you want to open this file or folder?", getPathLabel(uri.fsPath, this.environmentMainService), this.productService.nameShort), detail: localize('confirmOpenDetail', "If you did not initiate this request, it may represent an attempted attack on your system. Unless you took an explicit action to initiate this request, you should press 'No'"), @@ -1052,10 +1053,13 @@ export class CodeApplication extends Disposable { if (!timeout) { dialogMainService.showMessageBox({ + title: this.productService.nameLong, type: 'info', message: localize('trace.message', "Successfully created trace."), detail: localize('trace.detail', "Please create an issue and manually attach the following file:\n{0}", path), - buttons: [localize('trace.ok', "OK")] + buttons: [mnemonicButtonLabel(localize({ key: 'trace.ok', comment: ['&& denotes a mnemonic'] }, "&&OK"))], + defaultId: 0, + noLink: true }, withNullAsUndefined(BrowserWindow.getFocusedWindow())); } else { this.logService.info(`Tracing: data recorded (after 30s timeout) to ${path}`); diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 9d5eb03747f..c3477d25bc7 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -375,6 +375,7 @@ class CodeMain { buttons: [mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close"))], message, detail, + defaultId: 0, noLink: true }); } diff --git a/src/vs/platform/issue/electron-main/issueMainService.ts b/src/vs/platform/issue/electron-main/issueMainService.ts index 0df99eba03e..22fd82a67f6 100644 --- a/src/vs/platform/issue/electron-main/issueMainService.ts +++ b/src/vs/platform/issue/electron-main/issueMainService.ts @@ -22,6 +22,8 @@ import { FileAccess } from 'vs/base/common/network'; import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService'; import { IIPCObjectUrl, IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol'; import { DisposableStore } from 'vs/base/common/lifecycle'; +import { mnemonicButtonLabel } from 'vs/base/common/labels'; +import { IProductService } from 'vs/platform/product/common/productService'; export const IIssueMainService = createDecorator('issueMainService'); @@ -54,7 +56,8 @@ export class IssueMainService implements ICommonIssueService { @IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService, @IDialogMainService private readonly dialogMainService: IDialogMainService, @INativeHostMainService private readonly nativeHostMainService: INativeHostMainService, - @IProtocolMainService private readonly protocolMainService: IProtocolMainService + @IProtocolMainService private readonly protocolMainService: IProtocolMainService, + @IProductService private readonly productService: IProductService ) { this.registerListeners(); } @@ -99,12 +102,16 @@ export class IssueMainService implements ICommonIssueService { ipcMain.on('vscode:issueReporterClipboard', async event => { const messageOptions = { + title: this.productService.nameLong, message: localize('issueReporterWriteToClipboard', "There is too much data to send to GitHub directly. The data will be copied to the clipboard, please paste it into the GitHub issue page that is opened."), type: 'warning', buttons: [ - localize('ok', "OK"), - localize('cancel', "Cancel") - ] + mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK")), + mnemonicButtonLabel(localize({ key: 'cancel', comment: ['&& denotes a mnemonic'] }, "&&Cancel")), + ], + defaultId: 0, + cancelId: 1, + noLink: true }; if (this.issueReporterWindow) { @@ -120,12 +127,16 @@ export class IssueMainService implements ICommonIssueService { ipcMain.on('vscode:issueReporterConfirmClose', async () => { const messageOptions = { + title: this.productService.nameLong, message: localize('confirmCloseIssueReporter', "Your input will not be saved. Are you sure you want to close this window?"), type: 'warning', buttons: [ - localize('yes', "Yes"), - localize('cancel', "Cancel") - ] + mnemonicButtonLabel(localize({ key: 'yes', comment: ['&& denotes a mnemonic'] }, "&&Yes")), + mnemonicButtonLabel(localize({ key: 'cancel', comment: ['&& denotes a mnemonic'] }, "&&Cancel")), + ], + defaultId: 0, + cancelId: 1, + noLink: true }; if (this.issueReporterWindow) { diff --git a/src/vs/platform/native/electron-main/nativeHostMainService.ts b/src/vs/platform/native/electron-main/nativeHostMainService.ts index a1eea1a4d84..4443c92b4a0 100644 --- a/src/vs/platform/native/electron-main/nativeHostMainService.ts +++ b/src/vs/platform/native/electron-main/nativeHostMainService.ts @@ -33,6 +33,7 @@ import { memoize } from 'vs/base/common/decorators'; import { Disposable } from 'vs/base/common/lifecycle'; import { ISharedProcess } from 'vs/platform/sharedProcess/node/sharedProcess'; import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService'; +import { mnemonicButtonLabel } from 'vs/base/common/labels'; export interface INativeHostMainService extends AddFirstParameterToFunctions /* only methods, not events */, number | undefined /* window ID */> { } @@ -291,9 +292,15 @@ export class NativeHostMainService extends Disposable implements INativeHostMain } const { response } = await this.showMessageBox(windowId, { + title: this.productService.nameLong, type: 'info', message: localize('warnEscalation', "{0} will now prompt with 'osascript' for Administrator privileges to install the shell command.", this.productService.nameShort), - buttons: [localize('ok', "OK"), localize('cancel', "Cancel")], + buttons: [ + mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK")), + mnemonicButtonLabel(localize({ key: 'cancel', comment: ['&& denotes a mnemonic'] }, "&&Cancel")), + ], + noLink: true, + defaultId: 0, cancelId: 1 }); @@ -317,9 +324,15 @@ export class NativeHostMainService extends Disposable implements INativeHostMain switch (error.code) { case 'EACCES': const { response } = await this.showMessageBox(windowId, { + title: this.productService.nameLong, type: 'info', message: localize('warnEscalationUninstall', "{0} will now prompt with 'osascript' for Administrator privileges to uninstall the shell command.", this.productService.nameShort), - buttons: [localize('ok', "OK"), localize('cancel', "Cancel")], + buttons: [ + mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK")), + mnemonicButtonLabel(localize({ key: 'cancel', comment: ['&& denotes a mnemonic'] }, "&&Cancel")), + ], + noLink: true, + defaultId: 0, cancelId: 1 }); diff --git a/src/vs/platform/windows/electron-main/window.ts b/src/vs/platform/windows/electron-main/window.ts index f0a1425f0d3..a7691c91544 100644 --- a/src/vs/platform/windows/electron-main/window.ts +++ b/src/vs/platform/windows/electron-main/window.ts @@ -604,10 +604,16 @@ export class CodeWindow extends Disposable implements ICodeWindow { const result = await this.dialogMainService.showMessageBox({ title: this.productService.nameLong, type: 'warning', - buttons: [mnemonicButtonLabel(localize({ key: 'reopen', comment: ['&& denotes a mnemonic'] }, "&&Reopen")), mnemonicButtonLabel(localize({ key: 'wait', comment: ['&& denotes a mnemonic'] }, "&&Keep Waiting")), mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close"))], + buttons: [ + mnemonicButtonLabel(localize({ key: 'reopen', comment: ['&& denotes a mnemonic'] }, "&&Reopen")), + mnemonicButtonLabel(localize({ key: 'wait', comment: ['&& denotes a mnemonic'] }, "&&Keep Waiting")), + mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close")) + ], message: localize('appStalled', "The window is no longer responding"), detail: localize('appStalledDetail', "You can reopen or close the window or keep waiting."), - noLink: true + noLink: true, + defaultId: 0, + cancelId: 1 }, this._win); if (!this._win) { @@ -634,10 +640,14 @@ export class CodeWindow extends Disposable implements ICodeWindow { const result = await this.dialogMainService.showMessageBox({ title: this.productService.nameLong, type: 'warning', - buttons: [mnemonicButtonLabel(localize({ key: 'reopen', comment: ['&& denotes a mnemonic'] }, "&&Reopen")), mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close"))], + buttons: [ + mnemonicButtonLabel(localize({ key: 'reopen', comment: ['&& denotes a mnemonic'] }, "&&Reopen")), + mnemonicButtonLabel(localize({ key: 'close', comment: ['&& denotes a mnemonic'] }, "&&Close")) + ], message, - detail: localize('appCrashedDetail', "We are sorry for the inconvenience! You can reopen the window to continue where you left off."), - noLink: true + detail: localize('appCrashedDetail', "We are sorry for the inconvenience. You can reopen the window to continue where you left off."), + noLink: true, + defaultId: 0 }, this._win); if (!this._win) { diff --git a/src/vs/platform/windows/electron-main/windowsMainService.ts b/src/vs/platform/windows/electron-main/windowsMainService.ts index 48bd81a5bae..764491b8bc3 100644 --- a/src/vs/platform/windows/electron-main/windowsMainService.ts +++ b/src/vs/platform/windows/electron-main/windowsMainService.ts @@ -41,7 +41,7 @@ import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMain import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types'; import { isWindowsDriveLetter, toSlashes, parseLineAndColumnAware, sanitizeFilePath } from 'vs/base/common/extpath'; import { CharCode } from 'vs/base/common/charCode'; -import { getPathLabel } from 'vs/base/common/labels'; +import { getPathLabel, mnemonicButtonLabel } from 'vs/base/common/labels'; import { CancellationToken } from 'vs/base/common/cancellation'; import { IFileService } from 'vs/platform/files/common/files'; import { cwd } from 'vs/base/common/process'; @@ -702,7 +702,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic const options: MessageBoxOptions = { title: this.productService.nameLong, type: 'info', - buttons: [localize('ok', "OK")], + buttons: [mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK"))], + defaultId: 0, message: uri.scheme === Schemas.file ? localize('pathNotExistTitle', "Path does not exist") : localize('uriInvalidTitle', "URI can not be opened"), detail: uri.scheme === Schemas.file ? localize('pathNotExistDetail', "The path '{0}' does not seem to exist anymore on disk.", getPathLabel(uri.fsPath, this.environmentMainService)) : diff --git a/src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts index 95156bdad36..689b76486ae 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts @@ -26,6 +26,7 @@ import { withNullAsUndefined } from 'vs/base/common/types'; import { IBackupMainService } from 'vs/platform/backup/electron-main/backup'; import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService'; import { findWindowOnWorkspaceOrFolder } from 'vs/platform/windows/electron-main/windowsFinder'; +import { mnemonicButtonLabel } from 'vs/base/common/labels'; export const IWorkspacesManagementMainService = createDecorator('workspacesManagementMainService'); @@ -273,10 +274,11 @@ export class WorkspacesManagementMainService extends Disposable implements IWork const options: MessageBoxOptions = { title: this.productService.nameLong, type: 'info', - buttons: [localize('ok', "OK")], + buttons: [mnemonicButtonLabel(localize({ key: 'ok', comment: ['&& denotes a mnemonic'] }, "&&OK"))], message: localize('workspaceOpenedMessage', "Unable to save workspace '{0}'", basename(workspacePath)), detail: localize('workspaceOpenedDetail', "The workspace is already opened in another window. Please close that window first and then try again."), - noLink: true + noLink: true, + defaultId: 0 }; await this.dialogMainService.showMessageBox(options, withNullAsUndefined(BrowserWindow.getFocusedWindow()));