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, {Component} from 'react';
24 import {connect} from 'react-redux';
28 DEFAULT_VNFS_SEARCH_HASH
29 } from 'app/vnfSearch/VnfSearchConstants.js';
31 processTotalVnfVisualizationOnSearchChange,
32 processOrchStatusVisualizationOnSearchChange,
33 processProvStatusVisualizationOnSearchChange,
35 } from 'app/vnfSearch/VnfSearchActions.js';
36 import VnfSearchOrchStatusVisualizations from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx';
37 import VnfSearchProvStatusVisualizations from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx';
38 import VnfSearchTotalCountVisualization from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx';
39 import i18n from 'utils/i18n/i18n';
40 import {changeUrlAddress, buildRouteObj} from 'utils/Routes.js';
42 const mapStateToProps = ({vnfSearch}) => {
45 feedbackMsgSeverity = ''
54 let mapActionToProps = (dispatch) => {
56 onReceiveNewParams: (vnfParam) => {
57 dispatch(processTotalVnfVisualizationOnSearchChange(vnfParam));
58 dispatch(processOrchStatusVisualizationOnSearchChange(vnfParam));
59 dispatch(processProvStatusVisualizationOnSearchChange(vnfParam));
61 onMessageStateChange: (msgText, msgSeverity) => {
62 dispatch(setNotificationText(msgText, msgSeverity));
67 class vnfSearch extends Component {
68 componentWillMount() {
69 if (this.props.match &&
70 this.props.match.params &&
71 this.props.match.params.vnfParam) {
72 this.props.onReceiveNewParams(this.props.match.params.vnfParam);
74 // render using default search params (hash for "VNFs")
75 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
76 changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH),
80 if (this.props.feedbackMsgText) {
81 this.props.onMessageStateChange(this.props.feedbackMsgText,
82 this.props.feedbackMsgSeverity);
86 componentWillReceiveProps(nextProps) {
87 if (nextProps.match.params.vnfParam) {
88 if (nextProps.match.params.vnfParam !==
89 this.props.match.params.vnfParam) {
90 this.props.onReceiveNewParams(nextProps.match.params.vnfParam);
92 } else if (this.props.match.params.vnfParam) {
93 // currently on VNF page and somebody has clicked the VNF NavLink
94 // want to reload the view with the default params (hash for "NFVs")
95 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
96 changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH),
100 if (nextProps.feedbackMsgText &&
101 nextProps.feedbackMsgText !==
102 this.props.feedbackMsgText) {
103 this.props.onMessageStateChange(nextProps.feedbackMsgText,
104 nextProps.feedbackMsgSeverity);
108 componentWillUnmount() {
109 // resetting to default params so on relaunch there will be no
110 // visibility of old searches
111 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
117 <div className='secondary-header'>
118 <span className='secondary-title'>{i18n(VNF_TITLE)}</span>
120 <VnfSearchTotalCountVisualization />
121 <VnfSearchProvStatusVisualizations />
122 <VnfSearchOrchStatusVisualizations />
127 export default connect(mapStateToProps, mapActionToProps)(vnfSearch);