Specify a model while creating a VSP
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / creation / SoftwareProductCreationReducer.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 {
18     actionTypes,
19     SP_CREATION_FORM_NAME
20 } from './SoftwareProductCreationConstants.js';
21
22 export default (state = {}, action) => {
23     switch (action.type) {
24         case actionTypes.OPEN:
25             return {
26                 ...state,
27                 formName: SP_CREATION_FORM_NAME,
28                 disableVendor: action.selectedVendorId ? true : false,
29                 data: {
30                     vendorId: action.selectedVendorId
31                         ? action.selectedVendorId
32                         : undefined
33                 },
34                 genericFieldInfo: {
35                     description: {
36                         isValid: true,
37                         errorText: '',
38                         validations: [
39                             { type: 'freeEnglishText', data: true },
40                             { type: 'maxLength', data: 1000 },
41                             { type: 'required', data: true }
42                         ]
43                     },
44                     vendorId: {
45                         isValid: true,
46                         errorText: '',
47                         validations: [{ type: 'required', data: true }]
48                     },
49                     subCategory: {
50                         isValid: true,
51                         errorText: '',
52                         validations: [{ type: 'required', data: true }]
53                     },
54                     category: {
55                         isValid: true,
56                         errorText: '',
57                         validations: [{ type: 'required', data: true }]
58                     },
59                     name: {
60                         isValid: true,
61                         errorText: '',
62                         validations: [
63                             { type: 'required', data: true },
64                             { type: 'maxLength', data: 50 },
65                             { type: 'validateName', data: true }
66                         ]
67                     },
68                     onboardingMethod: {
69                         isValid: true,
70                         errorText: '',
71                         validations: [
72                             { type: 'requiredChooseOption', data: true }
73                         ]
74                     },
75                     modelOption: {
76                         isValid: true,
77                         errorText: '',
78                         validations: [
79                             { type: 'requiredChooseOption', data: true }
80                         ]
81                     },
82                     selectedModelList: {
83                         isValid: true,
84                         errorText: '',
85                         validations: []
86                     }
87                 },
88                 showModal: true
89             };
90         case actionTypes.VENDOR_LIST_LOADED:
91             return {
92                 ...state,
93                 vendorList: action.vendorList
94             };
95         case actionTypes.RESET_DATA:
96             return {};
97         default:
98             return state;
99     }
100 };