From b3d8ce20415ed27e5a22ed8ef227475b8c5044d9 Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Thu, 29 Mar 2018 17:19:38 +0200 Subject: [PATCH] feat(xo-web/new-vm): hide IP field if IP pools are not configured (#2811) Fixes #2739 --- packages/xo-web/src/xo-app/new-vm/index.js | 73 ++++++++++------------ 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/packages/xo-web/src/xo-app/new-vm/index.js b/packages/xo-web/src/xo-app/new-vm/index.js index 53e08692d..ec172be5b 100644 --- a/packages/xo-web/src/xo-app/new-vm/index.js +++ b/packages/xo-web/src/xo-app/new-vm/index.js @@ -41,6 +41,7 @@ import { createVms, getCloudInitConfig, subscribeCurrentUser, + subscribeIpPools, subscribePermissions, subscribeResourceSets, XEN_DEFAULT_CPU_CAP, @@ -115,12 +116,21 @@ const Item = ({ label, children, className }) => ( ) +@addSubscriptions({ + // eslint-disable-next-line standard/no-callback-literal + ipPoolsConfigured: cb => subscribeIpPools(ipPools => cb(ipPools.length > 0)), +}) @injectIntl class Vif extends BaseComponent { + _getIpPoolPredicate = createSelector( + () => this.props.vif, + vif => ipPool => includes(ipPool.networks, vif.network) + ) + render () { const { intl: { formatMessage }, - ipPoolPredicate, + ipPoolsConfigured, networkPredicate, onChangeAddresses, onChangeMac, @@ -159,26 +169,28 @@ class Vif extends BaseComponent { )} - - - {pool ? ( - - ) : ( - - )} - - + {ipPoolsConfigured && ( + + + {pool ? ( + + ) : ( + + )} + + + )}