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 {connect} from 'react-redux';
24 import React, {Component} from 'react';
25 import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx';
26 import {postAnalyticsData} from 'app/analytics/AnalyticsActions.js';
27 import {getClearGlobalMessageEvent} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
30 clearSuggestionsTextField,
32 onSuggestionsClearRequested,
33 getInvalidSearchInputEvent,
35 } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js';
37 let mapActionToProps = (dispatch) => {
39 onSuggestionsFetchRequested: ({value}) => dispatch(
40 queryRequestedValues(value)),
41 onClearSuggestionsTextFieldRequested: () => {
42 dispatch(getClearGlobalMessageEvent());
43 dispatch(clearSuggestionsTextField());
45 onInputChange: (event, {newValue}) => {
46 dispatch(getClearGlobalMessageEvent());
47 dispatch(onSuggestionsChange(event, newValue));
49 onSuggestionsClearRequested: () => dispatch(onSuggestionsClearRequested()),
50 dispatchAnalytics: () => dispatch(
51 postAnalyticsData(document.documentElement.outerHTML.replace('\s+', ''))),
52 onInvalidSearch: (searchText) => {
53 dispatch(getInvalidSearchInputEvent(searchText));
55 onMessageStateChange: (msgText, msgSeverity) => {
56 dispatch(setNotificationText(msgText, msgSeverity));
61 let mapStateToProps = ({globalAutoCompleteSearchBarReducer}) => {
65 cachedSuggestions = [],
66 suggestionName = 'text',
67 clearSearchText = false,
69 feedbackMsgSeverity = ''
70 } = globalAutoCompleteSearchBarReducer;
83 export class GlobalAutoCompleteSearchBar extends Component {
84 componentWillReceiveProps(nextProps) {
85 if (nextProps.clearSearchText) {
86 this.props.onClearSuggestionsTextFieldRequested();
89 if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) {
90 this.props.onMessageStateChange(nextProps.feedbackMsgText,
91 nextProps.feedbackMsgSeverity);
97 <AutoCompleteSearchBar {...this.props} />
101 export default connect(mapStateToProps, mapActionToProps)(
102 GlobalAutoCompleteSearchBar);