Specify a model while creating a VSP
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / SoftwareProductReducer.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  * Modifications Copyright (C) 2021 Nordix Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing
15  * permissions and limitations under the License.
16  */
17 import { combineReducers } from 'redux';
18 import {
19     actionTypes,
20     PRODUCT_QUESTIONNAIRE
21 } from './SoftwareProductConstants.js';
22 import SoftwareProductAttachmentsReducer from './attachments/SoftwareProductAttachmentsReducer.js';
23 import HeatValidationReducer from './attachments/validation/HeatValidationReducer.js';
24 import HeatSetupReducer from './attachments/setup/HeatSetupReducer.js';
25 import { actionTypes as heatSetupActionTypes } from './attachments/setup/HeatSetupConstants.js';
26 import SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js';
27 import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js';
28 import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js';
29 import SoftwareProductValidationReducer from './validation/SoftwareProductValidationReducer.js';
30 import SoftwareProductProcessesEditorReducer from './processes/SoftwareProductProcessesEditorReducer.js';
31 import SoftwareProductDeploymentListReducer from './deployment/SoftwareProductDeploymentListReducer.js';
32 import SoftwareProductDeploymentEditorReducer from './deployment/editor/SoftwareProductDeploymentEditorReducer.js';
33 import SoftwareProductNetworksListReducer from './networks/SoftwareProductNetworksListReducer.js';
34 import SoftwareProductComponentsListReducer from './components/SoftwareProductComponentsListReducer.js';
35 import SoftwareProductComponentEditorReducer from './components/SoftwareProductComponentEditorReducer.js';
36 import { actionTypes as processesActionTypes } from './processes/SoftwareProductProcessesConstants.js';
37 import SoftwareProductComponentProcessesListReducer from './components/processes/SoftwareProductComponentProcessesListReducer.js';
38 import SoftwareProductComponentProcessesEditorReducer from './components/processes/SoftwareProductComponentProcessesEditorReducer.js';
39 import { actionTypes as componentProcessesActionTypes } from './components/processes/SoftwareProductComponentProcessesConstants.js';
40 import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js';
41 import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js';
42 import SoftwareProductComponentsImageListReducer from './components/images/SoftwareProductComponentsImageListReducer.js';
43 import SoftwareProductComponentsImageEditorReducer from './components/images/SoftwareProductComponentsImageEditorReducer.js';
44 import SoftwareProductComponentsNICCreationReducer from './components/network/NICCreation/NICCreationReducer.js';
45 import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.js';
46 import SoftwareProductComponentsComputeFlavorListReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js';
47 import SoftwareProductComponentsComputeFlavorReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js';
48 import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js';
49 import SoftwareProductDependenciesReducer from './dependencies/SoftwareProductDependenciesReducer.js';
50 import SoftwareProductValidationResultsViewReducer from './validationResults/SoftwareProductValidationResultsViewReducer.js';
51 import {
52     createJSONSchemaReducer,
53     createComposedJSONSchemaReducer
54 } from 'sdc-app/common/reducers/JSONSchemaReducer.js';
55 import {
56     COMPONENTS_QUESTIONNAIRE,
57     COMPONENTS_COMPUTE_QUESTIONNAIRE
58 } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
59 import { NIC_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js';
60 import { IMAGE_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js';
61
62 import VNFImportReducer from './vnfMarketPlace/VNFImportReducer.js';
63
64 export default combineReducers({
65     softwareProductAttachments: combineReducers({
66         attachmentsDetails: SoftwareProductAttachmentsReducer,
67         heatValidation: HeatValidationReducer,
68         heatSetup: HeatSetupReducer,
69         heatSetupCache: (state = {}, action) =>
70             action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE
71                 ? action.payload
72                 : state
73     }),
74     softwareProductCreation: createPlainDataReducer(
75         SoftwareProductCreationReducer
76     ),
77     softwareProductEditor: createPlainDataReducer(
78         SoftwareProductDetailsReducer
79     ),
80     softwareProductValidation: createPlainDataReducer(
81         SoftwareProductValidationReducer
82     ),
83     softwareProductValidationResult: createPlainDataReducer(
84         SoftwareProductValidationResultsViewReducer
85     ),
86     softwareProductProcesses: combineReducers({
87         processesList: SoftwareProductProcessesListReducer,
88         processesEditor: createPlainDataReducer(
89             SoftwareProductProcessesEditorReducer
90         ),
91         processToDelete: (state = false, action) =>
92             action.type ===
93             processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM
94                 ? action.processToDelete
95                 : state
96     }),
97     softwareProductDeployment: combineReducers({
98         deploymentFlavors: SoftwareProductDeploymentListReducer,
99         deploymentFlavorEditor: createPlainDataReducer(
100             SoftwareProductDeploymentEditorReducer
101         )
102     }),
103     softwareProductNetworks: combineReducers({
104         networksList: SoftwareProductNetworksListReducer
105     }),
106     softwareProductDependencies: SoftwareProductDependenciesReducer,
107     softwareProductComponents: combineReducers({
108         componentsList: SoftwareProductComponentsListReducer,
109         componentEditor: createPlainDataReducer(
110             createComposedJSONSchemaReducer(
111                 COMPONENTS_QUESTIONNAIRE,
112                 SoftwareProductComponentEditorReducer
113             )
114         ),
115         componentProcesses: combineReducers({
116             processesList: SoftwareProductComponentProcessesListReducer,
117             processesEditor: createPlainDataReducer(
118                 SoftwareProductComponentProcessesEditorReducer
119             ),
120             processToDelete: (state = false, action) =>
121                 action.type ===
122                 componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM
123                     ? action.processToDelete
124                     : state
125         }),
126         network: combineReducers({
127             nicList: SoftwareProductComponentsNICListReducer,
128             nicEditor: createPlainDataReducer(
129                 createComposedJSONSchemaReducer(
130                     NIC_QUESTIONNAIRE,
131                     SoftwareProductComponentsNICEditorReducer
132                 )
133             ),
134             nicCreation: createPlainDataReducer(
135                 SoftwareProductComponentsNICCreationReducer
136             )
137         }),
138         images: combineReducers({
139             imagesList: SoftwareProductComponentsImageListReducer,
140             imageEditor: createPlainDataReducer(
141                 createComposedJSONSchemaReducer(
142                     IMAGE_QUESTIONNAIRE,
143                     SoftwareProductComponentsImageEditorReducer
144                 )
145             )
146         }),
147         computeFlavor: combineReducers({
148             computesList: SoftwareProductComponentsComputeFlavorListReducer,
149             computeEditor: createPlainDataReducer(
150                 createComposedJSONSchemaReducer(
151                     COMPONENTS_COMPUTE_QUESTIONNAIRE,
152                     SoftwareProductComponentsComputeFlavorReducer
153                 )
154             )
155         }),
156         monitoring: SoftwareProductComponentsMonitoringReducer
157     }),
158     softwareProductCategories: (state = [], action) => {
159         if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) {
160             return action.softwareProductCategories;
161         }
162         return state;
163     },
164     modelList: (state = [], action) => {
165         if (action.type === actionTypes.SOFTWARE_PRODUCT_MODELS_LOADED) {
166             return action.modelList;
167         }
168         return state;
169     },
170     softwareProductQuestionnaire: createJSONSchemaReducer(
171         PRODUCT_QUESTIONNAIRE
172     ),
173     VNFMarketPlaceImport: VNFImportReducer
174 });