提交 634e8ea9 编写于 作者: A Alex Ross

Simplify tasks command

上级 bca9d853
...@@ -12,6 +12,7 @@ import { RunOnOptions, Task, TaskRunSource } from 'vs/workbench/contrib/tasks/co ...@@ -12,6 +12,7 @@ import { RunOnOptions, Task, TaskRunSource } from 'vs/workbench/contrib/tasks/co
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
const ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE = 'tasks.run.allowAutomatic'; const ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE = 'tasks.run.allowAutomatic';
...@@ -131,38 +132,27 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut ...@@ -131,38 +132,27 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
} }
export class AllowAutomaticTaskRunning extends Action { export class ManageAutomaticTaskRunning extends Action {
public static readonly ID = 'workbench.action.tasks.allowAutomaticRunning'; public static readonly ID = 'workbench.action.tasks.manageAutomaticRunning';
public static readonly LABEL = nls.localize('workbench.action.tasks.allowAutomaticRunning', "Allow Automatic Tasks in Folder"); public static readonly LABEL = nls.localize('workbench.action.tasks.manageAutomaticRunning', "Manage Automatic Tasks in Folder");
constructor( constructor(
id: string, label: string, id: string, label: string,
@IStorageService private readonly storageService: IStorageService @IStorageService private readonly storageService: IStorageService,
@IQuickInputService private readonly quickInputService: IQuickInputService
) { ) {
super(id, label); super(id, label);
} }
public run(event?: any): Promise<any> { public async run(event?: any): Promise<any> {
this.storageService.store(ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE, true, StorageScope.WORKSPACE); const allowItem: IQuickPickItem = { label: nls.localize('workbench.action.tasks.allowAutomaticTasks', "Allow Automatic Tasks in Folder") };
return Promise.resolve(undefined); const disallowItem: IQuickPickItem = { label: nls.localize('workbench.action.tasks.disallowAutomaticTasks', "Disallow Automatic Tasks in Folder") };
} const value = await this.quickInputService.pick([allowItem, disallowItem], { canPickMany: false });
} if (!value) {
return;
export class DisallowAutomaticTaskRunning extends Action { }
public static readonly ID = 'workbench.action.tasks.disallowAutomaticRunning';
public static readonly LABEL = nls.localize('workbench.action.tasks.disallowAutomaticRunning', "Disallow Automatic Tasks in Folder");
constructor(
id: string, label: string,
@IStorageService private readonly storageService: IStorageService
) {
super(id, label);
}
public run(event?: any): Promise<any> { this.storageService.store(ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE, value === allowItem, StorageScope.WORKSPACE);
this.storageService.store(ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE, false, StorageScope.WORKSPACE);
return Promise.resolve(undefined);
} }
} }
...@@ -32,7 +32,7 @@ import { QuickOpenActionContributor } from '../browser/quickOpen'; ...@@ -32,7 +32,7 @@ import { QuickOpenActionContributor } from '../browser/quickOpen';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry, IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { RunAutomaticTasks, AllowAutomaticTaskRunning, DisallowAutomaticTaskRunning } from 'vs/workbench/contrib/tasks/browser/runAutomaticTasks'; import { RunAutomaticTasks, ManageAutomaticTaskRunning } from 'vs/workbench/contrib/tasks/browser/runAutomaticTasks';
let tasksCategory = nls.localize('tasksCategory', "Tasks"); let tasksCategory = nls.localize('tasksCategory', "Tasks");
...@@ -40,8 +40,7 @@ const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(Workbench ...@@ -40,8 +40,7 @@ const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(Workbench
workbenchRegistry.registerWorkbenchContribution(RunAutomaticTasks, LifecyclePhase.Eventually); workbenchRegistry.registerWorkbenchContribution(RunAutomaticTasks, LifecyclePhase.Eventually);
const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions); const actionRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(AllowAutomaticTaskRunning, AllowAutomaticTaskRunning.ID, AllowAutomaticTaskRunning.LABEL), 'Tasks: Allow Automatic Tasks in Folder', tasksCategory); actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ManageAutomaticTaskRunning, ManageAutomaticTaskRunning.ID, ManageAutomaticTaskRunning.LABEL), 'Tasks: Manage Automatic Tasks in Folder', tasksCategory);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(DisallowAutomaticTaskRunning, DisallowAutomaticTaskRunning.ID, DisallowAutomaticTaskRunning.LABEL), 'Tasks: Disallow Automatic Tasks in Folder', tasksCategory);
export class TaskStatusBarContributions extends Disposable implements IWorkbenchContribution { export class TaskStatusBarContributions extends Disposable implements IWorkbenchContribution {
private runningTasksStatusItem: IStatusbarEntryAccessor | undefined; private runningTasksStatusItem: IStatusbarEntryAccessor | undefined;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册