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 {Collapse} from 'react-bootstrap';
18 import LicenseAgreement from './listItems/LicenseAgreement.jsx';
19 import EntitlementPool from './listItems/EntitlementPool.jsx';
20 import FeatureGroup from './listItems/FeatureGroup.jsx';
21 import LicenseKeyGroup from './listItems/LicenseKeyGroup.jsx';
22 import {overviewEditorHeaders} from './LicenseModelOverviewConstants.js';
24 class VLMListView extends Component {
27 licensingDataList: React.PropTypes.array,
28 showInUse: React.PropTypes.bool
36 let {licensingDataList = []} = this.props;
38 <div className='vlm-list-view'>
40 <ul className='vlm-list' data-test-id='vlm-list'>
41 {licensingDataList.map(item => this.renderLicensingItem(item))}
48 renderLicensingItem(item) {
49 switch (item.itemType) {
50 case overviewEditorHeaders.LICENSE_AGREEMENT :
51 return this.renderLicenseAgreementItem(item);
52 case overviewEditorHeaders.FEATURE_GROUP :
53 return this.renderFeatureGroupItem(item);
54 case overviewEditorHeaders.LICENSE_KEY_GROUP :
55 return this.renderLicenseKeyGroupItem(item);
56 case overviewEditorHeaders.ENTITLEMENT_POOL:
57 return this.renderEntitlementPoolItem(item);
63 renderLicenseAgreementItem(licenseAgreement) {
65 <li key={licenseAgreement.id}>
67 laData={licenseAgreement}
68 isCollapsed={this.state[licenseAgreement.id]}
69 onClick={event => this.updateCollapsable(event, licenseAgreement.id) }/>
70 <Collapse in={this.state[licenseAgreement.id]}>
72 {licenseAgreement.children && licenseAgreement.children.map(item => this.renderLicensingItem(item))}
79 renderFeatureGroupItem(featureGroup) {
80 const {showInUse} = this.props;
82 <li key={featureGroup.id}>
85 isCollapsed={this.state[featureGroup.id]}
86 onClick={event=> this.updateCollapsable(event, featureGroup.id) }/>
88 showInUse && <Collapse in={this.state[featureGroup.id]}>
90 {featureGroup.children && featureGroup.children.map(item => this.renderLicensingItem(item))}
99 renderEntitlementPoolItem(entitlementPool) {
101 <li key={entitlementPool.id}>
102 <EntitlementPool epData={entitlementPool} />
107 renderLicenseKeyGroupItem(licenseKeyGroup) {
109 <li key={licenseKeyGroup.id}>
110 <LicenseKeyGroup lkgData={licenseKeyGroup} />
115 updateCollapsable(event, id) {
116 event.stopPropagation();
118 obj[id] = !this.state[id];
123 export default VLMListView;