2 * Copyright © 2016-2018 European Support Limited
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.
17 import React from 'react';
18 import PropTypes from 'prop-types';
19 import i18n from 'nfvo-utils/i18n/i18n.js';
20 import Form from 'nfvo-components/input/validation/Form.jsx';
21 import Input from 'nfvo-components/input/validation/Input.jsx';
22 import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js';
24 class VendorSelector extends React.Component {
26 finalizedLicenseModelList: PropTypes.array,
27 vendorName: PropTypes.string,
28 onClose: PropTypes.func.isRequired,
29 onConfirm: PropTypes.func.isRequired
33 const selectedValue = props.finalizedLicenseModelList.length ? props.finalizedLicenseModelList[0].id : '';
39 const vendor = this.props.finalizedLicenseModelList.find(item => item.id === this.state.selectedValue);
40 this.props.onConfirm(vendor.id);
44 const {finalizedLicenseModelList, vendorName, onClose} = this.props;
45 const {selectedValue} = this.state;
47 <div className='vsp-details-vendor-select'>
49 onSubmit={() => this.submit()}
50 onReset={() => onClose()}
51 isValid = {!!selectedValue}
52 submitButtonText={i18n('Save')}
54 <div className='vendor-selector-modal-title'>{`${i18n('The VLM')} '${vendorName}' ${i18n('assigned to this VSP is archived')}.`}</div>
55 <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>
57 data-test-id='vsp-vendor-name-select'
58 label={i18n('Vendor')}
60 onChange={e => {this.setState({
61 selectedValue: e.target.options[e.target.selectedIndex].value
63 value={selectedValue}>
64 <option key='emtyVendor' value=''>{i18n('please select...')}</option>
65 {sortByStringProperty(
66 finalizedLicenseModelList,
68 ).map(lm => <option key={lm.id} value={lm.id}>{lm.name}</option>)
77 export default VendorSelector;