From b376f367334c6c14dd5c4029e24902cbb269f1a2 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Tue, 16 Apr 2019 13:07:22 -0700 Subject: [PATCH] fix job action context (#5053) --- .../jobManagement/views/jobManagementView.ts | 6 +++-- .../jobManagement/common/jobActions.ts | 24 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/sql/parts/jobManagement/views/jobManagementView.ts b/src/sql/parts/jobManagement/views/jobManagementView.ts index 9f5ef428c6..efb7bd2de4 100644 --- a/src/sql/parts/jobManagement/views/jobManagementView.ts +++ b/src/sql/parts/jobManagement/views/jobManagementView.ts @@ -14,7 +14,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Taskbar } from '../../../base/browser/ui/taskbar/taskbar'; -import { JobsRefreshAction } from 'sql/platform/jobManagement/common/jobActions'; +import { JobsRefreshAction, IJobActionInfo } from 'sql/platform/jobManagement/common/jobActions'; import { TabChild } from 'sql/base/browser/ui/panel/tab.component'; import { IDashboardService } from 'sql/platform/dashboard/browser/dashboardService'; @@ -82,6 +82,7 @@ export abstract class JobManagementView extends TabChild implements AfterContent let actionContext = { ownerUri: ownerUri, targetObject: targetObject + }; let anchor = { x: event.pageX + 1, y: event.pageY }; @@ -116,7 +117,8 @@ export abstract class JobManagementView extends TabChild implements AfterContent { action: refreshAction }, { action: newAction } ]); - this._actionBar.context = { component: this }; + let context: IJobActionInfo = { component: this }; + this._actionBar.context = context; } public refreshJobs() { diff --git a/src/sql/platform/jobManagement/common/jobActions.ts b/src/sql/platform/jobManagement/common/jobActions.ts index 77fba9ca17..bd3febcb98 100644 --- a/src/sql/platform/jobManagement/common/jobActions.ts +++ b/src/sql/platform/jobManagement/common/jobActions.ts @@ -30,8 +30,8 @@ export enum JobActions { } export class IJobActionInfo { - ownerUri: string; - targetObject: any; + ownerUri?: string; + targetObject?: any; component: JobManagementView; } @@ -69,10 +69,11 @@ export class NewJobAction extends Action { super(NewJobAction.ID, NewJobAction.LABEL, 'newStepIcon'); } - public run(context: JobsViewComponent): Promise { + public run(context: IJobActionInfo): Promise { + let component = context.component as JobsViewComponent; return new Promise(async (resolve, reject) => { try { - await context.openCreateJobDialog(); + await component.openCreateJobDialog(); resolve(true); } catch (e) { reject(e); @@ -293,10 +294,11 @@ export class NewAlertAction extends Action { super(NewAlertAction.ID, NewAlertAction.LABEL, 'newStepIcon'); } - public run(context: AlertsViewComponent): Promise { + public run(context: IJobActionInfo): Promise { + let component = context.component as AlertsViewComponent; return new Promise((resolve, reject) => { try { - context.openCreateAlertDialog(); + component.openCreateAlertDialog(); resolve(true); } catch (e) { reject(e); @@ -380,10 +382,11 @@ export class NewOperatorAction extends Action { super(NewOperatorAction.ID, NewOperatorAction.LABEL, 'newStepIcon'); } - public run(context: OperatorsViewComponent): Promise { + public run(context: IJobActionInfo): Promise { + let component = context.component as OperatorsViewComponent; return new Promise((resolve, reject) => { try { - context.openCreateOperatorDialog(); + component.openCreateOperatorDialog(); resolve(true); } catch (e) { reject(e); @@ -466,10 +469,11 @@ export class NewProxyAction extends Action { super(NewProxyAction.ID, NewProxyAction.LABEL, 'newStepIcon'); } - public run(context: ProxiesViewComponent): Promise { + public run(context: IJobActionInfo): Promise { + let component = context.component as ProxiesViewComponent; return new Promise((resolve, reject) => { try { - context.openCreateProxyDialog(); + component.openCreateProxyDialog(); resolve(true); } catch (e) { reject(e);