feat(xo-web/pool): disable Rolling Pool Update if pool has 1 host (#7286)

See #6415
This commit is contained in:
MlssFrncJrg 2024-01-22 11:04:38 +01:00 committed by GitHub
parent 47922dee56
commit 51c11c15a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -35,6 +35,7 @@
- [File restore] Fix potential race condition in partition mount/unmount (PR [#7312](https://github.com/vatesfr/xen-orchestra/pull/7312))
- [Modal] Fix opened modal not closing when navigating to another route/URL (PR [#7301](https://github.com/vatesfr/xen-orchestra/pull/7301))
- [Backup/Restore] Don't count memory as a key (i.e. complete) disk [Forum#8212](https://xcp-ng.org/forum/post/69591) (PR [#7315](https://github.com/vatesfr/xen-orchestra/pull/7315))
- [Pool/patches] Disable Rolling Pool Update button if host is alone in its pool [#6415](https://github.com/vatesfr/xen-orchestra/issues/6415) (PR [#7286](https://github.com/vatesfr/xen-orchestra/pull/7286))
### Packages to release

View File

@ -938,6 +938,8 @@ const messages = {
noNbdConnection: 'No NBD Connection',
nbdConnection: 'NBD Connection',
insecureNbdConnection: 'Insecure NBD Connection (not allowed through XO)',
// ----- Pool patches tab -----
multiHostPoolUpdate: "Rolling pool update can only work when there's multiple hosts in a pool with a shared storage",
// ----- Pool stats tab -----
poolNoStats: 'No stats',
poolAllHosts: 'All hosts',

View File

@ -6,7 +6,7 @@ import Upgrade from 'xoa-upgrade'
import { addSubscriptions, connectStore, formatSize } from 'utils'
import { alert } from 'modal'
import { Col, Container, Row } from 'grid'
import { createGetObjectsOfType } from 'selectors'
import { createGetObjectsOfType, createSelector } from 'selectors'
import { FormattedRelative, FormattedTime } from 'react-intl'
import { getXoaPlan, ENTERPRISE } from 'xoa-plans'
import {
@ -17,6 +17,7 @@ import {
subscribeHostMissingPatches,
} from 'xo'
import isEmpty from 'lodash/isEmpty.js'
import size from 'lodash/size.js'
const ROLLING_POOL_UPDATES_AVAILABLE = getXoaPlan().value >= ENTERPRISE.value
@ -166,6 +167,12 @@ const INSTALLED_PATCH_COLUMNS = [
}))
@connectStore({
hostPatches: createGetObjectsOfType('patch').pick((_, { master }) => master.patches),
poolHosts: createGetObjectsOfType('host').filter(
createSelector(
(_, props) => props.pool.id,
poolId => host => host.$pool === poolId
)
),
})
export default class TabPatches extends Component {
render() {
@ -174,11 +181,14 @@ export default class TabPatches extends Component {
master: { productBrand },
missingPatches = [],
pool,
poolHosts,
userPreferences,
} = this.props
const needsCredentials = productBrand !== 'XCP-ng' && userPreferences.xsCredentials === undefined
const isSingleHost = size(poolHosts) < 2
return (
<Upgrade place='poolPatches' required={2}>
<Container>
@ -187,11 +197,12 @@ export default class TabPatches extends Component {
{ROLLING_POOL_UPDATES_AVAILABLE && (
<TabButton
btnStyle='primary'
disabled={isEmpty(missingPatches)}
disabled={isEmpty(missingPatches) || isSingleHost}
handler={rollingPoolUpdate}
handlerParam={pool.id}
icon='pool-rolling-update'
labelId='rollingPoolUpdate'
tooltip={isSingleHost ? _('multiHostPoolUpdate') : undefined}
/>
)}
<TabButton