Disable edit step until all steps are loaded (#4327)

* disable edit step until all steps are loaded

* job check
This commit is contained in:
Aditya Bist
2019-03-07 12:58:58 -08:00
committed by GitHub
parent e16c01623d
commit c8bde41451
2 changed files with 38 additions and 24 deletions

View File

@@ -3,13 +3,13 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata';
import { ElementRef, AfterContentChecked, ViewChild } from '@angular/core'; import { ElementRef, AfterContentChecked, ViewChild } from '@angular/core';
import { Table } from 'sql/base/browser/ui/table/table'; import { Table } from 'sql/base/browser/ui/table/table';
import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component'; import { AgentViewComponent } from 'sql/parts/jobManagement/agent/agentView.component';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { IAction, Action } from 'vs/base/common/actions'; import { IAction, Action } from 'vs/base/common/actions';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { TPromise } from 'vs/base/common/winjs.base';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -75,7 +75,7 @@ export abstract class JobManagementView extends TabChild implements AfterContent
let rowIndex = event.cell.row; let rowIndex = event.cell.row;
let targetObject = this.getCurrentTableObject(rowIndex); let targetObject = this.getCurrentTableObject(rowIndex);
let actions = this.getTableActions(); let actions = this.getTableActions(targetObject);
if (actions) { if (actions) {
let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri; let ownerUri: string = this._commonService.connectionManagementService.connectionInfo.ownerUri;
let actionContext = { let actionContext = {
@@ -98,11 +98,11 @@ export abstract class JobManagementView extends TabChild implements AfterContent
return kb; return kb;
} }
protected getTableActions(): IAction[] { protected getTableActions(targetObject?: any): IAction[] {
return undefined; return undefined;
} }
protected getCurrentTableObject(rowIndex: number): any { protected getCurrentTableObject(rowIndex: number): JobActionContext {
return undefined; return undefined;
} }
@@ -118,3 +118,8 @@ export abstract class JobManagementView extends TabChild implements AfterContent
]); ]);
} }
} }
export interface JobActionContext {
canEdit: boolean;
job: azdata.AgentJobInfo;
}

View File

@@ -25,7 +25,7 @@ import { EditJobAction, DeleteJobAction, NewJobAction } from 'sql/platform/jobMa
import { JobManagementUtilities } from 'sql/platform/jobManagement/common/jobManagementUtilities'; import { JobManagementUtilities } from 'sql/platform/jobManagement/common/jobManagementUtilities';
import { HeaderFilter } from 'sql/base/browser/ui/table/plugins/headerFilter.plugin'; import { HeaderFilter } from 'sql/base/browser/ui/table/plugins/headerFilter.plugin';
import { IJobManagementService } from 'sql/platform/jobManagement/common/interfaces'; import { IJobManagementService } from 'sql/platform/jobManagement/common/interfaces';
import { JobManagementView } from 'sql/parts/jobManagement/views/jobManagementView'; import { JobManagementView, JobActionContext } from 'sql/parts/jobManagement/views/jobManagementView';
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service'; import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommandService } from 'vs/platform/commands/common/commands';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
@@ -193,7 +193,6 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
self._agentViewComponent.agentJobInfo = job; self._agentViewComponent.agentJobInfo = job;
self._agentViewComponent.showHistory = true; self._agentViewComponent.showHistory = true;
}); });
this._register(this._table.onContextMenu(e => { this._register(this._table.onContextMenu(e => {
self.openContextMenu(e); self.openContextMenu(e);
})); }));
@@ -859,9 +858,13 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
}); });
} }
protected getTableActions(): IAction[] { protected getTableActions(targetObject: JobActionContext): IAction[] {
let actions: IAction[] = []; let actions: IAction[] = [];
actions.push(this._instantiationService.createInstance(EditJobAction)); let editAction = this._instantiationService.createInstance(EditJobAction);
if (!targetObject.canEdit) {
editAction.enabled = false;
}
actions.push(editAction);
actions.push(this._instantiationService.createInstance(DeleteJobAction)); actions.push(this._instantiationService.createInstance(DeleteJobAction));
return actions; return actions;
} }
@@ -900,7 +903,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
return result; return result;
} }
protected getCurrentTableObject(rowIndex: number): any { protected getCurrentTableObject(rowIndex: number): JobActionContext {
let data = this._table.grid.getData(); let data = this._table.grid.getData();
if (!data || rowIndex >= data.getLength()) { if (!data || rowIndex >= data.getLength()) {
return undefined; return undefined;
@@ -920,24 +923,30 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
return job.jobId === jobId; return job.jobId === jobId;
}); });
// add steps if (job && job.length > 0) {
if (this.jobSteps && this.jobSteps[jobId]) { // add steps
let steps = this.jobSteps[jobId]; if (this.jobSteps && this.jobSteps[jobId]) {
job[0].jobSteps = steps; let steps = this.jobSteps[jobId];
} job[0].jobSteps = steps;
}
// add schedules // add schedules
if (this.jobSchedules && this.jobSchedules[jobId]) { if (this.jobSchedules && this.jobSchedules[jobId]) {
let schedules = this.jobSchedules[jobId]; let schedules = this.jobSchedules[jobId];
job[0].jobSchedules = schedules; job[0].jobSchedules = schedules;
} }
// add alerts
if (this.jobAlerts && this.jobAlerts[jobId]) {
let alerts = this.jobAlerts[jobId];
job[0].alerts = alerts;
}
// add alerts if (job[0].jobSteps && job[0].jobSchedules && job[0].alerts) {
if (this.jobAlerts && this.jobAlerts[jobId]) { return { job: job[0], canEdit: true };
let alerts = this.jobAlerts[jobId]; }
job[0].alerts = alerts; return { job: job[0], canEdit: false };
} }
return job && job.length > 0 ? job[0] : undefined; return undefined;
} }
public openCreateJobDialog() { public openCreateJobDialog() {