diff options
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/details')
3 files changed, 160 insertions, 25 deletions
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 ( + <div className='vsp-details-vendor-select'> + <Form + onSubmit={() => this.submit()} + onReset={() => onClose()} + isValid = {!!selectedValue} + submitButtonText={i18n('Save')} + hasButtons={true}> + <div className='vendor-selector-modal-title'>{`${i18n('The VLM')} '${vendorName}' ${i18n('assigned to this VSP is archived')}.`}</div> + <div className='vendor-selector-modal-additional-text'>{i18n('If you select a different VLM you will not be able to reselect the archived VLM.')}</div> + <Input + data-test-id='vsp-vendor-name-select' + label={i18n('Vendor')} + type='select' + onChange={e => {this.setState({ + selectedValue: e.target.options[e.target.selectedIndex].value + });}} + value={selectedValue}> + <option key='emtyVendor' value=''>{i18n('please select...')}</option> + {sortByStringProperty( + finalizedLicenseModelList, + 'name' + ).map(lm => <option key={lm.id} value={lm.id}>{lm.name}</option>) + } + </Input> + </Form> + </div> + ); + } +} + +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 ( + <div className='depricated-vlm-info'> + <Input + data-test-id='vsp-vendor-name' + isRequired={true} + onClick={() => onVendorRemove()} + label={i18n('Vendor')} + type='select' + value={`${vendorName} (Archived)`}> + <option key={vendorName} value={`${vendorName} (Archived)`}>{`${vendorName} (Archived)`}</option> + </Input> + </div> + ); +}; + 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)}/> - <Input - data-test-id='vsp-vendor-name' - label={i18n('Vendor')} - type='select' - value={this.props.vendorId} - onChange={e => this.onVendorParamChanged(e)}> - {sortByStringProperty( - this.props.finalizedLicenseModelList, - 'name' - ).map(lm => <option key={lm.id} value={lm.id}>{lm.name}</option>) - } - </Input> + {this.props.isVendorArchived ? + <DeprecatedVlmInfo onVendorRemove={()=>this.onVendorRemove()} vendorName={this.props.vendorName} /> : + <Input + data-test-id='vsp-vendor-name' + label={i18n('Vendor')} + type='select' + value={this.props.vendorId} + onChange={e => this.onVendorParamChanged(e)}> + {sortByStringProperty( + this.props.finalizedLicenseModelList, + 'name' + ).map(lm => <option key={lm.id} value={lm.id}>{lm.name}</option>) + } + </Input> + } <Input data-test-id='vsp-category-name' label={i18n('Category')} @@ -127,7 +152,8 @@ class LicensesSection extends React.Component { onFeatureGroupsChanged: PropTypes.func.isRequired, onLicensingDataChanged: PropTypes.func.isRequired, featureGroupsList: PropTypes.array, - licenseAgreementList: PropTypes.array + licenseAgreementList: PropTypes.array, + isVendorArchived: PropTypes.bool }; onVendorParamChanged(e) { @@ -151,6 +177,7 @@ class LicensesSection extends React.Component { onChange={e => this.onVendorParamChanged(e)} value={this.props.licensingVersion || ''} label={i18n('Licensing Version')} + disabled={this.props.isVendorArchived} type='select'> {this.props.licensingVersionsList.map(version => <option @@ -165,6 +192,7 @@ class LicensesSection extends React.Component { data-test-id='vsp-license-agreement' label={i18n('License Agreement')} type='select' + disabled={this.props.isVendorArchived} value={this.props.licensingData.licenseAgreement ? this.props.licensingData.licenseAgreement : '' } onChange={(e) => this.onLicensingDataChanged(e)}> <option key='placeholder' value=''>{i18n('Select...')}</option> @@ -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, |