diff --git a/src/components/ComputeForm.js b/src/components/ComputeForm.js index fba04c6..ca84f6d 100644 --- a/src/components/ComputeForm.js +++ b/src/components/ComputeForm.js @@ -27,7 +27,7 @@ const initialState = { vCPU: 1, disk: 20, memory: 1024, - networkIds: '', + networkIds: [], federatedNetworkId: '', scriptType: '', publicKey: '', @@ -70,9 +70,16 @@ class ComputeForm extends Component { let { name, value } = event.target; if (name === 'networkIds') { - // NOTE(pauloewerton): this will work only with a single network id + let networkIds = this.state.networkIds || []; + + if (networkIds.includes(value)) { + networkIds.pop(value); + } else { + networkIds.push(value); + } + this.setState({ - [name]: [value] + 'networkIds': networkIds }); } else { this.setState({ @@ -286,22 +293,22 @@ class ComputeForm extends Component { onAddRequirement={this.addRequirement} onResetRequirements={this.resetRequirements}/> - - + + : undefined + ; }) : undefined } - +