[SDC] Onboarding 1710 rebase.
[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 SoftwareProductDeploymentListReducer from './deployment/SoftwareProductDeploymentListReducer.js';
26 import SoftwareProductDeploymentEditorReducer from './deployment/editor/SoftwareProductDeploymentEditorReducer.js';
27 import SoftwareProductNetworksListReducer from './networks/SoftwareProductNetworksListReducer.js';
28 import SoftwareProductComponentsListReducer from './components/SoftwareProductComponentsListReducer.js';
29 import SoftwareProductComponentEditorReducer from './components/SoftwareProductComponentEditorReducer.js';
30 import  {actionTypes as processesActionTypes} from './processes/SoftwareProductProcessesConstants.js';
31 import SoftwareProductComponentProcessesListReducer  from './components/processes/SoftwareProductComponentProcessesListReducer.js';
32 import SoftwareProductComponentProcessesEditorReducer from './components/processes/SoftwareProductComponentProcessesEditorReducer.js';
33 import  {actionTypes as componentProcessesActionTypes} from './components/processes/SoftwareProductComponentProcessesConstants.js';
34 import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js';
35 import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js';
36 import SoftwareProductComponentsImageListReducer from './components/images/SoftwareProductComponentsImageListReducer.js';
37 import SoftwareProductComponentsImageEditorReducer from './components/images/SoftwareProductComponentsImageEditorReducer.js';
38 import SoftwareProductComponentsImageNavigationReducer from './components/images/SoftwareProductComponentsImageNavigationReducer.js';
39 import SoftwareProductComponentsNICCreationReducer from './components/network/NICCreation/NICCreationReducer.js';
40 import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.js';
41 import SoftwareProductComponentsComputeFlavorListReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js';
42 import SoftwareProductComponentsComputeFlavorReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js';
43 import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js';
44 import SoftwareProductDependenciesReducer from './dependencies/SoftwareProductDependenciesReducer.js';
45 import {createJSONSchemaReducer, createComposedJSONSchemaReducer} from 'sdc-app/common/reducers/JSONSchemaReducer.js';
46 import {COMPONENTS_QUESTIONNAIRE, COMPONENTS_COMPUTE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
47 import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js';
48 import {IMAGE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js';
49
50 export default combineReducers({
51         softwareProductAttachments: combineReducers({
52                 heatValidation: HeatValidationReducer,
53                 heatSetup: HeatSetupReducer,
54                 heatSetupCache: (state = {}, action) => action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE ? action.payload : state
55         }),
56         softwareProductCreation: createPlainDataReducer(SoftwareProductCreationReducer),
57         softwareProductEditor: createPlainDataReducer(SoftwareProductDetailsReducer),
58         softwareProductProcesses: combineReducers({
59                 processesList: SoftwareProductProcessesListReducer,
60                 processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer),
61                 processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state
62         }),
63         softwareProductDeployment: combineReducers({
64                 deploymentFlavors: SoftwareProductDeploymentListReducer,
65                 deploymentFlavorEditor: createPlainDataReducer(SoftwareProductDeploymentEditorReducer)
66         }),
67         softwareProductNetworks: combineReducers({
68                 networksList: SoftwareProductNetworksListReducer
69         }),
70         softwareProductDependencies: SoftwareProductDependenciesReducer,
71         softwareProductComponents: combineReducers({
72                 componentsList: SoftwareProductComponentsListReducer,
73                 componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)),
74                 componentProcesses: combineReducers({
75                         processesList: SoftwareProductComponentProcessesListReducer,
76                         processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer),
77                         processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state,
78                 }),
79                 network: combineReducers({
80                         nicList: SoftwareProductComponentsNICListReducer,
81                         nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer)),
82                         nicCreation: createPlainDataReducer(SoftwareProductComponentsNICCreationReducer)
83                 }),
84                 images: combineReducers({
85                         imagesList: SoftwareProductComponentsImageListReducer,
86                         imagesNavigationList: SoftwareProductComponentsImageNavigationReducer,
87                         imageEditor: createPlainDataReducer(createComposedJSONSchemaReducer(IMAGE_QUESTIONNAIRE, SoftwareProductComponentsImageEditorReducer))
88                 }),
89                 computeFlavor: combineReducers({
90                         computesList: SoftwareProductComponentsComputeFlavorListReducer,
91                         computeEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_COMPUTE_QUESTIONNAIRE, SoftwareProductComponentsComputeFlavorReducer)),
92                 }),
93                 monitoring: SoftwareProductComponentsMonitoringReducer
94         }),
95         softwareProductCategories: (state = [], action) => {
96                 if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) {
97                         return action.softwareProductCategories;
98                 }
99                 return state;
100         },
101         softwareProductQuestionnaire: createJSONSchemaReducer(PRODUCT_QUESTIONNAIRE)
102 });