[AAI-92 Amsterdam] Update license
[aai/sparky-fe.git] / src / app / vnfSearch / VnfSearchReducer.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 import {vnfActionTypes} from 'app/vnfSearch/VnfSearchConstants.js';
24 import {
25   CHART_ORCH_STATUS,
26   CHART_PROV_STATUS,
27   TOTAL_VNF_COUNT
28 } from 'app/vnfSearch/VnfSearchConstants.js';
29 import {ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js';
30 import {MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js';
31 import {
32   globalAutoCompleteSearchBarActionTypes
33 } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
34
35 export default (state = {}, action) => {
36   let data = action.data;
37   switch (action.type) {
38
39     case vnfActionTypes.COUNT_BY_PROV_STATUS_RECEIVED:
40       return {
41         ...state,
42         processedProvStatusCountChartData: data.provStatusCountChartData.chartData,
43         feedbackMsgText: '',
44         feedbackMsgSeverity: ''
45       };
46
47     case vnfActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED:
48       return {
49         ...state,
50         processedOrchStatusCountChartData: data.orchStatusCountChartData.chartData,
51         feedbackMsgText: '',
52         feedbackMsgSeverity: ''
53       };
54     case vnfActionTypes.TOTAL_VNF_COUNT_RECEIVED:
55       return {
56         ...state,
57         count: data.count,
58         feedbackMsgText: '',
59         feedbackMsgSeverity: ''
60       };
61     case vnfActionTypes.ERROR_NO_DATA_FOR_PROV_STATUS_IN_SEARCH_RANGE_RECEIVED:
62       return {
63         ...state,
64         processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData,
65       };
66     case vnfActionTypes.ERROR_NO_DATA_FOR_ORCH_STATUS_IN_SEARCH_RANGE_RECEIVED:
67       return {
68         ...state,
69         processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData,
70       };
71     case vnfActionTypes.ERROR_NO_COUNT_RECEIVED:
72       return {
73         ...state,
74         count: TOTAL_VNF_COUNT.emptyValue,
75       };
76     case vnfActionTypes.VNF_NETWORK_ERROR:
77       return {
78         ...state,
79         processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData,
80         processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData,
81         count: TOTAL_VNF_COUNT.emptyValue,
82         feedbackMsgText: ERROR_RETRIEVING_DATA,
83         feedbackMsgSeverity: MESSAGE_LEVEL_DANGER
84       };
85     case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT:
86       return {
87         ...state,
88         processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData,
89         processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData,
90         count: TOTAL_VNF_COUNT.emptyValue
91       };
92   }
93
94   return state;
95 };