perf - polish profile, create issue, restart flow

This commit is contained in:
Johannes Rieken 2017-05-18 12:47:43 +02:00
parent c6d715e4e5
commit 9b4c2b5acd
2 changed files with 31 additions and 11 deletions

View file

@ -181,15 +181,28 @@ class StartupProfiler implements IWorkbenchContribution {
secondaryButton: localize('prof.restart', "Restart") secondaryButton: localize('prof.restart', "Restart")
}); });
let createIssue = TPromise.as<void>(void 0);
if (primaryButton) { if (primaryButton) {
const action = this._instantiationService.createInstance(ReportPerformanceIssueAction, ReportPerformanceIssueAction.ID, ReportPerformanceIssueAction.LABEL); const action = this._instantiationService.createInstance(ReportPerformanceIssueAction, ReportPerformanceIssueAction.ID, ReportPerformanceIssueAction.LABEL);
TPromise.join<any>([
createIssue = action.run(`:warning: Make sure to **attach** these files: :warning:\n${files.map(file => `-\`${join(profileStartup.dir, file)}\``).join('\n')}`).then(() => { this._windowsService.showItemInFolder(join(profileStartup.dir, files[0])),
return 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'] }));
}); });
}); });
} }

View file

@ -26,17 +26,24 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
} }
public confirm(confirmation: IConfirmation): boolean { 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 = { let opts: Electron.ShowMessageBoxOptions = {
title: confirmation.title, title: confirmation.title,
message: confirmation.message, message: confirmation.message,
buttons: [confirmation.primaryButton, confirmation.secondaryButton], buttons,
defaultId: 0, defaultId: 0,
cancelId: 1 cancelId: 1
}; };
@ -102,4 +109,4 @@ export class MessageService extends WorkbenchMessageService implements IChoiceSe
return label.replace(/&&/g, '&'); return label.replace(/&&/g, '&');
} }
} }