diff --git a/src/components/FormItem/NetworkSelect/index.jsx b/src/components/FormItem/NetworkSelect/index.jsx index 155762e5..5eb4eb88 100644 --- a/src/components/FormItem/NetworkSelect/index.jsx +++ b/src/components/FormItem/NetworkSelect/index.jsx @@ -291,33 +291,26 @@ export default class NetworkSelect extends React.Component { } renderIp() { - const { subnet, subnets, ipType, ip } = this.state; - if (!subnet) { + const { subnet, subnets, ipType, ip, network } = this.state; + if (!network) { return null; } - const item = subnets.find((it) => it.id === subnet); - if (!item) { - return null; - } - const totalAllocationPools = []; - subnets.forEach((sub) => { - const { allocation_pools: pools = [] } = sub; - pools.forEach((pool) => { - totalAllocationPools.push(pool); - }); - }); - const { allocation_pools: pools } = item; - const details = totalAllocationPools.map((pool, index) => ( - - {pool.start}--{pool.end} - - )); - const detailsDiv = pools.map((pool, index) => ( -
- {pool.start}--{pool.end} -
- )); if (ipType === 0) { + const totalAllocationPools = []; + const subnetsForCurrentNetwork = subnets.filter( + (s) => s.network_id === network + ); + subnetsForCurrentNetwork.forEach((sub) => { + const { allocation_pools: pools = [] } = sub; + pools.forEach((pool) => { + totalAllocationPools.push(pool); + }); + }); + const details = totalAllocationPools.map((pool, index) => ( + + {pool.start}--{pool.end} + + )); const tips = ( {t('Allocation Pools')}: @@ -326,6 +319,20 @@ export default class NetworkSelect extends React.Component { ); return {tips}; } + if (!subnet) { + return null; + } + const item = subnets.find((it) => it.id === subnet); + if (!item) { + return null; + } + const { allocation_pools: pools } = item; + + const detailsDiv = pools.map((pool, index) => ( +
+ {pool.start}--{pool.end} +
+ )); const tips = ( {t('Allocation Pools')}: diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx index 0d1e1bf8..a5241ff9 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/NetworkStep/index.jsx @@ -260,6 +260,7 @@ export class NetworkStep extends Base { } return Promise.resolve(); }, + wrapperCol: { span: 19 }, }, { name: 'divider1',