[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / licenseModel / LicenseModelReducer.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
18 import activityLogReducer from 'nfvo-components/activity-log/ActivityLogReducer.js';
19
20 import licenseModelCreationReducer from './creation/LicenseModelCreationReducer.js';
21 import licenseModelEditorReducer from './LicenseModelEditorReducer.js';
22
23 import licenseAgreementListReducer from './licenseAgreement/LicenseAgreementListReducer.js';
24 import licenseAgreementEditorReducer from './licenseAgreement/LicenseAgreementEditorReducer.js';
25
26 import featureGroupsEditorReducer from './featureGroups/FeatureGroupsEditorReducer.js';
27 import featureGroupsListReducer from './featureGroups/FeatureGroupsListReducer.js';
28
29 import entitlementPoolsListReducer from './entitlementPools/EntitlementPoolsListReducer.js';
30 import entitlementPoolsEditorReducer from './entitlementPools/EntitlementPoolsEditorReducer.js';
31
32 import licenseKeyGroupsEditorReducer from './licenseKeyGroups/LicenseKeyGroupsEditorReducer.js';
33 import licenseKeyGroupsListReducer from './licenseKeyGroups/LicenseKeyGroupsListReducer.js';
34
35 import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js';
36
37 import {actionTypes as licenseModelOverviewConstants, selectedButton, VLM_DESCRIPTION_FORM} from './overview/LicenseModelOverviewConstants.js';
38
39 export default combineReducers({
40         licenseModelCreation: createPlainDataReducer(licenseModelCreationReducer),
41         licenseModelEditor: licenseModelEditorReducer,
42
43         licenseAgreement: combineReducers({
44                 licenseAgreementEditor: createPlainDataReducer(licenseAgreementEditorReducer),
45                 licenseAgreementList: licenseAgreementListReducer
46         }),
47         featureGroup: combineReducers({
48                 featureGroupEditor: createPlainDataReducer(featureGroupsEditorReducer),
49                 featureGroupsList: featureGroupsListReducer
50         }),
51         entitlementPool: combineReducers({
52                 entitlementPoolEditor: createPlainDataReducer(entitlementPoolsEditorReducer),
53                 entitlementPoolsList: entitlementPoolsListReducer
54         }),
55         licenseKeyGroup: combineReducers({
56                 licenseKeyGroupsEditor: createPlainDataReducer(licenseKeyGroupsEditorReducer),
57                 licenseKeyGroupsList: licenseKeyGroupsListReducer
58         }),
59         licenseModelOverview: combineReducers({
60                 selectedTab: (state = selectedButton.VLM_LIST_VIEW, action) => action.type === licenseModelOverviewConstants.LICENSE_MODEL_OVERVIEW_TAB_SELECTED ? action.buttonTab : state,
61                 descriptionEditor: createPlainDataReducer(function(state = false, action) {
62                         if (action.type === licenseModelOverviewConstants.LM_DATA_CHANGED) {
63                                 return {
64                                         ...state,
65                                         data : {
66                                                 description : action.description
67                                         },
68                                         formReady: null,
69                                         formName: VLM_DESCRIPTION_FORM,
70                                         genericFieldInfo: {
71                                                 'description': {
72                                                         isValid: true,
73                                                         errorText: '',
74                                                         validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}]
75                                                 }
76                                         }
77                                 };
78                                 //return action.description;
79                         } else {
80                                 return state;
81                         }
82                 }
83         )}),
84         activityLog: activityLogReducer
85 });