[AAI] Remove Robby Maharajh & Harish Kajur as committers
[aai/sparky-fe.git] / src / app / MainScreenWrapperReducer.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 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 import {aaiActionTypes} from './MainScreenWrapperConstants.js';
22 import {
23   globalAutoCompleteSearchBarActionTypes
24 } from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
25 import {
26   contextHandlerActionTypes
27 } from 'app/contextHandler/ContextHandlerConstants.js';
28 import {
29   personalizationActionTypes
30 } from 'app/personlaization/PersonalizationConstans.js';
31
32 export default (state = {}, action) => {
33   switch (action.type) {
34     case aaiActionTypes.AAI_SHOW_MENU:
35       return {
36         ...state,
37         showMenu: action.data.showMenu,
38         toggleButtonActive: action.data.showMenu // if showing menu, then toggle
39                                                // is active
40       };
41     case aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_RESPONSE_RECEIVED:
42       let obj = {...state};
43       obj['extensibleViewNetworkCallbackData'] = {};
44       obj['extensibleViewNetworkCallbackData'][action.data.paramName] =  action.data.viewData;
45       // If there are some current viewData that need to be kept:
46       for(var vData in action.data.curViewData) {
47         obj['extensibleViewNetworkCallbackData'][vData] = action.data.curViewData[vData];
48       }
49       return obj;
50     case aaiActionTypes.EXTENSIBLE_VIEW_NETWORK_CALLBACK_CLEAR_DATA:
51       return {
52         ...state,
53         extensibleViewNetworkCallbackData : {}
54       };
55     case globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT:
56       return {
57         ...state,
58         extensibleViewNetworkCallbackData: {clearView: true}
59       };
60     case contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND:
61       return {
62         ...state,
63         externalRequestFound: action.data
64       };
65
66     case aaiActionTypes.SET_SECONDARY_TITLE:
67       return {
68         ...state,
69         secondaryTitle: action.data
70       };
71     case contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND:
72       return {
73         ...state,
74         subscriptionPayload: action.data.subscriptionDetails,
75         subscriptionEnabled: true
76       };
77     case contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY:
78       return {
79         ...state,
80         subscriptionEnabled: false
81       };
82     case personalizationActionTypes.PERSONALIZATION_PAYLOAD_FOUND:
83       return {
84         ...state,
85         aaiTopLeftPersonalizedHeader: action.data.topLeftHeader,
86         aaiPersonalizedHtmlDocumentTitle: action.data.htmlDocumentTitle,
87         aaiPersonalizedApertureService: action.data.apertureService,
88         aaiPersonalizedLoadTemplateMaxCount: action.data.loadTemplateMaxCount
89       };
90   }
91   return state;
92 };
93