Move Tasks Panel (#5162)

* moving tasks panel

* fix css styling

* clean up code

* do a bunch of renaming
This commit is contained in:
Anthony Dresser
2019-04-24 13:54:58 -07:00
committed by GitHub
parent 51145903aa
commit 9e804089e0
22 changed files with 204 additions and 256 deletions

View File

@@ -0,0 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/**
* Tasks panel id
*/
export const TASKS_PANEL_ID = 'workbench.panel.tasks';

View File

@@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { Action } from 'vs/base/common/actions';
import { ITaskService } from 'sql/platform/tasks/common/tasksService';
import { TaskNode } from 'sql/platform/tasks/common/tasksNode';
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
import Severity from 'vs/base/common/severity';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
export class CancelAction extends Action {
public static ID = 'taskHistory.cancel';
public static LABEL = localize('cancelTask.cancel', 'Cancel');
constructor(
id: string,
label: string,
@ITaskService private _taskService: ITaskService,
@IErrorMessageService private _errorMessageService: IErrorMessageService
) {
super(id, label);
}
public run(element: TaskNode): Promise<boolean> {
if (element instanceof TaskNode) {
this._taskService.cancelTask(element.providerName, element.id).then((result) => {
if (!result) {
let error = localize('errorMsgFromCancelTask', 'The task is failed to cancel.');
this.showError(error);
}
}, error => {
this.showError(error);
return Promise.resolve(true);
});
}
return Promise.resolve(true);
}
private showError(errorMessage: string) {
if (this._errorMessageService) {
this._errorMessageService.showDialog(Severity.Error, '', errorMessage);
}
}
}
export class ScriptAction extends Action {
public static ID = 'taskHistory.script';
public static LABEL = localize('taskAction.script', 'Script');
constructor(
id: string,
label: string,
@IQueryEditorService private _queryEditorService: IQueryEditorService
) {
super(id, label);
}
public run(element: TaskNode): Promise<boolean> {
if (element instanceof TaskNode) {
if (element.script && element.script !== '') {
this._queryEditorService.newSqlEditor(element.script);
}
}
return Promise.resolve(true);
}
}