feat(xo-web/new-vm): hide IP field if IP pools are not configured (#2811)
Fixes #2739
This commit is contained in:
parent
b47789bf82
commit
b3d8ce2041
@ -41,6 +41,7 @@ import {
|
|||||||
createVms,
|
createVms,
|
||||||
getCloudInitConfig,
|
getCloudInitConfig,
|
||||||
subscribeCurrentUser,
|
subscribeCurrentUser,
|
||||||
|
subscribeIpPools,
|
||||||
subscribePermissions,
|
subscribePermissions,
|
||||||
subscribeResourceSets,
|
subscribeResourceSets,
|
||||||
XEN_DEFAULT_CPU_CAP,
|
XEN_DEFAULT_CPU_CAP,
|
||||||
@ -115,12 +116,21 @@ const Item = ({ label, children, className }) => (
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@addSubscriptions({
|
||||||
|
// eslint-disable-next-line standard/no-callback-literal
|
||||||
|
ipPoolsConfigured: cb => subscribeIpPools(ipPools => cb(ipPools.length > 0)),
|
||||||
|
})
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class Vif extends BaseComponent {
|
class Vif extends BaseComponent {
|
||||||
|
_getIpPoolPredicate = createSelector(
|
||||||
|
() => this.props.vif,
|
||||||
|
vif => ipPool => includes(ipPool.networks, vif.network)
|
||||||
|
)
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
intl: { formatMessage },
|
intl: { formatMessage },
|
||||||
ipPoolPredicate,
|
ipPoolsConfigured,
|
||||||
networkPredicate,
|
networkPredicate,
|
||||||
onChangeAddresses,
|
onChangeAddresses,
|
||||||
onChangeMac,
|
onChangeMac,
|
||||||
@ -159,18 +169,19 @@ class Vif extends BaseComponent {
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</Item>
|
</Item>
|
||||||
|
{ipPoolsConfigured && (
|
||||||
<LineItem>
|
<LineItem>
|
||||||
<span className={styles.inlineSelect}>
|
<span className={styles.inlineSelect}>
|
||||||
{pool ? (
|
{pool ? (
|
||||||
<SelectIp
|
<SelectIp
|
||||||
containerPredicate={ipPoolPredicate}
|
containerPredicate={this._getIpPoolPredicate()}
|
||||||
multi
|
multi
|
||||||
onChange={onChangeAddresses}
|
onChange={onChangeAddresses}
|
||||||
value={vif.addresses}
|
value={vif.addresses}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<SelectResourceSetIp
|
<SelectResourceSetIp
|
||||||
containerPredicate={ipPoolPredicate}
|
containerPredicate={this._getIpPoolPredicate()}
|
||||||
multi
|
multi
|
||||||
onChange={onChangeAddresses}
|
onChange={onChangeAddresses}
|
||||||
resourceSetId={resourceSet.id}
|
resourceSetId={resourceSet.id}
|
||||||
@ -179,6 +190,7 @@ class Vif extends BaseComponent {
|
|||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
</LineItem>
|
</LineItem>
|
||||||
|
)}
|
||||||
<Item>
|
<Item>
|
||||||
<Button onClick={onDelete}>
|
<Button onClick={onDelete}>
|
||||||
<Icon icon='new-vm-remove' />
|
<Icon icon='new-vm-remove' />
|
||||||
@ -531,25 +543,6 @@ export default class NewVm extends BaseComponent {
|
|||||||
poolId => sr =>
|
poolId => sr =>
|
||||||
(poolId == null || poolId === sr.$pool) && sr.SR_type === 'iso'
|
(poolId == null || poolId === sr.$pool) && sr.SR_type === 'iso'
|
||||||
)
|
)
|
||||||
_getIpPoolPredicate = createSelector(
|
|
||||||
() => !!this.props.pool,
|
|
||||||
() => {
|
|
||||||
const { resourceSet } = this.props
|
|
||||||
return resourceSet && resourceSet.ipPools
|
|
||||||
},
|
|
||||||
() => this.props.vif,
|
|
||||||
(pool, ipPools, vif) => ipPool => {
|
|
||||||
if (!ipPool) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
pool ||
|
|
||||||
(ipPools &&
|
|
||||||
includes(ipPools, ipPool.id) &&
|
|
||||||
find(ipPool.networks, ipPoolNetwork => ipPoolNetwork === vif.network))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
_getNetworkPredicate = createSelector(
|
_getNetworkPredicate = createSelector(
|
||||||
this._getIsInPool,
|
this._getIsInPool,
|
||||||
this._getIsInResourceSet,
|
this._getIsInResourceSet,
|
||||||
|
Loading…
Reference in New Issue
Block a user