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 React from 'react';
17 import {connect} from 'react-redux';
19 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
20 import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js';
22 import EntitlementPoolsActionHelper from '../../entitlementPools/EntitlementPoolsActionHelper.js';
23 import LicenseAgreementActionHelper from '../../licenseAgreement/LicenseAgreementActionHelper.js';
24 import LicenseKeyGroupsActionHelper from '../../licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
25 import FeatureGroupsActionHelper from '../../featureGroups/FeatureGroupsActionHelper.js';
27 import {overviewItems} from '../LicenseModelOverviewConstants.js';
28 import SummaryCountItem from './SummaryCountItem.jsx';
30 export const mapStateToProps = ({
33 licenseAgreement: {licenseAgreementList},
34 featureGroup: {featureGroupsList},
35 entitlementPool: {entitlementPoolsList},
36 licenseKeyGroup: {licenseKeyGroupsList}
40 let {vendorName, description, id, version} = licenseModelEditor.data;
42 {name: overviewItems.LICENSE_AGREEMENTS, count: licenseAgreementList.length},
43 {name: overviewItems.FEATURE_GROUPS, count: featureGroupsList.length},
44 {name: overviewItems.ENTITLEMENT_POOLS, count: entitlementPoolsList.length},
45 {name: overviewItems.LICENSE_KEY_GROUPS, count: licenseKeyGroupsList.length},
58 const mapActionsToProps = (dispatch) => {
60 onEditorOpenClick: (name, licenseModelId, version) => {
62 case overviewItems.ENTITLEMENT_POOLS:
63 EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch);
65 case overviewItems.FEATURE_GROUPS:
66 FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId, version});
68 case overviewItems.LICENSE_AGREEMENTS:
69 LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, version});
71 case overviewItems.LICENSE_KEY_GROUPS:
72 LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch);
78 onNavigateClick: ({name, licenseModelId, version}) => {
81 case overviewItems.ENTITLEMENT_POOLS:
82 screenToNavigate = enums.SCREEN.ENTITLEMENT_POOLS;
84 case overviewItems.FEATURE_GROUPS:
85 screenToNavigate = enums.SCREEN.FEATURE_GROUPS;
87 case overviewItems.LICENSE_AGREEMENTS:
88 screenToNavigate = enums.SCREEN.LICENSE_AGREEMENTS;
90 case overviewItems.LICENSE_KEY_GROUPS:
91 screenToNavigate = enums.SCREEN.LICENSE_KEY_GROUPS;
96 ScreensHelper.loadScreen(dispatch, {
97 screen: screenToNavigate, screenType: screenTypes.LICENSE_MODEL,
98 props: {licenseModelId, version}
104 export class SummaryCountList extends React.Component {
107 let {counts} = this.props;
109 <div className='summary-count-list'>
110 {counts.map(item => this.renderItem(item))}
116 const {name, count} = item;
117 const {isReadOnlyMode} = this.props;
119 <SummaryCountItem isReadOnlyMode={isReadOnlyMode} name={name} counter={count} onNavigate={() => this.onNavigate(name)} onAdd={() => this.onAdd(name)} key={name} />
124 let {onEditorOpenClick, licenseModelId, isReadOnlyMode, version} = this.props;
125 if (!isReadOnlyMode) {
126 onEditorOpenClick(name, licenseModelId, version);
131 let {onNavigateClick, licenseModelId, version} = this.props;
132 onNavigateClick({licenseModelId, name, version});
136 export default connect(mapStateToProps, mapActionsToProps)(SummaryCountList);