import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; import objectValues from 'lodash/values.js'; import LicenseModelCreation from './licenseModel/creation/LicenseModelCreation.js'; import SoftwareProductCreation from './softwareProduct/creation/SoftwareProductCreation.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import classnames from 'classnames'; import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; export const catalogItemTypes = Object.freeze({ LICENSE_MODEL: 'license-model', SOFTWARE_PRODUCT: 'software-product' }); const catalogItemTypeClasses = { LICENSE_MODEL: 'license-model-type', SOFTWARE_PRODUCT: 'software-product-type' }; class OnboardingCatalogView extends React.Component { constructor(props) { super(props); this.state = {searchValue: ''}; this.handleSearch = this.handleSearch.bind(this); } handleSearch(event){ this.setState({searchValue: event.target.value}); } static propTypes = { licenseModelList: React.PropTypes.array, softwareProductList: React.PropTypes.array, modalToShow: React.PropTypes.oneOf(objectValues(catalogItemTypes)), onSelectLicenseModel: React.PropTypes.func.isRequired, onSelectSoftwareProduct: React.PropTypes.func.isRequired, onAddLicenseModelClick: React.PropTypes.func.isRequired, onAddSoftwareProductClick: React.PropTypes.func.isRequired }; getModalDetails() { const {modalToShow} = this.props; switch (modalToShow) { case catalogItemTypes.LICENSE_MODEL: return { title: i18n('New License Model'), element: }; case catalogItemTypes.SOFTWARE_PRODUCT: return { title: i18n('New Software Product'), element: }; } } render() { const modalDetails = this.getModalDetails(); const {licenseModelList, softwareProductList, onSelectLicenseModel, onSelectSoftwareProduct, onAddLicenseModelClick, onAddSoftwareProductClick, modalToShow} = this.props; return (
{i18n('Onboarding Catalog')}
{i18n('ADD')}
onAddLicenseModelClick()}>{i18n('New License Model')}
onAddSoftwareProductClick()}>{i18n('New Vendor Software Product')}
{licenseModelList.filter(vlm => vlm.vendorName.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) > -1).map(licenseModel => this.renderTile( { ...licenseModel, name: licenseModel.vendorName }, catalogItemTypeClasses.LICENSE_MODEL, () => onSelectLicenseModel(licenseModel)) )} {softwareProductList.filter(vsp => vsp.name.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) > -1).map(softwareProduct => this.renderTile(softwareProduct, catalogItemTypeClasses.SOFTWARE_PRODUCT, () => onSelectSoftwareProduct(softwareProduct)) )}
{modalDetails && modalDetails.title} { modalDetails && modalDetails.element }
); } getCatalogItemTypeClassByItemType(catalogItemType) { switch (catalogItemType) { case catalogItemTypes.LICENSE_MODEL: return catalogItemTypeClasses.LICENSE_MODEL; case catalogItemTypes.SOFTWARE_PRODUCT: return catalogItemTypeClasses.SOFTWARE_PRODUCT; } } renderTile(catalogItemData, catalogItemTypeClass, onSelect) { let {status: itemStatus} = VersionControllerUtils.getCheckOutStatusKindByUserID(catalogItemData.status, catalogItemData.lockingUser); return (
onSelect()}>
{catalogItemData.name}
V {catalogItemData.version}
); } } export default OnboardingCatalogView;