2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 import { connect } from 'react-redux';
18 import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js';
19 import FeatureGroupEditorView from './FeatureGroupEditorView.jsx';
20 import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
22 export const mapStateToProps = ({
23 licenseModel: { featureGroup, entitlementPool, licenseKeyGroup }
25 let { entitlementPoolsList = [] } = entitlementPool;
26 let { licenseKeyGroupsList = [] } = licenseKeyGroup;
27 const { featureGroupEditor } = featureGroup;
28 let { data, selectedTab, genericFieldInfo, formReady } = featureGroupEditor;
29 const featureGroupId = data ? data.id : null;
30 const list = featureGroup.featureGroupsList;
38 previousData = list.find(
39 featureGroup => featureGroup.id === featureGroupId
43 for (let i = 0; i < list.length; i++) {
44 FGNames[list[i].name.toLowerCase()] = list[i].id;
47 for (let field in genericFieldInfo) {
48 if (!genericFieldInfo[field].isValid) {
50 let tabId = genericFieldInfo[field].tabId;
51 if (invalidTabs.indexOf(tabId) === -1) {
52 invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId;
71 const mapActionsToProps = (dispatch, { licenseModelId, version }) => {
73 onDataChanged: (deltaData, formName, customValidations) =>
74 ValidationHelper.dataChanged(dispatch, {
80 FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab(
86 onSubmit: (previousFeatureGroup, featureGroup) => {
87 FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch);
88 FeatureGroupsActionHelper.saveFeatureGroup(dispatch, {
96 FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch),
97 onValidateForm: formName =>
98 ValidationHelper.validateForm(dispatch, formName)
102 export default connect(mapStateToProps, mapActionsToProps)(
103 FeatureGroupEditorView