fix job action context (#5053)

This commit is contained in:
Aditya Bist
2019-04-16 13:07:22 -07:00
committed by Karl Burtram
parent a21244816d
commit b2952d2ddf
2 changed files with 17 additions and 11 deletions

View File

@@ -82,6 +82,7 @@ export abstract class JobManagementView extends TabChild implements AfterContent
let actionContext = { let actionContext = {
ownerUri: ownerUri, ownerUri: ownerUri,
targetObject: targetObject targetObject: targetObject
}; };
let anchor = { x: event.pageX + 1, y: event.pageY }; let anchor = { x: event.pageX + 1, y: event.pageY };
@@ -116,7 +117,8 @@ export abstract class JobManagementView extends TabChild implements AfterContent
{ action: refreshAction }, { action: refreshAction },
{ action: newAction } { action: newAction }
]); ]);
this._actionBar.context = { component: this }; let context: IJobActionInfo = { component: this };
this._actionBar.context = context;
} }
public refreshJobs() { public refreshJobs() {

View File

@@ -30,8 +30,8 @@ export enum JobActions {
} }
export class IJobActionInfo { export class IJobActionInfo {
ownerUri: string; ownerUri?: string;
targetObject: any; targetObject?: any;
component: JobManagementView; component: JobManagementView;
} }
@@ -69,10 +69,11 @@ export class NewJobAction extends Action {
super(NewJobAction.ID, NewJobAction.LABEL, 'newStepIcon'); super(NewJobAction.ID, NewJobAction.LABEL, 'newStepIcon');
} }
public run(context: JobsViewComponent): Promise<boolean> { public run(context: IJobActionInfo): Promise<boolean> {
let component = context.component as JobsViewComponent;
return new Promise<boolean>(async (resolve, reject) => { return new Promise<boolean>(async (resolve, reject) => {
try { try {
await context.openCreateJobDialog(); await component.openCreateJobDialog();
resolve(true); resolve(true);
} catch (e) { } catch (e) {
reject(e); reject(e);
@@ -293,10 +294,11 @@ export class NewAlertAction extends Action {
super(NewAlertAction.ID, NewAlertAction.LABEL, 'newStepIcon'); super(NewAlertAction.ID, NewAlertAction.LABEL, 'newStepIcon');
} }
public run(context: AlertsViewComponent): Promise<boolean> { public run(context: IJobActionInfo): Promise<boolean> {
let component = context.component as AlertsViewComponent;
return new Promise<boolean>((resolve, reject) => { return new Promise<boolean>((resolve, reject) => {
try { try {
context.openCreateAlertDialog(); component.openCreateAlertDialog();
resolve(true); resolve(true);
} catch (e) { } catch (e) {
reject(e); reject(e);
@@ -380,10 +382,11 @@ export class NewOperatorAction extends Action {
super(NewOperatorAction.ID, NewOperatorAction.LABEL, 'newStepIcon'); super(NewOperatorAction.ID, NewOperatorAction.LABEL, 'newStepIcon');
} }
public run(context: OperatorsViewComponent): Promise<boolean> { public run(context: IJobActionInfo): Promise<boolean> {
let component = context.component as OperatorsViewComponent;
return new Promise<boolean>((resolve, reject) => { return new Promise<boolean>((resolve, reject) => {
try { try {
context.openCreateOperatorDialog(); component.openCreateOperatorDialog();
resolve(true); resolve(true);
} catch (e) { } catch (e) {
reject(e); reject(e);
@@ -466,10 +469,11 @@ export class NewProxyAction extends Action {
super(NewProxyAction.ID, NewProxyAction.LABEL, 'newStepIcon'); super(NewProxyAction.ID, NewProxyAction.LABEL, 'newStepIcon');
} }
public run(context: ProxiesViewComponent): Promise<boolean> { public run(context: IJobActionInfo): Promise<boolean> {
let component = context.component as ProxiesViewComponent;
return new Promise<boolean>((resolve, reject) => { return new Promise<boolean>((resolve, reject) => {
try { try {
context.openCreateProxyDialog(); component.openCreateProxyDialog();
resolve(true); resolve(true);
} catch (e) { } catch (e) {
reject(e); reject(e);