/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Collapse } from 'react-bootstrap';
import LicenseAgreement from './listItems/LicenseAgreement.jsx';
import EntitlementPool from './listItems/EntitlementPool.jsx';
import FeatureGroup from './listItems/FeatureGroup.jsx';
import LicenseKeyGroup from './listItems/LicenseKeyGroup.jsx';
import { overviewEditorHeaders } from './LicenseModelOverviewConstants.js';
class VLMListView extends Component {
static propTypes = {
licensingDataList: PropTypes.array,
showInUse: PropTypes.bool
};
state = {};
render() {
let { licensingDataList = [] } = this.props;
return (
{licensingDataList.map(item =>
this.renderLicensingItem(item)
)}
);
}
renderLicensingItem(item) {
switch (item.itemType) {
case overviewEditorHeaders.LICENSE_AGREEMENT:
return this.renderLicenseAgreementItem(item);
case overviewEditorHeaders.FEATURE_GROUP:
return this.renderFeatureGroupItem(item);
case overviewEditorHeaders.LICENSE_KEY_GROUP:
return this.renderLicenseKeyGroupItem(item);
case overviewEditorHeaders.ENTITLEMENT_POOL:
return this.renderEntitlementPoolItem(item);
default:
return;
}
}
renderLicenseAgreementItem(licenseAgreement) {
return (
this.updateCollapsable(event, licenseAgreement.id)
}
isOrphan={!this.props.showInUse}
/>
{licenseAgreement.children &&
licenseAgreement.children.map(item =>
this.renderLicensingItem(item)
)}
);
}
renderFeatureGroupItem(featureGroup) {
const { showInUse } = this.props;
return (
this.updateCollapsable(event, featureGroup.id)
}
isOrphan={!this.props.showInUse}
/>
{showInUse && (
{featureGroup.children &&
featureGroup.children.map(item =>
this.renderLicensingItem(item)
)}
)}
);
}
renderEntitlementPoolItem(entitlementPool) {
return (
);
}
renderLicenseKeyGroupItem(licenseKeyGroup) {
return (
);
}
updateCollapsable(event, id) {
event.stopPropagation();
let obj = {};
obj[id] = !this.state[id];
this.setState(obj);
}
}
export default VLMListView;