Skip to content

Commit

Permalink
fix(xo-web): feedback, improve proxies menu warning icon and message
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierFL committed Dec 21, 2023
1 parent f2b34d4 commit 6c0b768
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,8 @@ const messages = {
proxiesNeedUpgrade: 'Some proxies need to be upgraded.',
upgradeNeededForProxies: 'Some proxies need to be upgraded. Click here to get more information.',
xoProxyConcreteGuide: 'XO Proxy: a concrete guide',
someProxiesHaveErrors: 'Some proxies have errors',
someProxiesHaveErrors:
'{n, number} prox{n, plural, one {y} other {ies}} ha{n, plural, one {s} other {ve}} error{n, plural, one {} other {s}}',

// ----- Utils -----
secondsFormat: '{seconds, plural, one {# second} other {# seconds}}',
Expand Down
23 changes: 16 additions & 7 deletions packages/xo-web/src/xo-app/menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,19 @@ export default class Menu extends Component {
() => this.state.proxyStates,
proxyStates => some(proxyStates, state => state.endsWith('-upgrade-needed'))
)
_areProxiesErrors = createSelector(
_getNProxiesErrors = createSelector(
() => this.state.proxyStates,
proxyStates => some(proxyStates, state => state === 'error')
(proxyStates) => {
let count = 0

forEach(proxyStates, proxyState => {
if (proxyState === 'error') {
count++
}
})

return count
}
)
_checkPermissions = createSelector(
() => this.props.isAdmin,
Expand Down Expand Up @@ -216,6 +226,7 @@ export default class Menu extends Component {
const noOperatablePools = this._getNoOperatablePools()
const noResourceSets = this._getNoResourceSets()
const noNotifications = this._getNoNotifications()
const nProxiesErrors = this._getNProxiesErrors()

const missingPatchesWarning = this._hasMissingPatches() ? (
<Tooltip content={_('homeMissingPatches')}>
Expand Down Expand Up @@ -471,11 +482,9 @@ export default class Menu extends Component {
]}
/>
</Tooltip>
) : this._areProxiesErrors() ? (
<Tooltip content={_('someProxiesHaveErrors')}>
<span className='text-warning'>
<Icon icon='alarm' />
</span>
) : nProxiesErrors > 0 ? (
<Tooltip content={_('someProxiesHaveErrors', { n: nProxiesErrors })}>
<span className='tag tag-pill tag-warning'>{nProxiesErrors}</span>
</Tooltip>
) : null,
],
Expand Down

0 comments on commit 6c0b768

Please sign in to comment.