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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
21 import OnboardingActionHelper from '../../../OnboardingActionHelper.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 = ({licenseModel: {licenseModelEditor, licenseAgreement: {licenseAgreementList},
31 featureGroup: {featureGroupsList}, entitlementPool: {entitlementPoolsList}, licenseKeyGroup: {licenseKeyGroupsList}}}) => {
33 let {vendorName, description, id, version} = licenseModelEditor.data;
35 let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data);
38 {name: overviewItems.LICENSE_AGREEMENTS, count: licenseAgreementList.length},
39 {name: overviewItems.FEATURE_GROUPS, count: featureGroupsList.length},
40 {name: overviewItems.ENTITLEMENT_POOLS, count: entitlementPoolsList.length},
41 {name: overviewItems.LICENSE_KEY_GROUPS, count: licenseKeyGroupsList.length},
53 const mapActionsToProps = (dispatch) => {
55 onEditorOpenClick: (name, licenseModelId, version) => {
57 case overviewItems.ENTITLEMENT_POOLS:
58 EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch);
60 case overviewItems.FEATURE_GROUPS:
61 FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId, version});
63 case overviewItems.LICENSE_AGREEMENTS:
64 LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, version});
66 case overviewItems.LICENSE_KEY_GROUPS:
67 LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch);
73 onNavigateClick: ({name, licenseModelId, version}) => {
75 case overviewItems.ENTITLEMENT_POOLS:
76 OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version});
78 case overviewItems.FEATURE_GROUPS:
79 OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version});
81 case overviewItems.LICENSE_AGREEMENTS:
82 OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version});
84 case overviewItems.LICENSE_KEY_GROUPS:
85 OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version});
94 export class SummaryCountList extends React.Component {
97 let {counts} = this.props;
99 <div className='summary-count-list'>
100 {counts.map(item => this.renderItem(item))}
106 const {name, count} = item;
107 const {isReadOnlyMode} = this.props;
109 <SummaryCountItem isReadOnlyMode={isReadOnlyMode} name={name} counter={count} onNavigate={() => this.onNavigate(name)} onAdd={() => this.onAdd(name)} key={name} />
114 let {onEditorOpenClick, licenseModelId, isReadOnlyMode, version} = this.props;
115 if (!isReadOnlyMode) {
116 onEditorOpenClick(name, licenseModelId, version);
121 let {onNavigateClick, licenseModelId, version} = this.props;
122 onNavigateClick({licenseModelId, name, version});
126 export default connect(mapStateToProps, mapActionsToProps)(SummaryCountList);