fix(xo-web/menu/xoa): display icon when no notifications nor updates (#4068)
Fixes #4012
This commit is contained in:
parent
5edee4bae0
commit
21a7cf7158
@ -13,6 +13,7 @@
|
|||||||
- [Continuous Replication] Fix VHD size guess for empty files [#4105](https://github.com/vatesfr/xen-orchestra/issues/4105) (PR [#4107](https://github.com/vatesfr/xen-orchestra/pull/4107))
|
- [Continuous Replication] Fix VHD size guess for empty files [#4105](https://github.com/vatesfr/xen-orchestra/issues/4105) (PR [#4107](https://github.com/vatesfr/xen-orchestra/pull/4107))
|
||||||
- [Backup NG] Only display full backup interval in case of a delta backup (PR [#4125](https://github.com/vatesfr/xen-orchestra/pull/4107))
|
- [Backup NG] Only display full backup interval in case of a delta backup (PR [#4125](https://github.com/vatesfr/xen-orchestra/pull/4107))
|
||||||
- [Dashboard/Health] fix 'an error has occurred' on the storage state table [#4128](https://github.com/vatesfr/xen-orchestra/issues/4128) (PR [#4132](https://github.com/vatesfr/xen-orchestra/pull/4132))
|
- [Dashboard/Health] fix 'an error has occurred' on the storage state table [#4128](https://github.com/vatesfr/xen-orchestra/issues/4128) (PR [#4132](https://github.com/vatesfr/xen-orchestra/pull/4132))
|
||||||
|
- [Menu] XOA: Fixed empty slot when menu is collapsed [#4012](https://github.com/vatesfr/xen-orchestra/issues/4012) (PR [#4068](https://github.com/vatesfr/xen-orchestra/pull/4068)
|
||||||
|
|
||||||
### Released packages
|
### Released packages
|
||||||
|
|
||||||
|
@ -213,6 +213,8 @@ export const getStatus = state => state.status
|
|||||||
|
|
||||||
export const getUser = state => state.user
|
export const getUser = state => state.user
|
||||||
|
|
||||||
|
export const getXoaState = state => state.xoaUpdaterState
|
||||||
|
|
||||||
export const getCheckPermissions = invoke(() => {
|
export const getCheckPermissions = invoke(() => {
|
||||||
const getPredicate = create(
|
const getPredicate = create(
|
||||||
state => state.permissions,
|
state => state.permissions,
|
||||||
|
@ -2,9 +2,7 @@ import _ from 'intl'
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import Component from 'base-component'
|
import Component from 'base-component'
|
||||||
import Icon from 'icon'
|
import Icon from 'icon'
|
||||||
import isEmpty from 'lodash/isEmpty'
|
|
||||||
import Link from 'link'
|
import Link from 'link'
|
||||||
import map from 'lodash/map'
|
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Tooltip from 'tooltip'
|
import Tooltip from 'tooltip'
|
||||||
import { UpdateTag } from '../xoa/update'
|
import { UpdateTag } from '../xoa/update'
|
||||||
@ -13,6 +11,7 @@ import { addSubscriptions, connectStore, getXoaPlan, noop } from 'utils'
|
|||||||
import {
|
import {
|
||||||
connect,
|
connect,
|
||||||
signOut,
|
signOut,
|
||||||
|
subscribeNotifications,
|
||||||
subscribePermissions,
|
subscribePermissions,
|
||||||
subscribeResourceSets,
|
subscribeResourceSets,
|
||||||
} from 'xo'
|
} from 'xo'
|
||||||
@ -23,8 +22,10 @@ import {
|
|||||||
getIsPoolAdmin,
|
getIsPoolAdmin,
|
||||||
getStatus,
|
getStatus,
|
||||||
getUser,
|
getUser,
|
||||||
|
getXoaState,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
} from 'selectors'
|
} from 'selectors'
|
||||||
|
import { every, identity, isEmpty, map } from 'lodash'
|
||||||
|
|
||||||
import styles from './index.css'
|
import styles from './index.css'
|
||||||
|
|
||||||
@ -34,20 +35,22 @@ const returnTrue = () => true
|
|||||||
() => ({
|
() => ({
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isPoolAdmin: getIsPoolAdmin,
|
isPoolAdmin: getIsPoolAdmin,
|
||||||
|
nHosts: createGetObjectsOfType('host').count(),
|
||||||
nTasks: createGetObjectsOfType('task').count([
|
nTasks: createGetObjectsOfType('task').count([
|
||||||
task => task.status === 'pending',
|
task => task.status === 'pending',
|
||||||
]),
|
]),
|
||||||
pools: createGetObjectsOfType('pool'),
|
pools: createGetObjectsOfType('pool'),
|
||||||
nHosts: createGetObjectsOfType('host').count(),
|
|
||||||
srs: createGetObjectsOfType('SR'),
|
srs: createGetObjectsOfType('SR'),
|
||||||
status: getStatus,
|
status: getStatus,
|
||||||
user: getUser,
|
user: getUser,
|
||||||
|
xoaState: getXoaState,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
withRef: true,
|
withRef: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@addSubscriptions({
|
@addSubscriptions({
|
||||||
|
notifications: subscribeNotifications,
|
||||||
permissions: subscribePermissions,
|
permissions: subscribePermissions,
|
||||||
resourceSets: subscribeResourceSets,
|
resourceSets: subscribeResourceSets,
|
||||||
})
|
})
|
||||||
@ -88,6 +91,11 @@ export default class Menu extends Component {
|
|||||||
isEmpty
|
isEmpty
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_getNoNotifications = createSelector(
|
||||||
|
() => this.props.notifications,
|
||||||
|
notifications => every(notifications, { read: true })
|
||||||
|
)
|
||||||
|
|
||||||
get height() {
|
get height() {
|
||||||
return this.refs.content.offsetHeight
|
return this.refs.content.offsetHeight
|
||||||
}
|
}
|
||||||
@ -118,9 +126,11 @@ export default class Menu extends Component {
|
|||||||
pools,
|
pools,
|
||||||
nHosts,
|
nHosts,
|
||||||
srs,
|
srs,
|
||||||
|
xoaState,
|
||||||
} = this.props
|
} = this.props
|
||||||
const noOperatablePools = this._getNoOperatablePools()
|
const noOperatablePools = this._getNoOperatablePools()
|
||||||
const noResourceSets = this._getNoResourceSets()
|
const noResourceSets = this._getNoResourceSets()
|
||||||
|
const noNotifications = this._getNoNotifications()
|
||||||
|
|
||||||
/* eslint-disable object-property-newline */
|
/* eslint-disable object-property-newline */
|
||||||
const items = [
|
const items = [
|
||||||
@ -247,16 +257,12 @@ export default class Menu extends Component {
|
|||||||
to: isAdmin ? 'xoa/update' : 'xoa/notifications',
|
to: isAdmin ? 'xoa/update' : 'xoa/notifications',
|
||||||
icon: 'menu-xoa',
|
icon: 'menu-xoa',
|
||||||
label: 'xoa',
|
label: 'xoa',
|
||||||
extra: (
|
extra: [
|
||||||
<span>
|
!isAdmin || xoaState === 'upToDate' ? null : (
|
||||||
{isAdmin && (
|
<UpdateTag key='update' />
|
||||||
<span>
|
|
||||||
<UpdateTag />{' '}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
<NotificationTag />
|
|
||||||
</span>
|
|
||||||
),
|
),
|
||||||
|
noNotifications ? null : <NotificationTag key='notification' />,
|
||||||
|
],
|
||||||
subMenu: [
|
subMenu: [
|
||||||
isAdmin && {
|
isAdmin && {
|
||||||
to: 'xoa/update',
|
to: 'xoa/update',
|
||||||
@ -528,6 +534,7 @@ export default class Menu extends Component {
|
|||||||
const MenuLinkItem = props => {
|
const MenuLinkItem = props => {
|
||||||
const { item } = props
|
const { item } = props
|
||||||
const { to, icon, label, subMenu, pill, extra } = item
|
const { to, icon, label, subMenu, pill, extra } = item
|
||||||
|
const _extra = extra !== undefined ? extra.find(e => e !== null) : undefined
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className='nav-item xo-menu-item'>
|
<li className='nav-item xo-menu-item'>
|
||||||
@ -537,7 +544,7 @@ const MenuLinkItem = props => {
|
|||||||
to={to}
|
to={to}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
className={classNames((pill || extra) && styles.hiddenCollapsed)}
|
className={classNames((pill || _extra) && styles.hiddenCollapsed)}
|
||||||
icon={`${icon}`}
|
icon={`${icon}`}
|
||||||
size='lg'
|
size='lg'
|
||||||
fixedWidth
|
fixedWidth
|
||||||
@ -548,7 +555,10 @@ const MenuLinkItem = props => {
|
|||||||
|
|
||||||
</span>
|
</span>
|
||||||
{pill > 0 && <span className='tag tag-pill tag-primary'>{pill}</span>}
|
{pill > 0 && <span className='tag tag-pill tag-primary'>{pill}</span>}
|
||||||
{extra}
|
<span className={styles.hiddenUncollapsed}>{_extra}</span>
|
||||||
|
<span className={styles.hiddenCollapsed}>
|
||||||
|
{extra !== undefined && extra.map(identity)}
|
||||||
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
{subMenu && <SubMenu items={subMenu} />}
|
{subMenu && <SubMenu items={subMenu} />}
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user