Skip to content

Commit

Permalink
front
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuRA committed Dec 11, 2024
1 parent faf69aa commit 1b0fe95
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 22 deletions.
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const messages = {
notifications: 'Notifications',
noNotifications: 'No notifications so far.',
notificationNew: 'NEW!',
notYetAvailableForXs8: 'Not yet available for XenServer 8',
moreDetails: 'More details',
messageSubject: 'Subject',
messageFrom: 'From',
Expand Down
4 changes: 4 additions & 0 deletions packages/xo-web/src/common/xo/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import defined from '@xen-orchestra/defined'
import semver from 'semver'
import { find, forEach, includes, map } from 'lodash'

export const getDefaultNetworkForVif = (vif, destHost, pifs, networks) => {
Expand Down Expand Up @@ -41,3 +42,6 @@ export const getDefaultMigrationNetwork = (intraPool, destHost, pools, pifs) =>
intraPool ? {} : defaultPif
).$network
}

export const isXsHostWithCdnPatches = ({ version, productBrand }) =>
productBrand === 'XenServer' && semver.gte(version, '8.4.0')
28 changes: 19 additions & 9 deletions packages/xo-web/src/xo-app/host/tab-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { installAllPatchesOnHost, restartHost } from 'xo'
import isEmpty from 'lodash/isEmpty.js'

import { createGetObject } from '../../common/selectors'
import { isXsHostWithCdnPatches } from '../../common/xo/utils'

const MISSING_PATCH_COLUMNS = [
{
Expand Down Expand Up @@ -163,7 +164,7 @@ class XcpPatches extends Component {
/>
)}
<TabButton
// disabled={!hasMissingPatches || pool?.HA_enabled}
disabled={!hasMissingPatches || pool?.HA_enabled}
btnStyle={hasMissingPatches ? 'primary' : undefined}
handler={installAllPatches}
icon={hasMissingPatches ? 'host-patch-update' : 'success'}
Expand Down Expand Up @@ -196,6 +197,7 @@ class XenServerPatches extends Component {
render() {
const { host, hostPatches, installAllPatches, missingPatches, pool } = this.props
const hasMissingPatches = !isEmpty(missingPatches)
const _isXsHostWithCdnPatches = isXsHostWithCdnPatches(host)
return (
<Container>
<Row>
Expand All @@ -210,12 +212,18 @@ class XenServerPatches extends Component {
/>
)}
<TabButton
disabled={!hasMissingPatches || pool.HA_enabled}
disabled={!hasMissingPatches || pool.HA_enabled || _isXsHostWithCdnPatches}
btnStyle={hasMissingPatches ? 'primary' : undefined}
handler={installAllPatches}
icon={hasMissingPatches ? 'host-patch-update' : 'success'}
labelId={hasMissingPatches ? 'patchUpdateButton' : 'hostUpToDate'}
tooltip={pool.HA_enabled ? _('highAvailabilityNotDisabledTooltip') : undefined}
tooltip={
pool.HA_enabled
? _('highAvailabilityNotDisabledTooltip')
: hasMissingPatches && _isXsHostWithCdnPatches
? _('notYetAvailableForXs8')
: undefined
}
/>
</Col>
</Row>
Expand All @@ -227,12 +235,14 @@ class XenServerPatches extends Component {
</Col>
</Row>
)}
<Row>
<Col>
<h3>{_('hostAppliedPatches')}</h3>
<SortedTable collection={hostPatches} columns={INSTALLED_PATCH_COLUMNS} stateUrlParam='s_installed' />
</Col>
</Row>
{!_isXsHostWithCdnPatches && (
<Row>
<Col>
<h3>{_('hostAppliedPatches')}</h3>
<SortedTable collection={hostPatches} columns={INSTALLED_PATCH_COLUMNS} stateUrlParam='s_installed' />
</Col>
</Row>
)}
</Container>
)
}
Expand Down
45 changes: 32 additions & 13 deletions packages/xo-web/src/xo-app/pool/tab-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import filter from 'lodash/filter.js'
import isEmpty from 'lodash/isEmpty.js'
import size from 'lodash/size.js'
import some from 'lodash/some.js'
import { isXsHostWithCdnPatches } from 'xo/utils'

