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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import React from 'react';
17 import i18n from 'nfvo-utils/i18n/i18n.js';
18 import Input from 'nfvo-components/input/validation/Input.jsx';
19 import Form from 'nfvo-components/input/validation/Form.jsx';
20 import GridSection from 'nfvo-components/grid/GridSection.jsx';
21 import GridItem from 'nfvo-components/grid/GridItem.jsx';
22 import SelectInput from 'nfvo-components/input/SelectInput.jsx';
23 import SelectActionTable from 'nfvo-components/table/SelectActionTable.jsx';
24 import SelectActionTableRow from 'nfvo-components/table/SelectActionTableRow.jsx';
25 import SelectActionTableCell from 'nfvo-components/table/SelectActionTableCell.jsx';
26 import Validator from 'nfvo-utils/Validator.js';
28 export default class SoftwareProductDeploymentEditorView extends React.Component {
36 selectedFeatureGroupsList,
45 componentComputeAssociations = []
47 let featureGroupsExist = selectedFeatureGroupsList.length > 0;
50 {genericFieldInfo && (
55 isReadOnlyMode={isReadOnlyMode}
56 onSubmit={() => this.submit()}
58 isEdit ? i18n('Save') : i18n('Create')
60 onReset={() => onClose()}
61 onValidateForm={() => this.validate()}
62 isValid={this.props.isFormValid}
63 formReady={this.props.formReady}
64 className="vsp-deployment-editor"
65 btnClassName="sdc-modal__footer">
66 <GridSection hasLastColSet>
67 <GridItem colSpan={1}>
74 this.validateName(model)
80 data-test-id="deployment-model"
81 isValid={genericFieldInfo.model.isValid}
82 errorText={genericFieldInfo.model.errorText}
87 <GridItem colSpan={3} lastColInRow>
89 onChange={description =>
90 onDataChanged({ description })
92 label={i18n('Description')}
94 data-test-id="deployment-description"
96 genericFieldInfo.description.isValid
99 genericFieldInfo.description.errorText
106 className={`deployment-feature-groups-section${
107 !featureGroupsExist ? ' no-feature-groups' : ''
109 title={i18n('License Details')}
111 <GridItem colSpan={1}>
113 data-test-id="deployment-feature-groups"
114 label={i18n('Feature Group')}
115 value={featureGroupId}
116 onChange={featureGroup =>
118 featureGroupId: featureGroup
126 isReadOnlyMode || !featureGroupsExist
128 className="field-section"
129 options={selectedFeatureGroupsList}
133 {!featureGroupsExist && (
134 <GridSection className="deployment-feature-group-warning-section">
135 <GridItem colSpan={3}>
138 'Please assign Feature Groups in VSP General'
145 title={i18n('Assign VFCs and Compute Flavors')}
146 className="vfc-table"
148 <GridItem colSpan={4} lastColInRow>
151 'Virtual Function Components',
155 {componentComputeAssociations.map(
156 (association, index) => (
157 <SelectActionTableRow
158 key={association.componentId}>
159 <SelectActionTableCell
160 options={componentsList.map(
164 component.displayName
168 association.componentId
170 onChange={componentId => {
171 let newAssociations = [
172 ...componentComputeAssociations
183 componentComputeAssociations: newAssociations
188 <SelectActionTableCell
189 options={computesList
192 compute.componentId ===
193 association.componentId
197 compute.computeFlavorId,
201 association.computeFlavorId
203 onChange={computeFlavorId => {
204 let newAssociations = [
205 ...componentComputeAssociations
216 componentComputeAssociations: newAssociations
219 disabled={isReadOnlyMode}
221 </SelectActionTableRow>
233 validateName(value) {
234 const { data: { id = '' }, DFNames } = this.props;
235 const isExists = Validator.isItemNameAlreadyExistsInList({
242 ? { isValid: true, errorText: '' }
246 "Deployment flavor by the name '" +
248 "' already exists. Deployment flavor name must be unique"
254 let { isEdit, onCreate, onEdit, onClose, data } = this.props;
264 this.props.onValidateForm();