Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap tasks cmds as Actions for telemetry #29223

Merged
merged 2 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/vs/code/electron-main/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,16 @@ export class CodeMenu {
}

private setTaskMenu(taskMenu: Electron.Menu): void {
const runTask = this.createMenuItem(nls.localize({ key: 'miRunTask', comment: ['&& denotes a mnemonic'] }, "&&Run Task..."), 'workbench.action.tasks.runTask');
const restartTask = this.createMenuItem(nls.localize({ key: 'miRestartTask', comment: ['&& denotes a mnemonic'] }, "R&&estart Task"), 'workbench.action.tasks.restartTask');
const terminateTask = this.createMenuItem(nls.localize({ key: 'miTerminateTask', comment: ['&& denotes a mnemonic'] }, "&&Terminate Task"), 'workbench.action.tasks.terminate');
const buildTask = this.createMenuItem(nls.localize({ key: 'miBuildTask', comment: ['&& denotes a mnemonic'] }, "&&Build Task"), 'workbench.action.tasks.build');
const testTask = this.createMenuItem(nls.localize({ key: 'miTestTask', comment: ['&& denotes a mnemonic'] }, "Test T&&ask"), 'workbench.action.tasks.test');
const showTaskLog = this.createMenuItem(nls.localize({ key: 'miShowTaskLog', comment: ['&& denotes a mnemonic'] }, "&&Show Task Log"), 'workbench.action.tasks.showLog');
const runTask = this.createMenuItem(nls.localize({ key: 'miRunTask', comment: ['&& denotes a mnemonic'] }, "&&Run Task..."), 'workbench.action.taskAction.runTask');
const restartTask = this.createMenuItem(nls.localize({ key: 'miRestartTask', comment: ['&& denotes a mnemonic'] }, "R&&estart Task"), 'workbench.action.taskAction.restartTask');
const terminateTask = this.createMenuItem(nls.localize({ key: 'miTerminateTask', comment: ['&& denotes a mnemonic'] }, "&&Terminate Task"), 'workbench.action.taskAction.terminateTask');
const buildTask = this.createMenuItem(nls.localize({ key: 'miBuildTask', comment: ['&& denotes a mnemonic'] }, "&&Build Task"), 'workbench.action.taskAction.build');
const testTask = this.createMenuItem(nls.localize({ key: 'miTestTask', comment: ['&& denotes a mnemonic'] }, "Test T&&ask"), 'workbench.action.taskAction.test');
const showTaskLog = this.createMenuItem(nls.localize({ key: 'miShowTaskLog', comment: ['&& denotes a mnemonic'] }, "&&Show Task Log"), 'workbench.action.taskAction.showLog');
const configureTask = this.createMenuItem(nls.localize({ key: 'miConfigureTask', comment: ['&& denotes a mnemonic'] }, "&&Configure Task Runner"), 'workbench.action.tasks.configureTaskRunner');

[
configureTask,
showTaskLog,
runTask,
restartTask,
Expand Down
141 changes: 141 additions & 0 deletions src/vs/workbench/parts/tasks/common/taskActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

'use strict';

import { TPromise } from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import { Action } from 'vs/base/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';

export class RunTaskAction extends Action {

public static ID = 'workbench.action.taskAction.runTask';
public static LABEL = nls.localize('runTaskAction', "Run task");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.runTask');
return TPromise.as(null);
}
}

export class RestartTaskAction extends Action {

public static ID = 'workbench.action.taskAction.restartTask';
public static LABEL = nls.localize('restartTaskAction', "Restart task");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.restartTask');
return TPromise.as(null);
}
}

export class TerminateTaskAction extends Action {

public static ID = 'workbench.action.taskAction.terminateTask';
public static LABEL = nls.localize('terminateTaskAction', "Terminate task");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.terminate');
return TPromise.as(null);
}
}

export class BuildTaskAction extends Action {

public static ID = 'workbench.action.taskAction.build';
public static LABEL = nls.localize('buildTaskAction', "Build task");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.build');
return TPromise.as(null);
}
}

export class TestTaskAction extends Action {

public static ID = 'workbench.action.taskAction.test';
public static LABEL = nls.localize('testTaskAction', "Test task");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.test');
return TPromise.as(null);
}
}

export class ShowTaskLogAction extends Action {

public static ID = 'workbench.action.taskAction.showLog';
public static LABEL = nls.localize('showTaskLogAction', "Show task log");

constructor(
id: string,
label: string,
@ICommandService private commandService: ICommandService
) {
super(id, label);
}

public run(context?: any): TPromise<any> {
this.commandService.executeCommand('workbench.action.tasks.showLog');
return TPromise.as(null);
}
}

Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(RunTaskAction, RunTaskAction.ID, RunTaskAction.LABEL), 'Run Task');
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(RestartTaskAction, RestartTaskAction.ID, RestartTaskAction.LABEL), 'Restart Task');
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(TerminateTaskAction, TerminateTaskAction.ID, TerminateTaskAction.LABEL), 'Terminate Task');
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(BuildTaskAction, BuildTaskAction.ID, BuildTaskAction.LABEL), 'Build Task');
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(TestTaskAction, TestTaskAction.ID, TestTaskAction.LABEL), 'Test Task');
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions)
.registerWorkbenchAction(new SyncActionDescriptor(ShowTaskLogAction, ShowTaskLogAction.ID, ShowTaskLogAction.LABEL), 'Show Task Log');
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'vs/workbench/parts/tasks/browser/terminateQuickOpen';
import 'vs/workbench/parts/tasks/browser/restartQuickOpen';
import 'vs/workbench/parts/tasks/browser/buildQuickOpen';
import 'vs/workbench/parts/tasks/browser/testQuickOpen';
import 'vs/workbench/parts/tasks/common/taskActions';

import * as nls from 'vs/nls';

Expand Down