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, {Component} from 'react';
17 import PropTypes from 'prop-types';
18 import {Collapse} from 'react-bootstrap';
19 import LicenseAgreement from './listItems/LicenseAgreement.jsx';
20 import EntitlementPool from './listItems/EntitlementPool.jsx';
21 import FeatureGroup from './listItems/FeatureGroup.jsx';
22 import LicenseKeyGroup from './listItems/LicenseKeyGroup.jsx';
23 import {overviewEditorHeaders} from './LicenseModelOverviewConstants.js';
25 class VLMListView extends Component {
28 licensingDataList: PropTypes.array,
29 showInUse: PropTypes.bool
37 let {licensingDataList = []} = this.props;
39 <div className='vlm-list-view'>
41 <ul className='vlm-list' data-test-id='vlm-list'>
42 {licensingDataList.map(item => this.renderLicensingItem(item))}
49 renderLicensingItem(item) {
50 switch (item.itemType) {
51 case overviewEditorHeaders.LICENSE_AGREEMENT :
52 return this.renderLicenseAgreementItem(item);
53 case overviewEditorHeaders.FEATURE_GROUP :
54 return this.renderFeatureGroupItem(item);
55 case overviewEditorHeaders.LICENSE_KEY_GROUP :
56 return this.renderLicenseKeyGroupItem(item);
57 case overviewEditorHeaders.ENTITLEMENT_POOL:
58 return this.renderEntitlementPoolItem(item);
64 renderLicenseAgreementItem(licenseAgreement) {
66 <li key={licenseAgreement.id}>
68 laData={licenseAgreement}
69 isCollapsed={this.state[licenseAgreement.id]}
70 onClick={event => this.updateCollapsable(event, licenseAgreement.id) }
71 isOrphan={!this.props.showInUse}/>
72 <Collapse in={this.state[licenseAgreement.id]}>
74 {licenseAgreement.children && licenseAgreement.children.map(item => this.renderLicensingItem(item))}
81 renderFeatureGroupItem(featureGroup) {
82 const {showInUse} = this.props;
84 <li key={featureGroup.id}>
87 isCollapsed={this.state[featureGroup.id]}
88 onClick={event=> this.updateCollapsable(event, featureGroup.id) }
89 isOrphan={!this.props.showInUse}/>
91 showInUse && <Collapse in={this.state[featureGroup.id]}>
93 {featureGroup.children && featureGroup.children.map(item => this.renderLicensingItem(item))}
102 renderEntitlementPoolItem(entitlementPool) {
104 <li key={entitlementPool.id}>
105 <EntitlementPool epData={entitlementPool} isOrphan={!this.props.showInUse}/>
110 renderLicenseKeyGroupItem(licenseKeyGroup) {
112 <li key={licenseKeyGroup.id}>
113 <LicenseKeyGroup lkgData={licenseKeyGroup} isOrphan={!this.props.showInUse}/>
118 updateCollapsable(event, id) {
119 event.stopPropagation();
121 obj[id] = !this.state[id];
126 export default VLMListView;