97988d87f9202ba32756af5048d23e228794e202
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / SoftwareProductReducer.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 import {combineReducers} from 'redux';
17 import {actionTypes, PRODUCT_QUESTIONNAIRE} from './SoftwareProductConstants.js';
18 import HeatValidationReducer from './attachments/validation/HeatValidationReducer.js';
19 import HeatSetupReducer from './attachments/setup/HeatSetupReducer.js';
20 import {actionTypes as heatSetupActionTypes} from './attachments/setup/HeatSetupConstants.js';
21 import SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js';
22 import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js';
23 import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js';
24 import SoftwareProductProcessesEditorReducer from './processes/SoftwareProductProcessesEditorReducer.js';
25 import SoftwareProductNetworksListReducer from './networks/SoftwareProductNetworksListReducer.js';
26 import SoftwareProductComponentsListReducer from './components/SoftwareProductComponentsListReducer.js';
27 import SoftwareProductComponentEditorReducer from './components/SoftwareProductComponentEditorReducer.js';
28 import  {actionTypes as processesActionTypes} from './processes/SoftwareProductProcessesConstants.js';
29 import SoftwareProductComponentProcessesListReducer  from './components/processes/SoftwareProductComponentProcessesListReducer.js';
30 import SoftwareProductComponentProcessesEditorReducer from './components/processes/SoftwareProductComponentProcessesEditorReducer.js';
31 import  {actionTypes as componentProcessesActionTypes} from './components/processes/SoftwareProductComponentProcessesConstants.js';
32 import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js';
33 import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js';
34 import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.js';
35 import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js';
36 import SoftwareProductDependenciesReducer from './dependencies/SoftwareProductDependenciesReducer.js';
37 import {createJSONSchemaReducer, createComposedJSONSchemaReducer} from 'sdc-app/common/reducers/JSONSchemaReducer.js';
38 import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
39 import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js';
40
41 export default combineReducers({
42         softwareProductAttachments: combineReducers({
43                 heatValidation: HeatValidationReducer,
44                 heatSetup: HeatSetupReducer,
45                 heatSetupCache: (state = {}, action) => action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE ? action.payload : state
46         }),
47         softwareProductCreation: createPlainDataReducer(SoftwareProductCreationReducer),
48         softwareProductEditor: createPlainDataReducer(SoftwareProductDetailsReducer),
49         softwareProductProcesses: combineReducers({
50                 processesList: SoftwareProductProcessesListReducer,
51                 processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer),
52                 processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state
53         }),
54         softwareProductNetworks: combineReducers({
55                 networksList: SoftwareProductNetworksListReducer
56         }),
57         softwareProductDependencies: SoftwareProductDependenciesReducer,
58         softwareProductComponents: combineReducers({
59                 componentsList: SoftwareProductComponentsListReducer,
60                 componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)),
61                 componentProcesses: combineReducers({
62                         processesList: SoftwareProductComponentProcessesListReducer,
63                         processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer),
64                         processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state,
65                 }),
66                 network: combineReducers({
67                         nicList: SoftwareProductComponentsNICListReducer,
68                         nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer))
69                 }),
70                 monitoring: SoftwareProductComponentsMonitoringReducer
71         }),
72         softwareProductCategories: (state = [], action) => {
73                 if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) {
74                         return action.softwareProductCategories;
75                 }
76                 return state;
77         },
78         softwareProductQuestionnaire: createJSONSchemaReducer(PRODUCT_QUESTIONNAIRE)
79 });