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}/> - Network ID - - Choose a network - { - this.props.networks.loading ? + Networks + + { !this.state.provider || !this.state.cloudName ? No cloud or provider selected : undefined } + { this.props.networks.loading ? this.props.networks.data.map((network, idx) => { return network.provider === this.state.provider && network.cloudName === this.state.cloudName ? - - {network.instanceId} - : - undefined; }) : + + { console.log(network) } + + {network.instanceName} + : undefined + ; }) : undefined } - + Federated Network ID