2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
25 import React, {Component} from 'react';
26 import {connect} from 'react-redux';
30 DEFAULT_VNFS_SEARCH_HASH
31 } from 'app/vnfSearch/VnfSearchConstants.js';
33 processTotalVnfVisualizationOnSearchChange,
34 processOrchStatusVisualizationOnSearchChange,
35 processProvStatusVisualizationOnSearchChange,
37 } from 'app/vnfSearch/VnfSearchActions.js';
38 import VnfSearchOrchStatusVisualizations from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx';
39 import VnfSearchProvStatusVisualizations from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx';
40 import VnfSearchTotalCountVisualization from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx';
41 import i18n from 'utils/i18n/i18n';
42 import {changeUrlAddress, buildRouteObj} from 'utils/Routes.js';
44 const mapStateToProps = ({vnfSearch}) => {
47 feedbackMsgSeverity = ''
56 let mapActionToProps = (dispatch) => {
58 onReceiveNewParams: (vnfParam) => {
59 dispatch(processTotalVnfVisualizationOnSearchChange(vnfParam));
60 dispatch(processOrchStatusVisualizationOnSearchChange(vnfParam));
61 dispatch(processProvStatusVisualizationOnSearchChange(vnfParam));
63 onMessageStateChange: (msgText, msgSeverity) => {
64 dispatch(setNotificationText(msgText, msgSeverity));
69 class vnfSearch extends Component {
70 componentWillMount() {
71 if (this.props.match &&
72 this.props.match.params &&
73 this.props.match.params.vnfParam) {
74 this.props.onReceiveNewParams(this.props.match.params.vnfParam);
76 // render using default search params (hash for "VNFs")
77 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
78 changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH),
82 if (this.props.feedbackMsgText) {
83 this.props.onMessageStateChange(this.props.feedbackMsgText,
84 this.props.feedbackMsgSeverity);
88 componentWillReceiveProps(nextProps) {
89 if (nextProps.match.params.vnfParam) {
90 if (nextProps.match.params.vnfParam !==
91 this.props.match.params.vnfParam) {
92 this.props.onReceiveNewParams(nextProps.match.params.vnfParam);
94 } else if (this.props.match.params.vnfParam) {
95 // currently on VNF page and somebody has clicked the VNF NavLink
96 // want to reload the view with the default params (hash for "NFVs")
97 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
98 changeUrlAddress(buildRouteObj(VNFS_ROUTE, DEFAULT_VNFS_SEARCH_HASH),
102 if (nextProps.feedbackMsgText &&
103 nextProps.feedbackMsgText !==
104 this.props.feedbackMsgText) {
105 this.props.onMessageStateChange(nextProps.feedbackMsgText,
106 nextProps.feedbackMsgSeverity);
110 componentWillUnmount() {
111 // resetting to default params so on relaunch there will be no
112 // visibility of old searches
113 this.props.onReceiveNewParams(DEFAULT_VNFS_SEARCH_HASH);
119 <div className='secondary-header'>
120 <span className='secondary-title'>{i18n(VNF_TITLE)}</span>
122 <VnfSearchTotalCountVisualization />
123 <VnfSearchProvStatusVisualizations />
124 <VnfSearchOrchStatusVisualizations />
129 export default connect(mapStateToProps, mapActionToProps)(vnfSearch);