mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
hide the backup restore commands from command palette (#2317)
This commit is contained in:
@@ -86,7 +86,7 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
|
|||||||
}).filter(i => !!i);
|
}).filter(i => !!i);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tasks = tasks.map(i => MenuRegistry.getCommand(i)).filter(v => !!v);
|
this._tasks = tasks.map(i => TaskRegistry.getCommandActionById(i)).filter(v => !!v);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ export abstract class Task {
|
|||||||
id: this.id,
|
id: this.id,
|
||||||
handler: (accessor, profile, args) => this.runTask(accessor, profile, args),
|
handler: (accessor, profile, args) => this.runTask(accessor, profile, args),
|
||||||
description: this._description,
|
description: this._description,
|
||||||
iconClass: this._iconClass
|
iconClass: this._iconClass,
|
||||||
|
iconPath: this.iconPath,
|
||||||
|
title: this.title
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +64,10 @@ export abstract class Task {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerTask(): IDisposable {
|
public registerTask(showInCommandPalette: boolean = true): IDisposable {
|
||||||
|
if (showInCommandPalette) {
|
||||||
MenuRegistry.addCommand(this.toCommandAction());
|
MenuRegistry.addCommand(this.toCommandAction());
|
||||||
|
}
|
||||||
return TaskRegistry.registerTask(this.toITask());
|
return TaskRegistry.registerTask(this.toITask());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +102,8 @@ export interface ITask {
|
|||||||
precondition?: ContextKeyExpr;
|
precondition?: ContextKeyExpr;
|
||||||
description?: ITaskHandlerDescription;
|
description?: ITaskHandlerDescription;
|
||||||
iconClass?: string;
|
iconClass?: string;
|
||||||
|
iconPath?: { dark: string; light?: string; };
|
||||||
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITaskRegistry {
|
export interface ITaskRegistry {
|
||||||
@@ -106,6 +112,7 @@ export interface ITaskRegistry {
|
|||||||
getTasks(): string[];
|
getTasks(): string[];
|
||||||
getOrCreateTaskIconClassName(item: ICommandAction): string;
|
getOrCreateTaskIconClassName(item: ICommandAction): string;
|
||||||
onTaskRegistered: Event<string>;
|
onTaskRegistered: Event<string>;
|
||||||
|
getCommandActionById(id: string): ICommandAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ids = new IdGenerator('task-icon-');
|
const ids = new IdGenerator('task-icon-');
|
||||||
@@ -116,6 +123,7 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
|
|||||||
private _onTaskRegistered = new Emitter<string>();
|
private _onTaskRegistered = new Emitter<string>();
|
||||||
public readonly onTaskRegistered: Event<string> = this._onTaskRegistered.event;
|
public readonly onTaskRegistered: Event<string> = this._onTaskRegistered.event;
|
||||||
private taskIdToIconClassNameMap: Map<string /* task id */, string /* CSS rule */> = new Map<string, string>();
|
private taskIdToIconClassNameMap: Map<string /* task id */, string /* CSS rule */> = new Map<string, string>();
|
||||||
|
private taskIdToCommandActionMap: Map<string, ICommandAction> = new Map<string, ICommandAction>();
|
||||||
|
|
||||||
registerTask(idOrTask: string | ITask, handler?: ITaskHandler): IDisposable {
|
registerTask(idOrTask: string | ITask, handler?: ITaskHandler): IDisposable {
|
||||||
let disposable: IDisposable;
|
let disposable: IDisposable;
|
||||||
@@ -127,6 +135,13 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
|
|||||||
if (idOrTask.iconClass) {
|
if (idOrTask.iconClass) {
|
||||||
this.taskIdToIconClassNameMap.set(idOrTask.id, idOrTask.iconClass);
|
this.taskIdToIconClassNameMap.set(idOrTask.id, idOrTask.iconClass);
|
||||||
}
|
}
|
||||||
|
if (idOrTask.iconPath && idOrTask.title) {
|
||||||
|
this.taskIdToCommandActionMap.set(idOrTask.id, {
|
||||||
|
iconPath: idOrTask.iconPath,
|
||||||
|
id: idOrTask.id,
|
||||||
|
title: idOrTask.title
|
||||||
|
});
|
||||||
|
}
|
||||||
disposable = CommandsRegistry.registerCommand(idOrTask);
|
disposable = CommandsRegistry.registerCommand(idOrTask);
|
||||||
id = idOrTask.id;
|
id = idOrTask.id;
|
||||||
}
|
}
|
||||||
@@ -161,4 +176,8 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
|
|||||||
getTasks(): string[] {
|
getTasks(): string[] {
|
||||||
return this._tasks.slice(0);
|
return this._tasks.slice(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCommandActionById(taskId: string): ICommandAction {
|
||||||
|
return this.taskIdToCommandActionMap.get(taskId);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
|
|||||||
import { ShowCurrentReleaseNotesAction } from 'sql/workbench/update/releaseNotes';
|
import { ShowCurrentReleaseNotesAction } from 'sql/workbench/update/releaseNotes';
|
||||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||||
|
|
||||||
new Actions.BackupAction().registerTask();
|
new Actions.BackupAction().registerTask(false);
|
||||||
new Actions.RestoreAction().registerTask();
|
new Actions.RestoreAction().registerTask(false);
|
||||||
new Actions.NewQueryAction().registerTask();
|
new Actions.NewQueryAction().registerTask();
|
||||||
new Actions.ConfigureDashboardAction().registerTask();
|
new Actions.ConfigureDashboardAction().registerTask();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user