From ce78d22bb838095bf3cc467cc7d924915f7cfbf3 Mon Sep 17 00:00:00 2001 From: rajaa-b Date: Wed, 21 Sep 2022 11:25:14 +0200 Subject: [PATCH] fix(xo-web/tasks): fix tasks being displayed to all users (#6422) See zammad#9509 Introduced by e246c8ee478036f58d9b89060908969dd7ac9cf7 --- CHANGELOG.unreleased.md | 1 + packages/xo-web/src/common/selectors.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index a0115c67c..6711bc37e 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -19,6 +19,7 @@ - [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)) +- [Tasks] Fix tasks being displayed for all users (PR [#6422](https://github.com/vatesfr/xen-orchestra/pull/6422)) ### Packages to release diff --git a/packages/xo-web/src/common/selectors.js b/packages/xo-web/src/common/selectors.js index 730be173a..6e53d635c 100644 --- a/packages/xo-web/src/common/selectors.js +++ b/packages/xo-web/src/common/selectors.js @@ -629,7 +629,8 @@ const getLinkedObjectsByTaskRefOrId = create( export const getResolvedPendingTasks = create( createGetObjectsOfType('task').filter([task => task.status === 'pending']), getLinkedObjectsByTaskRefOrId, - (tasks, linkedObjectsByTaskRefOrId) => { + getCheckPermissions, + (tasks, linkedObjectsByTaskRefOrId, check) => { const resolvedTasks = [] forEach(tasks, task => { const objects = [ @@ -638,10 +639,13 @@ export const getResolvedPendingTasks = create( // { taskId → operation } map instead of { taskRef → operation } map ...defined(linkedObjectsByTaskRefOrId[task.id], []), ] - resolvedTasks.push({ - ...task, - objects, - }) + + if (objects.length > 0 || check(task.$host, 'view')) { + resolvedTasks.push({ + ...task, + objects, + }) + } }) return resolvedTasks }