Integrate VNF Repository with SDC
[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 import VNFImportReducer from './vnfMarketPlace/VNFImportReducer.js';
51
52 export default combineReducers({
53         softwareProductAttachments: combineReducers({
54                 attachmentsDetails: SoftwareProductAttachmentsReducer,
55                 heatValidation: HeatValidationReducer,
56                 heatSetup: HeatSetupReducer,
57                 heatSetupCache: (state = {}, action) => action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE ? action.payload : state
58         }),
59         softwareProductCreation: createPlainDataReducer(SoftwareProductCreationReducer),
60         softwareProductEditor: createPlainDataReducer(SoftwareProductDetailsReducer),
61         softwareProductProcesses: combineReducers({
62                 processesList: SoftwareProductProcessesListReducer,
63                 processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer),
64                 processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state
65         }),
66         softwareProductDeployment: combineReducers({
67                 deploymentFlavors: SoftwareProductDeploymentListReducer,
68                 deploymentFlavorEditor: createPlainDataReducer(SoftwareProductDeploymentEditorReducer)
69         }),
70         softwareProductNetworks: combineReducers({
71                 networksList: SoftwareProductNetworksListReducer
72         }),
73         softwareProductDependencies: SoftwareProductDependenciesReducer,
74         softwareProductComponents: combineReducers({
75                 componentsList: SoftwareProductComponentsListReducer,
76                 componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)),
77                 componentProcesses: combineReducers({
78                         processesList: SoftwareProductComponentProcessesListReducer,
79                         processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer),
80                         processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state,
81                 }),
82                 network: combineReducers({
83                         nicList: SoftwareProductComponentsNICListReducer,
84                         nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer)),
85                         nicCreation: createPlainDataReducer(SoftwareProductComponentsNICCreationReducer)
86                 }),
87                 images: combineReducers({
88                         imagesList: SoftwareProductComponentsImageListReducer,
89                         imageEditor: createPlainDataReducer(createComposedJSONSchemaReducer(IMAGE_QUESTIONNAIRE, SoftwareProductComponentsImageEditorReducer))
90                 }),
91                 computeFlavor: combineReducers({
92                         computesList: SoftwareProductComponentsComputeFlavorListReducer,
93                         computeEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_COMPUTE_QUESTIONNAIRE, SoftwareProductComponentsComputeFlavorReducer)),
94                 }),
95                 monitoring: SoftwareProductComponentsMonitoringReducer
96         }),
97         softwareProductCategories: (state = [], action) => {
98                 if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) {
99                         return action.softwareProductCategories;
100                 }
101                 return state;
102         },
103         softwareProductQuestionnaire: createJSONSchemaReducer(PRODUCT_QUESTIONNAIRE),
104         VNFMarketPlaceImport: VNFImportReducer
105 });