} from '../../../services/component-services/topology-template.service';
import {TranslateService} from "../../../shared/translator/translate.service";
import {ModalService} from 'app/ng2/services/modal.service';
+import {CompositionService} from "app/ng2/pages/composition/composition.service";
import {ModalComponent} from 'app/ng2/components/ui/modal/modal.component';
import {Component as TopologyTemplate} from "../../../../models/components/component";
import {PluginsService} from "app/ng2/services/plugins.service";
import {SelectedComponentType} from "../common/store/graph.actions";
-
+import {InstanceFeDetails} from "../../../../models/instance-fe-details";
import {WorkspaceService} from "../../workspace/workspace.service";
import {
ComponentInterfaceDefinitionModel,
deploymentArtifactsFilePath: Array<DropdownValue> = [];
toscaArtifactTypes: Array<DropdownValue> = [];
+ componentInstanceMap: Map<string, InstanceFeDetails> = new Map<string, InstanceFeDetails>();
+ validImplementationProps: boolean = true;
@Input() component: ComponentInstance;
@Input() isViewOnly: boolean;
private topologyTemplateService: TopologyTemplateService,
private toscaArtifactService: ToscaArtifactService,
private modalServiceNg2: ModalService,
+ private compositionService: CompositionService,
private workspaceService: WorkspaceService,
@Inject("Notification") private Notification: any,
) {
).length === 0;
}
- private enableOrDisableSaveButton = (isValid): boolean => {
- return isValid;
+ private disableSaveButton = (): boolean => {
+ let disable:boolean = true;
+ if(this.isViewOnly) {
+ return disable;
+ }
+
+ let enableAddArtifactImplementation = this.modalInstance.instance.dynamicContent.instance.enableAddArtifactImplementation;
+ if(enableAddArtifactImplementation) {
+ const validImplementationProps = this.modalInstance.instance.dynamicContent.instance.validImplementationProps;
+ const toscaArtifactTypeSelected = this.modalInstance.instance.dynamicContent.instance.toscaArtifactTypeSelected;
+ const isToscaArtifactType:boolean = !(typeof toscaArtifactTypeSelected == 'undefined' || _.isEmpty(toscaArtifactTypeSelected));
+ disable = !isToscaArtifactType || !validImplementationProps;
+ return disable;
+ }
+ disable = false;
+ return disable;
}
onSelectInterfaceOperation(interfaceModel: UIInterfaceModel, operation: InterfaceOperationModel) {
buttonList.push(closeButton);
} else {
const saveButton: ButtonModel = new ButtonModel(this.modalTranslation.SAVE_BUTTON, 'blue', () =>
- this.updateInterfaceOperation(), this.enableOrDisableSaveButton);
+ this.updateInterfaceOperation(), this.disableSaveButton);
const cancelButton: ButtonModel = new ButtonModel(this.modalTranslation.CANCEL_BUTTON, 'outline white', this.cancelAndCloseModal);
buttonList.push(saveButton);
buttonList.push(cancelButton);
const modalModel: ModalModel = new ModalModel('l', this.modalTranslation.EDIT_TITLE, '', buttonList, 'custom');
this.modalInstance = this.modalServiceNg2.createCustomModal(modalModel);
+ const componentInstances = this.compositionService.getComponentInstances()
+ if (componentInstances) {
+ componentInstances.forEach(value => {
+ this.componentInstanceMap.set(value.uniqueId, <InstanceFeDetails>{
+ name: value.name
+ });
+ });
+ }
+
this.modalServiceNg2.addDynamicContentToModal(
this.modalInstance,
InterfaceOperationHandlerComponent,
{
deploymentArtifactsFilePath: this.deploymentArtifactsFilePath,
+ componentInstanceMap: this.componentInstanceMap,
toscaArtifactTypes: this.toscaArtifactTypes,
selectedInterface: interfaceModel ? interfaceModel : new UIInterfaceModel(),
selectedInterfaceOperation: operation ? operation : new InterfaceOperationModel(),
- validityChangedCallback: this.enableOrDisableSaveButton,
+ validityChangedCallback: this.disableSaveButton,
isViewOnly: this.isViewOnly,
+ validImplementationProps: this.validImplementationProps,
isEdit: true,
modelName: this.componentMetaData.model
}
this.modalServiceNg2.currentModal.instance.dynamicContent.instance.isLoading = true;
const interfaceOperationHandlerComponentInstance: InterfaceOperationHandlerComponent = this.modalInstance.instance.dynamicContent.instance;
const operationUpdated: InterfaceOperationModel = interfaceOperationHandlerComponentInstance.operationToUpdate;
+ let timeout = null;
+ if (operationUpdated.implementation && operationUpdated.implementation.timeout != null) {
+ timeout = operationUpdated.implementation.timeout;
+ }
const isArtifactChecked = interfaceOperationHandlerComponentInstance.enableAddArtifactImplementation;
if (!isArtifactChecked) {
let artifactName = interfaceOperationHandlerComponentInstance.artifactName;
artifactName = artifactName === undefined ? '' : artifactName;
operationUpdated.implementation = new ArtifactModel({'artifactName': artifactName, 'artifactVersion': ''} as ArtifactModel);
}
+ if (timeout != null) {
+ operationUpdated.implementation.timeout = timeout;
+ }
this.topologyTemplateService.updateComponentInstanceInterfaceOperation(
this.componentMetaData.uniqueId,
this.componentMetaData.componentType,