Create new VSP, onboard from TOSCA file - UI
[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 SoftwareProductAttachmentsReducer from './attachments/SoftwareProductAttachmentsReducer.js';
19 import HeatValidationReducer from './attachments/validation/HeatValidationReducer.js';
20 import HeatSetupReducer from './attachments/setup/HeatSetupReducer.js';
21 import {actionTypes as heatSetupActionTypes} from './attachments/setup/HeatSetupConstants.js';
22 import SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js';
23 import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js';
24 import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js';
25 import SoftwareProductProcessesEditorReducer from './processes/SoftwareProductProcessesEditorReducer.js';
26 import SoftwareProductDeploymentListReducer from './deployment/SoftwareProductDeploymentListReducer.js';
27 import SoftwareProductDeploymentEditorReducer from './deployment/editor/SoftwareProductDeploymentEditorReducer.js';
28 import SoftwareProductNetworksListReducer from './networks/SoftwareProductNetworksListReducer.js';
29 import SoftwareProductComponentsListReducer from './components/SoftwareProductComponentsListReducer.js';
30 import SoftwareProductComponentEditorReducer from './components/SoftwareProductComponentEditorReducer.js';
31 import  {actionTypes as processesActionTypes} from './processes/SoftwareProductProcessesConstants.js';
32 import SoftwareProductComponentProcessesListReducer  from './components/processes/SoftwareProductComponentProcessesListReducer.js';
33 import SoftwareProductComponentProcessesEditorReducer from './components/processes/SoftwareProductComponentProcessesEditorReducer.js';
34 import  {actionTypes as componentProcessesActionTypes} from './components/processes/SoftwareProductComponentProcessesConstants.js';
35 import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js';
36 import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js';
37 import SoftwareProductComponentsImageListReducer from './components/images/SoftwareProductComponentsImageListReducer.js';
38 import SoftwareProductComponentsImageEditorReducer from './components/images/SoftwareProductComponentsImageEditorReducer.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                 attachmentsDetails: SoftwareProductAttachmentsReducer,
53                 heatValidation: HeatValidationReducer,
54                 heatSetup: HeatSetupReducer,
55                 heatSetupCache: (state = {}, action) => action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE ? action.payload : state
56         }),
57         softwareProductCreation: createPlainDataReducer(SoftwareProductCreationReducer),
58         softwareProductEditor: createPlainDataReducer(SoftwareProductDetailsReducer),
59         softwareProductProcesses: combineReducers({
60                 processesList: SoftwareProductProcessesListReducer,
61                 processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer),
62                 processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state
63         }),
64         softwareProductDeployment: combineReducers({
65                 deploymentFlavors: SoftwareProductDeploymentListReducer,
66                 deploymentFlavorEditor: createPlainDataReducer(SoftwareProductDeploymentEditorReducer)
67         }),
68         softwareProductNetworks: combineReducers({
69                 networksList: SoftwareProductNetworksListReducer
70         }),
71         softwareProductDependencies: SoftwareProductDependenciesReducer,
72         softwareProductComponents: combineReducers({
73                 componentsList: SoftwareProductComponentsListReducer,
74                 componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)),
75                 componentProcesses: combineReducers({
76                         processesList: SoftwareProductComponentProcessesListReducer,
77                         processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer),
78                         processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state,
79                 }),
80                 network: combineReducers({
81                         nicList: SoftwareProductComponentsNICListReducer,
82                         nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer)),
83                         nicCreation: createPlainDataReducer(SoftwareProductComponentsNICCreationReducer)
84                 }),
85                 images: combineReducers({
86                         imagesList: SoftwareProductComponentsImageListReducer,
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 });