const ROLLING_POOL_UPDATES_AVAILABLE = getXoaPlan().value >= ENTERPRISE.value

Expand Down Expand Up @@ -59,7 +60,8 @@ const MISSING_PATCH_COLUMNS = [

const ACTIONS = [
{
disabled: (_, { pool, needsCredentials }) => pool.HA_enabled || needsCredentials,
disabled: (_, { isXsHostWithCdnPatches, pool, needsCredentials }) =>
pool.HA_enabled || needsCredentials || isXsHostWithCdnPatches,
handler: (patches, { pool }) => installPatches(patches, pool),
icon: 'host-patch-update',
label: _('install'),
Expand Down Expand Up @@ -223,14 +225,16 @@ export default class TabPatches extends Component {
render() {
const {
hostPatches,
master: { productBrand },
master: { productBrand, version },
missingPatches = [],
pool,
poolHosts,
userPreferences,
} = this.props

const needsCredentials = productBrand !== 'XCP-ng' && userPreferences.xsCredentials === undefined
const _isXsHostWithCdnPatches = isXsHostWithCdnPatches({ version, productBrand })
const needsCredentials =
productBrand !== 'XCP-ng' && !_isXsHostWithCdnPatches && userPreferences.xsCredentials === undefined

const isSingleHost = size(poolHosts) < 2

Expand All @@ -246,7 +250,11 @@ export default class TabPatches extends Component {
<TabButton
btnStyle='primary'
disabled={
hasAXostor || isEmpty(missingPatches) || hasMultipleVmsRunningOnLocalStorage || isSingleHost
hasAXostor ||
isEmpty(missingPatches) ||
hasMultipleVmsRunningOnLocalStorage ||
isSingleHost ||
_isXsHostWithCdnPatches
}
handler={rollingPoolUpdate}
handlerParam={pool.id}
Expand All @@ -261,14 +269,16 @@ export default class TabPatches extends Component {
})
: isSingleHost
? _('multiHostPoolUpdate')
: undefined
: _isXsHostWithCdnPatches
? _('notYetAvailableForXs8')
: undefined
}
/>
)}
<TabButton
btnStyle='primary'
data-pool={pool}
disabled={isEmpty(missingPatches) || pool.HA_enabled || needsCredentials}
disabled={isEmpty(missingPatches) || pool.HA_enabled || needsCredentials || _isXsHostWithCdnPatches}
handler={installAllPatchesOnPool}
icon='host-patch-update'
labelId='installPoolPatches'
Expand All @@ -277,7 +287,9 @@ export default class TabPatches extends Component {
? _('highAvailabilityNotDisabledTooltip')
: needsCredentials
? _('xsCredentialsMissingShort')
: undefined
: _isXsHostWithCdnPatches
? _('notYetAvailableForXs8')
: undefined
}
/>
</Col>
Expand Down Expand Up @@ -318,18 +330,25 @@ export default class TabPatches extends Component {
actions={ACTIONS}
collection={missingPatches}
columns={MISSING_PATCH_COLUMNS}
data-isXsHostWithCdnPatches={_isXsHostWithCdnPatches}
data-pool={pool}
data-needsCredentials={needsCredentials}
stateUrlParam='s_missing'
/>
</Col>
</Row>
<Row>
<Col>
<h3>{_('hostAppliedPatches')}</h3>
<SortedTable collection={hostPatches} columns={INSTALLED_PATCH_COLUMNS} stateUrlParam='s_installed' />
</Col>
</Row>
{!_isXsHostWithCdnPatches && (
<Row>
<Col>
<h3>{_('hostAppliedPatches')}</h3>
<SortedTable
collection={hostPatches}
columns={INSTALLED_PATCH_COLUMNS}
stateUrlParam='s_installed'
/>
</Col>
</Row>
)}
</div>
)}
</Container>
Expand Down

0 comments on commit 1b0fe95

Please sign in to comment.