From 091edfdac90f66d91caff1b93131f99ba74f9aeb Mon Sep 17 00:00:00 2001 From: svishnev Date: Mon, 19 Mar 2018 12:15:19 +0200 Subject: ui support for archive items Issue-ID: SDC-1088 Change-Id: I836e4896a8ec6bb065f9d2571f514916ccf6759f Signed-off-by: svishnev --- .../details/SoftwareProductDetails.js | 30 +++++++-- .../SoftwareProductDetailsVendorSelector.jsx | 78 ++++++++++++++++++++++ .../details/SoftwareProductDetailsView.jsx | 77 +++++++++++++++------ 3 files changed, 160 insertions(+), 25 deletions(-) create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/details') diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js index b7ddf134bb..0973537d43 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,18 @@ * permissions and limitations under the License. */ import {connect} from 'react-redux'; - +import i18n from 'nfvo-utils/i18n/i18n.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import SoftwareProductDetailsView from './SoftwareProductDetailsView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import {PRODUCT_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; - +import {actionTypes as modalActionTypes, modalSizes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; export const mapStateToProps = ({ finalizedLicenseModelList, + archivedLicenseModelList, softwareProduct, licenseModel: {licenseAgreement, featureGroup} }) => { @@ -44,7 +47,7 @@ export const mapStateToProps = ({ let {qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap} = softwareProductQuestionnaire; let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - + const isVendorArchived = archivedLicenseModelList.find(item => item.id === currentSoftwareProduct.vendorId); return { currentSoftwareProduct, softwareProductCategories, @@ -56,7 +59,8 @@ export const mapStateToProps = ({ isFormValid, genericFieldInfo, qGenericFieldInfo, - dataMap + dataMap, + isVendorArchived: !!isVendorArchived }; }; @@ -67,7 +71,21 @@ export const mapActionsToProps = (dispatch, {version}) => { onVendorParamChanged: (deltaData, formName) => SoftwareProductActionHelper.softwareProductEditorVendorChanged(dispatch, {deltaData, formName}), onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: PRODUCT_QUESTIONNAIRE}), onValidityChanged: isValidityData => SoftwareProductActionHelper.setIsValidityData(dispatch, {isValidityData}), - onSubmit: (softwareProduct, qdata) => SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata, version}) + onSubmit: (softwareProduct, qdata) => SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata, version}), + onArchivedVendorRemove: ({onVendorParamChanged, finalizedLicenseModelList, vendorName}) => dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data:{ + title: i18n('Change Archived VLM'), + modalComponentName: modalContentMapper.VENDOR_SELECTOR, + modalComponentProps: { + size: modalSizes.MEDIUM, + finalizedLicenseModelList, + vendorName, + onClose: () => dispatch({type: modalActionTypes.GLOBAL_MODAL_CLOSE}), + onConfirm: (vendorId) => onVendorParamChanged({vendorId}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS) + } + } + }) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx new file mode 100644 index 0000000000..c2a3e0bd02 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx @@ -0,0 +1,78 @@ +/*! + * Copyright © 2016-2018 European Support Limited + * + * 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 from 'react'; +import PropTypes from 'prop-types'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; + +class VendorSelector extends React.Component { + static propTypes = { + finalizedLicenseModelList: PropTypes.array, + vendorName: PropTypes.string, + onClose: PropTypes.func.isRequired, + onConfirm: PropTypes.func.isRequired + } + constructor(props){ + super(props); + const selectedValue = props.finalizedLicenseModelList.length ? props.finalizedLicenseModelList[0].id : ''; + this.state = { + selectedValue + }; + } + submit() { + const vendor = this.props.finalizedLicenseModelList.find(item => item.id === this.state.selectedValue); + this.props.onConfirm(vendor.id); + this.props.onClose(); + } + render() { + const {finalizedLicenseModelList, vendorName, onClose} = this.props; + const {selectedValue} = this.state; + return ( +
+
this.submit()} + onReset={() => onClose()} + isValid = {!!selectedValue} + submitButtonText={i18n('Save')} + hasButtons={true}> +
{`${i18n('The VLM')} '${vendorName}' ${i18n('assigned to this VSP is archived')}.`}
+
{i18n('If you select a different VLM you will not be able to reselect the archived VLM.')}
+ {this.setState({ + selectedValue: e.target.options[e.target.selectedIndex].value + });}} + value={selectedValue}> + + {sortByStringProperty( + finalizedLicenseModelList, + 'name' + ).map(lm => ) + } + +
+
+ ); + } +} + +export default VendorSelector; + diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx index f6199ec83e..24aa319c24 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -1,5 +1,5 @@ /*! - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,22 @@ import GridItem from 'nfvo-components/grid/GridItem.jsx'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +const DeprecatedVlmInfo = ({vendorName, onVendorRemove}) => { + return ( +
+ onVendorRemove()} + label={i18n('Vendor')} + type='select' + value={`${vendorName} (Archived)`}> + + +
+ ); +}; + class GeneralSection extends React.Component { static propTypes = { vendorId: PropTypes.string, @@ -36,7 +52,9 @@ class GeneralSection extends React.Component { finalizedLicenseModelList: PropTypes.array, onDataChanged: PropTypes.func.isRequired, onVendorParamChanged: PropTypes.func.isRequired, - onSelectSubCategory: PropTypes.func.isRequired + onSelectSubCategory: PropTypes.func.isRequired, + isVendorArchived: PropTypes.bool, + onArchivedVendorRemove: PropTypes.func }; onVendorParamChanged(e) { @@ -51,6 +69,10 @@ class GeneralSection extends React.Component { const subCategory = e.target.options[selectedIndex].value; this.props.onSelectSubCategory(subCategory); } + onVendorRemove() { + const {finalizedLicenseModelList, vendorName, onVendorParamChanged} = this.props; + this.props.onArchivedVendorRemove({finalizedLicenseModelList, onVendorParamChanged, vendorName}); + } render (){ let {genericFieldInfo} = this.props; @@ -67,18 +89,21 @@ class GeneralSection extends React.Component { errorText={genericFieldInfo.name.errorText} isValid={genericFieldInfo.name.isValid} onChange={name => name.length <= 25 && this.props.onDataChanged({name}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS)}/> - this.onVendorParamChanged(e)}> - {sortByStringProperty( - this.props.finalizedLicenseModelList, - 'name' - ).map(lm => ) - } - + {this.props.isVendorArchived ? + this.onVendorRemove()} vendorName={this.props.vendorName} /> : + this.onVendorParamChanged(e)}> + {sortByStringProperty( + this.props.finalizedLicenseModelList, + 'name' + ).map(lm => ) + } + + } this.onVendorParamChanged(e)} value={this.props.licensingVersion || ''} label={i18n('Licensing Version')} + disabled={this.props.isVendorArchived} type='select'> {this.props.licensingVersionsList.map(version => @@ -178,6 +206,7 @@ class LicensesSection extends React.Component { type='select' isMultiSelect={true} onInputChange={()=>{}} + disabled={this.props.isVendorArchived} onEnumChange={featureGroups => this.props.onFeatureGroupsChanged({featureGroups})} multiSelectedEnum={this.props.licensingData.featureGroups} name='feature-groups' @@ -295,8 +324,8 @@ class SoftwareProductDetails extends Component { }; prepareDataForGeneralSection(){ - let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, currentSoftwareProduct, genericFieldInfo} = this.props; - let {name, description, vendorId, subCategory} = currentSoftwareProduct; + let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, currentSoftwareProduct, genericFieldInfo, isVendorArchived, onArchivedVendorRemove} = this.props; + let {name, description, vendorId, subCategory, vendorName} = currentSoftwareProduct; return { name, description, @@ -307,13 +336,16 @@ class SoftwareProductDetails extends Component { onDataChanged, onVendorParamChanged: args => this.onVendorParamChanged(args), onSelectSubCategory: args => this.onSelectSubCategory(args), - genericFieldInfo + genericFieldInfo, + vendorName, + isVendorArchived, + onArchivedVendorRemove }; } prepareDataForLicensesSection(){ - let { featureGroupsList, licenseAgreementList, currentSoftwareProduct } = this.props; + let { featureGroupsList, licenseAgreementList, currentSoftwareProduct, isVendorArchived} = this.props; let {vendorId, licensingVersion, licensingData = {}} = currentSoftwareProduct; return { onVendorParamChanged: args => this.onVendorParamChanged(args), @@ -325,6 +357,7 @@ class SoftwareProductDetails extends Component { onLicensingDataChanged: args => this.onLicensingDataChanged(args), featureGroupsList, licenseAgreementList, + isVendorArchived }; } @@ -356,11 +389,17 @@ class SoftwareProductDetails extends Component { } onVendorParamChanged({vendorId, licensingVersion}) { + let {finalizedLicenseModelList, onVendorParamChanged} = this.props; if(!licensingVersion) { const licensingVersionsList = this.buildLicensingVersionsListItems(); licensingVersion = licensingVersionsList[0].enum; } + + if (!vendorId) { + vendorId = finalizedLicenseModelList[0].id; + } + let vendorName = finalizedLicenseModelList.find(licenseModelItem => licenseModelItem.id === vendorId).name || ''; let deltaData = { vendorId, -- cgit 1.2.3-korg