2 * Copyright © 2016-2018 European Support Limited
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 or implied.
13 * See the License for the specific language governing permissions and
14 * 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 }
39 let { vendorName, description, id, version } = licenseModelEditor.data;
42 name: overviewItems.LICENSE_AGREEMENTS,
43 count: licenseAgreementList.length
45 { name: overviewItems.FEATURE_GROUPS, count: featureGroupsList.length },
47 name: overviewItems.ENTITLEMENT_POOLS,
48 count: entitlementPoolsList.length
51 name: overviewItems.LICENSE_KEY_GROUPS,
52 count: licenseKeyGroupsList.length
65 const mapActionsToProps = dispatch => {
67 onEditorOpenClick: (name, licenseModelId, version) => {
69 case overviewItems.ENTITLEMENT_POOLS:
70 EntitlementPoolsActionHelper.openEntitlementPoolsEditor(
79 case overviewItems.FEATURE_GROUPS:
80 FeatureGroupsActionHelper.openFeatureGroupsEditor(
89 case overviewItems.LICENSE_AGREEMENTS:
90 LicenseAgreementActionHelper.openLicenseAgreementEditor(
99 case overviewItems.LICENSE_KEY_GROUPS:
100 LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(
105 isReadOnlyMode: false
113 onNavigateClick: ({ name, licenseModelId, version }) => {
114 let screenToNavigate;
116 case overviewItems.ENTITLEMENT_POOLS:
117 screenToNavigate = enums.SCREEN.ENTITLEMENT_POOLS;
119 case overviewItems.FEATURE_GROUPS:
120 screenToNavigate = enums.SCREEN.FEATURE_GROUPS;
122 case overviewItems.LICENSE_AGREEMENTS:
123 screenToNavigate = enums.SCREEN.LICENSE_AGREEMENTS;
125 case overviewItems.LICENSE_KEY_GROUPS:
126 screenToNavigate = enums.SCREEN.LICENSE_KEY_GROUPS;
131 ScreensHelper.loadScreen(dispatch, {
132 screen: screenToNavigate,
133 screenType: screenTypes.LICENSE_MODEL,
134 props: { licenseModelId, version }
140 export class SummaryCountList extends React.Component {
142 let { counts } = this.props;
144 <div className="summary-count-list">
145 {counts.map(item => this.renderItem(item))}
151 const { name, count } = item;
152 const { isReadOnlyMode } = this.props;
155 isReadOnlyMode={isReadOnlyMode}
158 onNavigate={() => this.onNavigate(name)}
159 onAdd={() => this.onAdd(name)}
172 if (!isReadOnlyMode) {
173 onEditorOpenClick(name, licenseModelId, version);
178 let { onNavigateClick, licenseModelId, version } = this.props;
179 onNavigateClick({ licenseModelId, name, version });
183 export default connect(mapStateToProps, mapActionsToProps)(SummaryCountList);