Skip to content

Commit

Permalink
group only alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuRA committed Mar 6, 2023
1 parent 10a2b36 commit 52c0b68
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
37 changes: 21 additions & 16 deletions packages/xo-web/src/xo-app/home/pool-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,27 @@ export default class PoolItem extends Component {
return Object.values(this.props.poolHosts)[0].productBrand === 'XCP-ng'
}

_getPoolLicenseInfo = () => this.props.state.poolLicenseInfoByPoolId[this.props.item.id]

_getAlerts = createSelector(
() => this.props.item,
() => this.props.isAdmin,
() => this.props.state,
(pool, isAdmin, reacletteState) => {
this._getPoolLicenseInfo,
(isAdmin, poolLicenseInfo) => {
const alerts = []

if (isAdmin) {
const { icon, supportLevel } = reacletteState.poolLicenseInfoByPoolId[pool.id]
const level = supportLevel === 'total' ? 'success' : supportLevel === 'partial' ? 'warning' : 'danger'
alerts.push({
level,
render: (
<p>
{icon()} {this._getPoolLicenseIconTooltip()}
</p>
),
})
if (isAdmin && this._isXcpngPool()) {
const { icon, supportLevel } = poolLicenseInfo
if (supportLevel !== 'total') {
const level = supportLevel === 'partial' ? 'warning' : 'danger'
alerts.push({
level,
render: (
<p>
{icon()} {this._getPoolLicenseIconTooltip()}
</p>
),
})
}
}
return alerts
}
Expand All @@ -122,6 +125,7 @@ export default class PoolItem extends Component {
render() {
const { item: pool, expandAll, selected, hostMetrics, poolHosts, nSrs, nVms } = this.props
const { missingPatchCount } = this.state
const { icon, supportLevel } = this._getPoolLicenseInfo()

return (
<div className={styles.item}>
Expand All @@ -134,8 +138,6 @@ export default class PoolItem extends Component {
<Ellipsis>
<Text value={pool.name_label} onChange={this._setNameLabel} useLongClick />
</Ellipsis>
{isAdmin && this._isXcpngPool() && <span className='ml-1'>{this._getPoolLicenseIcon()}</span>}
&nbsp;&nbsp;
&nbsp;
<BulkIcons alerts={this._getAlerts()} />
&nbsp;
Expand All @@ -146,6 +148,9 @@ export default class PoolItem extends Component {
</Tooltip>
</span>
)}
&nbsp;
{isAdmin && this._isXcpngPool() && supportLevel === 'total' && icon(this._getPoolLicenseIconTooltip())}
&nbsp;
{pool.HA_enabled && (
<span>
&nbsp;&nbsp;
Expand Down
11 changes: 7 additions & 4 deletions packages/xo-web/src/xo-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import Xosan from './xosan'
import Import from './import'

import keymap, { help } from '../keymap'
import Tooltip from '../common/tooltip'
import { createCollectionWrapper, createGetObjectsOfType } from '../common/selectors'
import { bindXcpngLicense, rebindLicense, subscribeXcpngLicenses } from '../common/xo'
import { SOURCES } from '../common/xoa-plans'
Expand Down Expand Up @@ -88,10 +89,12 @@ const WrapperIconPoolLicense = ({ children }) => (
)

export const ICON_POOL_LICENSE = {
total: () => (
<WrapperIconPoolLicense>
<Icon icon='pro-support' className='text-success' />
</WrapperIconPoolLicense>
total: tooltip => (
<Tooltip content={tooltip}>
<WrapperIconPoolLicense>
<Icon icon='pro-support' className='text-success' />
</WrapperIconPoolLicense>
</Tooltip>
),
partial: () => (
<WrapperIconPoolLicense>
Expand Down

0 comments on commit 52c0b68

Please sign in to comment.