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.
26 import {connect} from 'react-redux';
27 import React, {Component} from 'react';
28 import AutoCompleteSearchBar from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx';
29 import {postAnalyticsData} from 'app/analytics/AnalyticsActions.js';
30 import {getClearGlobalMessageEvent} from 'app/GlobalInlineMessageBar/GlobalInlineMessageBarActions.js';
33 clearSuggestionsTextField,
35 onSuggestionsClearRequested,
36 getInvalidSearchInputEvent,
38 } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js';
40 let mapActionToProps = (dispatch) => {
42 onSuggestionsFetchRequested: ({value}) => dispatch(
43 queryRequestedValues(value)),
44 onClearSuggestionsTextFieldRequested: () => {
45 dispatch(getClearGlobalMessageEvent());
46 dispatch(clearSuggestionsTextField());
48 onInputChange: (event, {newValue}) => {
49 dispatch(getClearGlobalMessageEvent());
50 dispatch(onSuggestionsChange(event, newValue));
52 onSuggestionsClearRequested: () => dispatch(onSuggestionsClearRequested()),
53 dispatchAnalytics: () => dispatch(
54 postAnalyticsData(document.documentElement.outerHTML.replace('\s+', ''))),
55 onInvalidSearch: (searchText) => {
56 dispatch(getInvalidSearchInputEvent(searchText));
58 onMessageStateChange: (msgText, msgSeverity) => {
59 dispatch(setNotificationText(msgText, msgSeverity));
64 let mapStateToProps = ({globalAutoCompleteSearchBarReducer}) => {
68 cachedSuggestions = [],
69 suggestionName = 'text',
70 clearSearchText = false,
72 feedbackMsgSeverity = ''
73 } = globalAutoCompleteSearchBarReducer;
86 export class GlobalAutoCompleteSearchBar extends Component {
87 componentWillReceiveProps(nextProps) {
88 if (nextProps.clearSearchText) {
89 this.props.onClearSuggestionsTextFieldRequested();
92 if (nextProps.feedbackMsgText !== this.props.feedbackMsgText) {
93 this.props.onMessageStateChange(nextProps.feedbackMsgText,
94 nextProps.feedbackMsgSeverity);
100 <AutoCompleteSearchBar {...this.props} />
104 export default connect(mapStateToProps, mapActionToProps)(
105 GlobalAutoCompleteSearchBar);