From 9b4c2b5acd0d9dd47635aba51a418c51767255b1 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 18 May 2017 12:47:43 +0200 Subject: [PATCH] perf - polish profile, create issue, restart flow --- .../performance.contribution.ts | 23 +++++++++++++++---- .../electron-browser/messageService.ts | 19 ++++++++++----- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts index 1df63eac28d..0cc4a86b200 100644 --- a/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts +++ b/src/vs/workbench/parts/performance/electron-browser/performance.contribution.ts @@ -181,15 +181,28 @@ class StartupProfiler implements IWorkbenchContribution { secondaryButton: localize('prof.restart', "Restart") }); - let createIssue = TPromise.as(void 0); if (primaryButton) { const action = this._instantiationService.createInstance(ReportPerformanceIssueAction, ReportPerformanceIssueAction.ID, ReportPerformanceIssueAction.LABEL); - - createIssue = action.run(`:warning: Make sure to **attach** these files: :warning:\n${files.map(file => `-\`${join(profileStartup.dir, file)}\``).join('\n')}`).then(() => { - return this._windowsService.showItemInFolder(join(profileStartup.dir, files[0])); + TPromise.join([ + this._windowsService.showItemInFolder(join(profileStartup.dir, files[0])), + action.run(`:warning: Make sure to **attach** these files: :warning:\n${files.map(file => `-\`${join(profileStartup.dir, file)}\``).join('\n')}`) + ]).then(() => { + // keep window stable until restart is selected + this._messageService.confirm({ + type: 'info', + message: localize('prof.thanks', "Thanks for helping us."), + detail: localize('prof.detail.restart', "A final restart is required to continue to use '{0}'. Again, thank you for your contribution.", this._environmentService.appNameLong), + primaryButton: localize('prof.restart', "Restart"), + secondaryButton: null + }); + // now we are ready to restart + this._windowsService.relaunch({ removeArgs: ['--prof-startup'] }); }); + + } else { + // simply restart + this._windowsService.relaunch({ removeArgs: ['--prof-startup'] }); } - createIssue.then(() => this._windowsService.relaunch({ removeArgs: ['--prof-startup'] })); }); }); } diff --git a/src/vs/workbench/services/message/electron-browser/messageService.ts b/src/vs/workbench/services/message/electron-browser/messageService.ts index 607db7a5253..811ba46eb10 100644 --- a/src/vs/workbench/services/message/electron-browser/messageService.ts +++ b/src/vs/workbench/services/message/electron-browser/messageService.ts @@ -26,17 +26,24 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe } public confirm(confirmation: IConfirmation): boolean { - if (!confirmation.primaryButton) { - confirmation.primaryButton = nls.localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"); + + const buttons: string[] = []; + if (confirmation.primaryButton) { + buttons.push(confirmation.primaryButton); + } else { + buttons.push(nls.localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes")); } - if (!confirmation.secondaryButton) { - confirmation.secondaryButton = nls.localize('cancelButton', "Cancel"); + + if (confirmation.secondaryButton) { + buttons.push(confirmation.secondaryButton); + } else if (typeof confirmation.secondaryButton === 'undefined') { + buttons.push(nls.localize('cancelButton', "Cancel")); } let opts: Electron.ShowMessageBoxOptions = { title: confirmation.title, message: confirmation.message, - buttons: [confirmation.primaryButton, confirmation.secondaryButton], + buttons, defaultId: 0, cancelId: 1 }; @@ -102,4 +109,4 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe return label.replace(/&&/g, '&'); } -} \ No newline at end of file +}