fix(xo-web/tasks): fix tasks filter (#6424)

See zammad#9423
This commit is contained in:
rajaa-b 2022-09-21 11:02:03 +02:00 committed by GitHub
parent 2a71e28253
commit 99a1dbeae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 23 deletions

View File

@ -8,7 +8,6 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [Backup/Restore file] Implement File level restore for s3 and encrypted backups (PR [#6409](https://github.com/vatesfr/xen-orchestra/pull/6409))
- [Backup] Improve listing speed by updating caches instead of regenerating them on backup creation/deletion (PR [#6411](https://github.com/vatesfr/xen-orchestra/pull/6411))
- [Backup] Add `mergeBlockConcurrency` and `writeBlockConcurrency` to allow tuning of backup resources consumptions (PR [#6416](https://github.com/vatesfr/xen-orchestra/pull/6416))
@ -19,6 +18,7 @@
- [Plugin/auth-saml] Certificate input support multiline (PR [#6403](https://github.com/vatesfr/xen-orchestra/pull/6403))
- [Backup] Launch Health Check after a full backup (PR [#6401](https://github.com/vatesfr/xen-orchestra/pull/6401))
- [Backup] Fix `Lock file is already being held` error when deleting a VM backup while the VM is currently being backed up
- [Tasks] Fix the pool filter that did not display tasks even if they existed (PR [#6424](https://github.com/vatesfr/xen-orchestra/pull/6424))
### Packages to release

View File

@ -10,7 +10,7 @@ import { addSubscriptions, connectStore, resolveIds } from 'utils'
import { FormattedDate, FormattedRelative, injectIntl } from 'react-intl'
import { SelectPool } from 'select-objects'
import { Col, Container, Row } from 'grid'
import { differenceBy, flatMap, groupBy, isEmpty, keys, map, some } from 'lodash'
import { differenceBy, isEmpty, map, some } from 'lodash'
import {
createFilter,
createGetObject,
@ -192,20 +192,18 @@ const GROUPED_ACTIONS = [
permissions: subscribePermissions,
})
@connectStore(() => {
const getResolvedPendingTasksByPool = createSelector(getResolvedPendingTasks, resolvedPendingTasks =>
groupBy(resolvedPendingTasks, '$pool')
const getPools = createGetObjectsOfType('pool').pick(
createSelector(getResolvedPendingTasks, resolvedPendingTasks => resolvedPendingTasks.map(task => task.$poolId))
)
const getPools = createGetObjectsOfType('pool').pick(createSelector(getResolvedPendingTasksByPool, keys))
return (state, props) => {
// true: useResourceSet to bypass permissions
const resolvedPendingTasksByPool = getResolvedPendingTasks(state, props, true)
const resolvedPendingTasks = getResolvedPendingTasks(state, props, true)
return {
isAdmin: isAdmin(state, props),
nResolvedTasks: resolvedPendingTasksByPool.length,
nResolvedTasks: resolvedPendingTasks.length,
pools: getPools(state, props, true),
resolvedPendingTasksByPool,
resolvedPendingTasks,
}
}
})
@ -216,7 +214,7 @@ export default class Tasks extends Component {
}
componentWillReceiveProps(props) {
const finishedTasks = differenceBy(this.props.resolvedPendingTasksByPool, props.resolvedPendingTasksByPool, 'id')
const finishedTasks = differenceBy(this.props.resolvedPendingTasks, props.resolvedPendingTasks, 'id')
if (!isEmpty(finishedTasks)) {
this.setState({
finishedTasks: finishedTasks
@ -226,22 +224,14 @@ export default class Tasks extends Component {
}
}
_getTasks = createSelector(
_getPoolFilter = createSelector(
createSelector(() => this.state.pools, resolveIds),
() => this.props.resolvedPendingTasksByPool,
(poolIds, resolvedPendingTasksByPool) =>
isEmpty(poolIds)
? resolvedPendingTasksByPool
: flatMap(poolIds, poolId => resolvedPendingTasksByPool[poolId] || [])
poolIds => (isEmpty(poolIds) ? null : ({ $poolId }) => poolIds.includes($poolId))
)
_getFinishedTasks = createFilter(
() => this.state.finishedTasks,
createSelector(
createSelector(() => this.state.pools, resolveIds),
poolIds => (isEmpty(poolIds) ? null : ({ $poolId }) => poolIds.includes($poolId))
)
)
_getTasks = createFilter(() => this.props.resolvedPendingTasks, this._getPoolFilter)
_getFinishedTasks = createFilter(() => this.state.finishedTasks, this._getPoolFilter)
_getItemsPerPageContainer = () => this.state.itemsPerPageContainer