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.
24 import React, {Component} from 'react';
25 import {connect} from 'react-redux';
26 import SplitPane from 'react-split-pane';
28 import {setSecondaryTitle} from 'app/MainScreenWrapperActionHelper.js';
29 import ForceDirectedGraph from 'generic-components/graph/ForceDirectedGraph.jsx';
30 import SelectedNodeDetails from 'app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx';
33 import overlaysDetails from 'resources/overlays/overlaysDetails.json';
34 import * as Overlays from 'app/overlays/OverlayImports.js';
36 import i18n from 'utils/i18n/i18n';
41 querySelectedNodeElement,
44 } from 'app/tierSupport/TierSupportActions.js';
47 TSUI_NODE_DETAILS_INITIAL_WIDTH,
48 TSUI_NODE_DETAILS_MIN_WIDTH,
49 TSUI_GRAPH_MENU_NODE_DETAILS,
50 } from './TierSupportConstants.js';
52 let mapStateToProps = (
57 globalAutoCompleteSearchBar
62 forceDirectedGraphRawData = {
69 graphNodeSelectedMenu = TSUI_GRAPH_MENU_NODE_DETAILS,
71 feedbackMsgSeverity = '',
73 } = tierSupportReducer;
76 performPrepareVisualization = false,
77 selectedSuggestion = {}
78 } = globalAutoCompleteSearchBar;
80 forceDirectedGraphRawData,
83 graphNodeSelectedMenu,
84 performPrepareVisualization,
92 let mapActionToProps = (dispatch) => {
94 onSetViewTitle: (title) => {
95 dispatch(setSecondaryTitle(title));
97 onNodeSelected: (requestObject) => {
98 dispatch(onNodeDetailsChange(requestObject));
100 onNodeMenuSelect: (selectedMenu) => {
101 dispatch(onNodeMenuChange(selectedMenu.buttonId));
103 onSplitPaneResize: (initialLoad) => {
104 dispatch(splitPaneResize(initialLoad));
106 onNewVIParam: (param) => {
107 dispatch(querySelectedNodeElement(param));
109 onMessageStateChange: (msgText, msgSeverity) => {
110 dispatch(setNotificationText(msgText, msgSeverity));
112 onRequestClearData: () => {
113 dispatch(clearVIData());
118 class TierSupport extends Component {
120 forceDirectedGraphRawData: React.PropTypes.object,
121 windowWidth: React.PropTypes.number,
122 windowHeight: React.PropTypes.number,
123 graphNodeSelectedMenu: React.PropTypes.string,
124 feedbackMsgText: React.PropTypes.string,
125 feedbackMsgSeverity: React.PropTypes.string,
126 nodeData: React.PropTypes.object
129 componentWillReceiveProps(nextProps) {
130 if (nextProps.match.params.viParam &&
131 nextProps.match.params.viParam !==
132 this.props.match.params.viParam) {
133 this.props.onNewVIParam(nextProps.match.params.viParam);
135 if(nextProps.match.params.viParam && nextProps.match.params.viParam !==
136 this.props.match.params.viParam) {
137 this.props.onRequestClearData();
140 if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) {
141 this.props.onMessageStateChange(nextProps.feedbackMsgText,
142 nextProps.feedbackMsgSeverity);
146 componentWillMount() {
147 this.props.onSetViewTitle(i18n(TSUI_TITLE));
148 if (this.props.match.params.viParam) {
149 this.props.onNewVIParam(this.props.match.params.viParam);
151 this.props.onRequestClearData();
155 componentDidMount() {
156 this.props.onSplitPaneResize(true);
159 componentWillUnmount() {
160 // resetting to default (empty screen)
161 this.props.onRequestClearData();
167 forceDirectedGraphRawData,
176 let availableOverlay;
177 let overlayComponent;
178 // Currently only ONE overlay can be added to each view.
179 // todo: need to make it array if more than one overlay can be used. No need now.
180 overlaysDetails.forEach(function(overlay){
181 if(overlay.view === 'schema') {
182 availableOverlay = overlay.key;
183 overlayComponent = overlay.componentName;
187 //Temp code for a demo, will be removed as Vis library is updated
188 let currentNodeButton;
189 if(this.props.graphNodeSelectedMenu ===
190 TSUI_GRAPH_MENU_NODE_DETAILS ) {
191 currentNodeButton = 'NODE_DETAILS';
192 } else if(availableOverlay) {
193 currentNodeButton = availableOverlay;
196 let dataOverlayButtons = ['NODE_DETAILS'];
197 if(availableOverlay) {
198 dataOverlayButtons.push(availableOverlay);
200 let currentSelectedMenu = this.getCurrentSelectedMenu(overlayComponent);
202 <div className='tier-support-ui'>
205 enableResizing='true'
206 onDragFinished={ () => {
207 onSplitPaneResize(false);
209 defaultSize={TSUI_NODE_DETAILS_INITIAL_WIDTH}
210 minSize={TSUI_NODE_DETAILS_MIN_WIDTH}
215 viewWidth={windowWidth}
216 viewHeight={windowHeight}
217 graphData={forceDirectedGraphRawData}
218 nodeSelectedCallback={(nodeData) => {
219 onNodeSelected(nodeData);
221 nodeButtonSelectedCallback={(selectedMenuId) => {
222 onNodeMenuSelect(selectedMenuId);
224 dataOverlayButtons={dataOverlayButtons}
225 currentlySelectedNodeView={currentNodeButton}/>
229 {currentSelectedMenu}
237 for(var prop in obj) {
238 if(obj.hasOwnProperty(prop)) {
245 getCurrentSelectedMenu(overlayComponent) {
247 if (this.props.graphNodeSelectedMenu === TSUI_GRAPH_MENU_NODE_DETAILS) {
248 if (!this.nodeDetails) {
249 this.nodeDetails = <SelectedNodeDetails/>;
251 return this.nodeDetails;
254 if (this.isNotEmpty(this.props.nodeData) && overlayComponent) {
255 if (Overlays.default.hasOwnProperty(overlayComponent)) {
256 let OverlayComponent = Overlays.default[overlayComponent];
257 secondOverlay = <OverlayComponent nodeDetails={this.props.nodeData}/>;
260 return secondOverlay;
266 export default connect(mapStateToProps, mapActionToProps)(TierSupport);