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 { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
export class ProfilerConnect extends Action {
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 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');
}
run(input: ProfilerInput): Promise<void> {
input.data.clear();
return Promise.resolve(null);
async run(input: ProfilerInput): Promise<void> {
this._notificationService.prompt(Severity.Warning, nls.localize('profiler.clearDataPrompt', "Are you sure you want to clear the data?"), [
{
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");
constructor(
id: string, label: string
id: string,
label: string,
@INotificationService private _notificationService: INotificationService
) {
super(id, label, 'clear-filter');
}
public run(input: ProfilerInput): Promise<boolean> {
input.clearFilter();
return Promise.resolve(true);
public async run(input: ProfilerInput): Promise<void> {
this._notificationService.prompt(Severity.Warning, nls.localize('profiler.clearFilterPrompt', "Are you sure you want to clear the filters?"), [
{
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._pauseAction },
{ element: Taskbar.createTaskbarSeparator() },
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) },
{ element: Taskbar.createTaskbarSeparator() },
{ action: this._filterAction },
{ action: this._clearFilterAction },
{ element: Taskbar.createTaskbarSeparator() },
{ element: this._createTextElement(nls.localize('profiler.viewSelectLabel', "Select View:")) },
{ element: viewTemplateContainer },
{ action: this._autoscrollAction },
{ action: this._instantiationService.createInstance(Actions.ProfilerClear, Actions.ProfilerClear.ID, Actions.ProfilerClear.LABEL) }
{ action: this._autoscrollAction }
]);
}