Support 50 Characters for VSP Name
[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  *
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 {
17     actionTypes,
18     SP_CREATION_FORM_NAME
19 } from './SoftwareProductCreationConstants.js';
20
21 export default (state = {}, action) => {
22     switch (action.type) {
23         case actionTypes.OPEN:
24             return {
25                 ...state,
26                 formName: SP_CREATION_FORM_NAME,
27                 disableVendor: action.selectedVendorId ? true : false,
28                 data: {
29                     vendorId: action.selectedVendorId
30                         ? action.selectedVendorId
31                         : undefined
32                 },
33                 genericFieldInfo: {
34                     description: {
35                         isValid: true,
36                         errorText: '',
37                         validations: [
38                             { type: 'freeEnglishText', data: true },
39                             { type: 'maxLength', data: 1000 },
40                             { type: 'required', data: true }
41                         ]
42                     },
43                     vendorId: {
44                         isValid: true,
45                         errorText: '',
46                         validations: [{ type: 'required', data: true }]
47                     },
48                     subCategory: {
49                         isValid: true,
50                         errorText: '',
51                         validations: [{ type: 'required', data: true }]
52                     },
53                     category: {
54                         isValid: true,
55                         errorText: '',
56                         validations: [{ type: 'required', data: true }]
57                     },
58                     name: {
59                         isValid: true,
60                         errorText: '',
61                         validations: [
62                             { type: 'required', data: true },
63                             { type: 'maxLength', data: 50 },
64                             { type: 'validateName', data: true }
65                         ]
66                     },
67                     onboardingMethod: {
68                         isValid: true,
69                         errorText: '',
70                         validations: [
71                             { type: 'requiredChooseOption', data: true }
72                         ]
73                     }
74                 },
75                 showModal: true
76             };
77         case actionTypes.VENDOR_LIST_LOADED:
78             return {
79                 ...state,
80                 vendorList: action.vendorList
81             };
82         case actionTypes.RESET_DATA:
83             return {};
84         default:
85             return state;
86     }
87 };