[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / licenseModel / featureGroups / FeatureGroupsEditorReducer.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
17 import {actionTypes, FG_EDITOR_FORM, state as FeatureGroupStateConstants} from './FeatureGroupsConstants.js';
18
19
20
21 export default (state = {}, action) => {
22         switch (action.type) {
23                 case actionTypes.featureGroupsEditor.OPEN:
24                         return {
25                                 ...state,
26                                 data: action.featureGroup || {},
27                                 formReady: null,
28                                 formName: FG_EDITOR_FORM,
29                                 genericFieldInfo: {
30                                         'description': {
31                                                 isValid: true,
32                                                 errorText: '',
33                                                 validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}],
34                                                 tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL
35                                         },
36                                         'partNumber': {
37                                                 isValid: true,
38                                                 errorText: '',
39                                                 validations: [{type: 'required', data: true}],
40                                                 tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL
41                                         },
42                                         'name': {
43                                                 isValid: true,
44                                                 errorText: '',
45                                                 validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}],
46                                                 tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL
47                                         }
48                                 }
49                         };
50                 case actionTypes.featureGroupsEditor.CLOSE:
51                         return {};
52                 case actionTypes.featureGroupsEditor.SELECT_TAB:
53                         return {
54                                 ...state,
55                                 selectedTab: action.tab
56                         };
57
58                 case actionTypes.featureGroupsEditor.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB:
59                         return {
60                                 ...state,
61                                 selectedEntitlementPoolsButtonTab: action.buttonTab
62                         };
63                 case actionTypes.featureGroupsEditor.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB:
64                         return {
65                                 ...state,
66                                 selectedLicenseKeyGroupsButtonTab: action.buttonTab
67                         };
68                 default:
69                         return state;
70         }
71
72 };