From 7780659822de5314578acad565e342c0a3b76c6f Mon Sep 17 00:00:00 2001 From: Arielk Date: Tue, 5 Feb 2019 15:29:23 +0200 Subject: Check if WF plugin is loaded Change-Id: Ia3538d66ace7d5e862625861c242aed68bf09f18 Issue-ID: SDC-2084 Signed-off-by: Arielk --- .../interface-operation.page.component.ts | 10 +++- .../operation-creator.component.html | 9 +-- .../operation-creator.component.ts | 67 ++++++++++++++-------- .../param-row/param-row.component.ts | 2 +- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts index b22a4bdc83..f04ccd9085 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/interface-operation.page.component.ts @@ -18,8 +18,9 @@ import {ModalButtonComponent} from "sdc-ui/lib/angular/components"; import {ComponentServiceNg2} from 'app/ng2/services/component-services/component.service'; import {ComponentGenericResponse} from 'app/ng2/services/responses/component-generic-response'; import {WorkflowServiceNg2} from 'app/ng2/services/workflow.service'; +import {PluginsService} from "app/ng2/services/plugins.service"; -import {OperationCreatorComponent, OperationCreatorInput} from './operation-creator/operation-creator.component'; +import {OperationCreatorComponent, OperationCreatorInput} from 'app/ng2/pages/interface-operation/operation-creator/operation-creator.component'; export class UIOperationModel extends OperationModel { isCollapsed: boolean = true; @@ -111,6 +112,7 @@ export class InterfaceOperationComponent { isLoading: boolean; interfaceTypes:{ [interfaceType: string]: Array }; modalTranslation: ModalTranslation; + workflowIsOnline: boolean; workflows: Array; @Input() component: IComponent; @@ -122,6 +124,7 @@ export class InterfaceOperationComponent { @Inject(SdcConfigToken) private sdcConfig: ISdcConfig, @Inject("$state") private $state: ng.ui.IStateService, private TranslateService: TranslateService, + private PluginsService: PluginsService, private ComponentServiceNg2: ComponentServiceNg2, private WorkflowServiceNg2: WorkflowServiceNg2, private ModalServiceNg2: ModalService, @@ -133,7 +136,8 @@ export class InterfaceOperationComponent { ngOnInit(): void { this.isLoading = true; - const workflowSubscription = this.enableWorkflowAssociation ? this.WorkflowServiceNg2.getWorkflows() : Promise.resolve(); + this.workflowIsOnline = !_.isUndefined(this.PluginsService.getPluginByStateUrl('workflowDesigner')); + const workflowSubscription = this.enableWorkflowAssociation && this.workflowIsOnline ? this.WorkflowServiceNg2.getWorkflows() : Promise.resolve(); Observable.forkJoin( this.ComponentServiceNg2.getInterfaces(this.component), this.ComponentServiceNg2.getComponentInputs(this.component), @@ -249,9 +253,9 @@ export class InterfaceOperationComponent { inputProperties: this.inputs, enableWorkflowAssociation: this.enableWorkflowAssociation, readonly: this.readonly, - isService: this.component.isService(), interfaceTypes: this.interfaceTypes, validityChangedCallback: this.enableOrDisableSaveButton, + workflowIsOnline: this.workflowIsOnline }; const modalConfig: IModalConfig = { diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html index 5848b585e9..7abc1a52c0 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/operation-creator.component.html @@ -84,8 +84,9 @@
+ [disabled]="readonly || !workflows.length || !workflowIsOnline">
, enableWorkflowAssociation: boolean, readonly: boolean, - isService: boolean, interfaceTypes: { [interfaceType: string]: Array }, validityChangedCallback: Function, + workflowIsOnline: boolean; } @Component({ @@ -49,7 +49,7 @@ export interface OperationCreatorInput { providers: [TranslateService] }) -export class OperationCreatorComponent { +export class OperationCreatorComponent implements OperationCreatorInput { input: OperationCreatorInput; inputOperation: OperationModel; @@ -81,6 +81,7 @@ export class OperationCreatorComponent { workflowAssociationType: string; enableWorkflowAssociation: boolean; + workflowIsOnline: boolean; isEditMode: boolean = false; isLoading: boolean = false; readonly: boolean; @@ -147,23 +148,27 @@ export class OperationCreatorComponent { []); if (this.enableWorkflowAssociation) { - this.workflows = _.map( - _.filter( - this.allWorkflows, - (workflow: any) => { - if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ACTIVE) { - return true; - } - if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ARCHIVED && - workflow.id === this.operation.workflowId) { - this.archivedWorkflowId = workflow.id; - return true; + if (this.workflowIsOnline) { + this.workflows = _.map( + _.filter( + this.allWorkflows, + (workflow: any) => { + if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ACTIVE) { + return true; + } + if (workflow.archiving === this.workflowServiceNg2.WF_STATE_ARCHIVED && + workflow.id === this.operation.workflowId) { + this.archivedWorkflowId = workflow.id; + return true; + } + return false; } - return false; - } - ), - (workflow: any) => new DropdownValue(workflow.id, workflow.name) - ); + ), + (workflow: any) => new DropdownValue(workflow.id, workflow.name) + ); + } else { + this.workflows = [new DropdownValue(this.operation.workflowId, this.operation.workflowId)]; + } } this.reconstructOperation(); this.validityChanged(); @@ -171,37 +176,47 @@ export class OperationCreatorComponent { } reconstructOperation = () => { + + const buildAndUpdate = () => { + this.buildParams(); + this.updateTable(); + }; + const inputOperation = this.inputOperation; if (inputOperation) { this.onSelectInterface(new DropDownOption(this.operation.interfaceType)); + if (this.enableWorkflowAssociation && inputOperation.workflowVersionId && this.isUsingExistingWF(inputOperation)) { this.assignInputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; this.assignOutputParameters[this.operation.workflowId] = {[inputOperation.workflowVersionId]: []}; this.inputParameters = this.assignInputParameters[this.operation.workflowId][this.operation.workflowVersionId]; this.outputParameters = this.assignOutputParameters[this.operation.workflowId][this.operation.workflowVersionId]; + const sub = this.onSelectWorkflow(new DropDownOption(inputOperation.workflowId), inputOperation.workflowVersionId); if (sub) { sub.add(() => { - this.buildParams(); - this.updateTable(); + buildAndUpdate(); this.operation.workflowVersionId = '-1'; - setTimeout(() => this.operation.workflowVersionId = this.inputOperation.workflowVersionId, 0); + setTimeout(() => this.operation.workflowVersionId = this.inputOperation.workflowVersionId); }); + } else { + buildAndUpdate(); } } else { this.inputParameters = this.noAssignInputParameters; this.outputParameters = this.noAssignOutputParameters; - this.buildParams(); - this.updateTable(); + buildAndUpdate(); } if (inputOperation.uniqueId) { this.isEditMode = true; } } + } buildParams = () => { + if (this.inputOperation.outputs) { this.currentTab = this.TYPE_OUTPUT; this.updateTable(); @@ -212,6 +227,7 @@ export class OperationCreatorComponent { } ); } + this.currentTab = this.TYPE_INPUT; this.updateTable(); if (this.inputOperation.inputs) { @@ -222,6 +238,7 @@ export class OperationCreatorComponent { } ); } + } isInterfaceOther(): boolean { @@ -275,7 +292,7 @@ export class OperationCreatorComponent { onSelectWorkflow(workflowId: DropDownOption, selectedVersionId?: string): Subscription { - if (_.isUndefined(workflowId)) { + if (_.isUndefined(workflowId) || !this.workflowIsOnline) { return; } this.operation.workflowId = workflowId.value; @@ -320,7 +337,7 @@ export class OperationCreatorComponent { changeWorkflowVersion(versionId: DropDownOption) { - if (_.isUndefined(versionId)) { + if (_.isUndefined(versionId) || !this.workflowIsOnline) { return; } diff --git a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts index bfa2b11b1c..1b51d721af 100644 --- a/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts +++ b/catalog-ui/src/app/ng2/pages/interface-operation/operation-creator/param-row/param-row.component.ts @@ -86,7 +86,7 @@ export class ParamRowComponent { const selProp = this.getSelectedProp(); if (selProp && selProp.type === this.param.type) { this.param.inputId = '-1'; - setTimeout(() => this.param.inputId = selProp.uniqueId || selProp.value, 0); + setTimeout(() => this.param.inputId = selProp.uniqueId || selProp.value); } else { this.param.inputId = null; } -- cgit 1.2.3-korg