1 import React from 'react';
2 import i18n from 'nfvo-utils/i18n/i18n.js';
3 import Input from 'nfvo-components/input/validation/Input.jsx';
4 import Form from 'nfvo-components/input/validation/Form.jsx';
5 import GridSection from 'nfvo-components/grid/GridSection.jsx';
6 import GridItem from 'nfvo-components/grid/GridItem.jsx';
7 import SelectInput from 'nfvo-components/input/SelectInput.jsx';
8 import SelectActionTable from 'nfvo-components/table/SelectActionTable.jsx';
9 import SelectActionTableRow from 'nfvo-components/table/SelectActionTableRow.jsx';
10 import SelectActionTableCell from 'nfvo-components/table/SelectActionTableCell.jsx';
11 import Validator from 'nfvo-utils/Validator.js';
13 export default class SoftwareProductDeploymentEditorView extends React.Component {
21 selectedFeatureGroupsList,
30 componentComputeAssociations = []
32 let featureGroupsExist = selectedFeatureGroupsList.length > 0;
35 {genericFieldInfo && (
40 isReadOnlyMode={isReadOnlyMode}
41 onSubmit={() => this.submit()}
43 isEdit ? i18n('Save') : i18n('Create')
45 onReset={() => onClose()}
46 onValidateForm={() => this.validate()}
47 isValid={this.props.isFormValid}
48 formReady={this.props.formReady}
49 className="vsp-deployment-editor">
50 <GridSection hasLastColSet>
51 <GridItem colSpan={1}>
58 this.validateName(model)
64 data-test-id="deployment-model"
65 isValid={genericFieldInfo.model.isValid}
66 errorText={genericFieldInfo.model.errorText}
71 <GridItem colSpan={3} lastColInRow>
73 onChange={description =>
74 onDataChanged({ description })
76 label={i18n('Description')}
78 data-test-id="deployment-description"
80 genericFieldInfo.description.isValid
83 genericFieldInfo.description.errorText
90 className={`deployment-feature-groups-section${
91 !featureGroupsExist ? ' no-feature-groups' : ''
93 title={i18n('License Details')}
95 <GridItem colSpan={1}>
97 data-test-id="deployment-feature-groups"
98 label={i18n('Feature Group')}
99 value={featureGroupId}
100 onChange={featureGroup =>
102 featureGroupId: featureGroup
110 isReadOnlyMode || !featureGroupsExist
112 className="field-section"
113 options={selectedFeatureGroupsList}
117 {!featureGroupsExist && (
118 <GridSection className="deployment-feature-group-warning-section">
119 <GridItem colSpan={3}>
122 'Please assign Feature Groups in VSP General'
129 title={i18n('Assign VFCs and Compute Flavors')}
130 className="vfc-table"
132 <GridItem colSpan={4} lastColInRow>
135 'Virtual Function Components',
139 {componentComputeAssociations.map(
140 (association, index) => (
141 <SelectActionTableRow
142 key={association.componentId}>
143 <SelectActionTableCell
144 options={componentsList.map(
148 component.displayName
152 association.componentId
154 onChange={componentId => {
155 let newAssociations = [
156 ...componentComputeAssociations
167 componentComputeAssociations: newAssociations
172 <SelectActionTableCell
173 options={computesList
176 compute.componentId ===
177 association.componentId
181 compute.computeFlavorId,
185 association.computeFlavorId
187 onChange={computeFlavorId => {
188 let newAssociations = [
189 ...componentComputeAssociations
200 componentComputeAssociations: newAssociations
203 disabled={isReadOnlyMode}
205 </SelectActionTableRow>
217 validateName(value) {
218 const { data: { id = '' }, DFNames } = this.props;
219 const isExists = Validator.isItemNameAlreadyExistsInList({
226 ? { isValid: true, errorText: '' }
230 "Deployment flavor by the name '" +
232 "' already exists. Deployment flavor name must be unique"
238 let { isEdit, onCreate, onEdit, onClose, data } = this.props;
248 this.props.onValidateForm();