add confirm prompt for some profiler actions (#13952)

This commit is contained in:
Alan Ren
2021-01-13 15:02:05 -08:00
committed by GitHub
parent 1ec42a082e
commit 1d42431914
2 changed files with 34 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ import * as nls from 'vs/nls';
import { IEditorAction } from 'vs/editor/common/editorCommon'; import { IEditorAction } from 'vs/editor/common/editorCommon';
import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
export class ProfilerConnect extends Action { export class ProfilerConnect extends Action {
private static readonly ConnectText = nls.localize('profilerAction.connect', "Connect"); private static readonly ConnectText = nls.localize('profilerAction.connect', "Connect");
@@ -155,13 +156,24 @@ export class ProfilerClear extends Action {
public static ID = 'profiler.clear'; public static ID = 'profiler.clear';
public static LABEL = nls.localize('profiler.clear', "Clear Data"); public static LABEL = nls.localize('profiler.clear', "Clear Data");
constructor(id: string, label: string) { constructor(id: string,
label: string,
@INotificationService private _notificationService: INotificationService) {
super(id, label, 'clear-results'); super(id, label, 'clear-results');
} }
run(input: ProfilerInput): Promise<void> { async run(input: ProfilerInput): Promise<void> {
input.data.clear(); this._notificationService.prompt(Severity.Warning, nls.localize('profiler.clearDataPrompt', "Are you sure you want to clear the data?"), [
return Promise.resolve(null); {
label: nls.localize('profiler.yes', "Yes"),
run: () => {
input.data.clear();
}
}, {
label: nls.localize('profiler.no', "No"),
run: () => { }
}
]);
} }
} }
@@ -317,13 +329,24 @@ export class ProfilerClearSessionFilter extends Action {
public static LABEL = nls.localize('profiler.clearFilter', "Clear Filter"); public static LABEL = nls.localize('profiler.clearFilter', "Clear Filter");
constructor( constructor(
id: string, label: string id: string,
label: string,
@INotificationService private _notificationService: INotificationService
) { ) {
super(id, label, 'clear-filter'); super(id, label, 'clear-filter');
} }
public run(input: ProfilerInput): Promise<boolean> { public async run(input: ProfilerInput): Promise<void> {
input.clearFilter(); this._notificationService.prompt(Severity.Warning, nls.localize('profiler.clearFilterPrompt', "Are you sure you want to clear the filters?"), [
return Promise.resolve(true); {
label: nls.localize('profiler.yes', "Yes"),
run: () => {
input.clearFilter();
}
}, {
label: nls.localize('profiler.no', "No"),
run: () => { }
}
]);
} }
} }

View File

@@ -272,13 +272,14 @@ export class ProfilerEditor extends EditorPane {
{ action: this._stopAction }, { action: this._stopAction },
{ action: this._pauseAction }, { action: this._pauseAction },
{ element: Taskbar.createTaskbarSeparator() }, { element: Taskbar.createTaskbarSeparator() },
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) },
{ element: Taskbar.createTaskbarSeparator() },
{ action: this._filterAction }, { action: this._filterAction },
{ action: this._clearFilterAction }, { action: this._clearFilterAction },
{ element: Taskbar.createTaskbarSeparator() }, { element: Taskbar.createTaskbarSeparator() },
{ element: this._createTextElement(nls.localize('profiler.viewSelectLabel', "Select View:")) }, { element: this._createTextElement(nls.localize('profiler.viewSelectLabel', "Select View:")) },
{ element: viewTemplateContainer }, { element: viewTemplateContainer },
{ action: this._autoscrollAction }, { action: this._autoscrollAction }
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) }
]); ]);
} }