2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 import React from 'react';
25 import NodeVisualElementConstants from './NodeVisualElementConstants.js';
26 import NodeVisualElementFactory from './NodeVisualElementFactory.js';
32 this.visualElementFactory = new NodeVisualElementFactory();
34 this.setNodeMeta = this.setNodeMeta.bind(this);
37 setNodeMeta(metaObject) {
38 this.graphMeta = metaObject;
39 this.visualElementFactory.setVisualElementMeta(metaObject);
41 // hideButton a temporary solution to not display the button.
42 buildNode(nodeType, nodeProps, hideButton) {
44 let translate = `translate(
45 ${nodeProps.renderProps.x},
46 ${nodeProps.renderProps.y})`;
48 ...nodeProps.renderProps,
49 className: this.graphMeta.aaiEntityNodeDescriptors[nodeType].class,
53 let nodeVisualElementsData = this.extractVisualElementArrayFromMeta(
54 nodeType, hideButton);
55 let nodeVisualElements = undefined;
56 if (nodeVisualElementsData) {
57 nodeVisualElements = [];
58 nodeVisualElementsData.map((elementData, index) => {
59 if (elementData.type === NodeVisualElementConstants.BUTTON) {
60 if (nodeProps.buttons) {
61 let isButtonSelected = false;
63 isButtonSelected = nodeProps.buttons[0];
66 isButtonSelected = nodeProps.buttons[1];
70 isSelected: isButtonSelected
74 nodeVisualElements.push(
75 this.visualElementFactory.buildVisualElement(nodeProps.meta,
76 elementData.type, elementData, index));
78 //Draw overlay only if the node is validated
79 if (nodeProps.meta.nodeMeta.nodeValidated) {
81 if (nodeProps.meta.nodeMeta.nodeIssue) {
82 let warningOverlayProps = {
83 name: NodeVisualElementConstants.ICON_WARNING,
85 nodeVisualElements.push(
86 this.visualElementFactory.buildVisualElement(nodeProps,
87 NodeVisualElementConstants.ICON, warningOverlayProps,
88 nodeVisualElementsData.length + 1));
90 let tickOverlayProps = {
91 name: NodeVisualElementConstants.ICON_TICK,
93 nodeVisualElements.push(
94 this.visualElementFactory.buildVisualElement(nodeProps,
95 NodeVisualElementConstants.ICON, tickOverlayProps,
96 nodeVisualElementsData.length + 1));
101 if (nodeVisualElements) {
102 return React.createElement('g', finalProps, nodeVisualElements);
105 return React.createElement('g', finalProps);
108 extractVisualElementArrayFromMeta(nodeClassName, hideButton) {
109 let nodeVisualElements = undefined;
110 if (this.graphMeta.aaiEntityNodeDescriptors) {
112 this.graphMeta.aaiEntityNodeDescriptors[nodeClassName].visualElements;
114 // temp, until BE not sent the triangle button
115 for (var i = 0; i < nodeVisualElements.length; i++) {
116 if (nodeVisualElements[i].type === 'button' && nodeVisualElements[i].name === 'icon_triangle_warning') {
117 nodeVisualElements.splice(i, 1);
123 return nodeVisualElements;
127 export default NodeFactory;