From f73683c3490188a186e7c6b1dbfc0d6643e45e0a Mon Sep 17 00:00:00 2001 From: Jannik Stehle <50302941+JammingBen@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:55:41 +0100 Subject: [PATCH] Change behaviour of user filters to `OR` (#8525) --- changelog/unreleased/enhancement-user-group-filter | 1 + changelog/unreleased/enhancement-user-role-filter | 1 + packages/web-app-admin-settings/src/views/Users.vue | 11 ++++++----- .../tests/unit/views/Users.spec.ts | 8 ++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/changelog/unreleased/enhancement-user-group-filter b/changelog/unreleased/enhancement-user-group-filter index 2c3cf6b4ba0..bbd417ec066 100644 --- a/changelog/unreleased/enhancement-user-group-filter +++ b/changelog/unreleased/enhancement-user-group-filter @@ -5,3 +5,4 @@ Users in the users list can now be filtered by their group assignments. https://github.com/owncloud/web/issues/8377 https://github.com/owncloud/web/pull/8378 https://github.com/owncloud/web/pull/8495 +https://github.com/owncloud/web/pull/8525 diff --git a/changelog/unreleased/enhancement-user-role-filter b/changelog/unreleased/enhancement-user-role-filter index efa582de6b3..d766c47b5d4 100644 --- a/changelog/unreleased/enhancement-user-role-filter +++ b/changelog/unreleased/enhancement-user-role-filter @@ -4,3 +4,4 @@ Users in the users list can now be filtered by their role assignments. https://github.com/owncloud/web/pull/8492 https://github.com/owncloud/web/pull/8495 +https://github.com/owncloud/web/pull/8525 diff --git a/packages/web-app-admin-settings/src/views/Users.vue b/packages/web-app-admin-settings/src/views/Users.vue index 03ec3fa3516..96604c5e4db 100644 --- a/packages/web-app-admin-settings/src/views/Users.vue +++ b/packages/web-app-admin-settings/src/views/Users.vue @@ -220,11 +220,12 @@ export default defineComponent({ const loadUsersTask = useTask(function* (signal) { const filter = Object.values(filters) .reduce((acc, f) => { - acc.push( - unref(f.ids) - .map((id) => format(f.query, id)) - .join(' and ') - ) + const str = unref(f.ids) + .map((id) => format(f.query, id)) + .join(' or ') + if (str) { + acc.push(`(${str})`) + } return acc }, []) .filter(Boolean) diff --git a/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts b/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts index 256172ca764..ae9f1331446 100644 --- a/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts +++ b/packages/web-app-admin-settings/tests/unit/views/Users.spec.ts @@ -350,7 +350,7 @@ describe('Users view', () => { expect(graphMock.users.listUsers).toHaveBeenNthCalledWith( 2, 'displayName', - "memberOf/any(m:m/id eq '1')" + "(memberOf/any(m:m/id eq '1'))" ) }) it('does filter initially if group ids are given via query param', async () => { @@ -364,7 +364,7 @@ describe('Users view', () => { await wrapper.vm.loadResourcesTask.last expect(graphMock.users.listUsers).toHaveBeenCalledWith( 'displayName', - "memberOf/any(m:m/id eq '1') and memberOf/any(m:m/id eq '2')" + "(memberOf/any(m:m/id eq '1') or memberOf/any(m:m/id eq '2'))" ) }) }) @@ -383,7 +383,7 @@ describe('Users view', () => { expect(graphMock.users.listUsers).toHaveBeenNthCalledWith( 2, 'displayName', - "appRoleAssignments/any(m:m/appRoleId eq '1')" + "(appRoleAssignments/any(m:m/appRoleId eq '1'))" ) }) it('does filter initially if role ids are given via query param', async () => { @@ -397,7 +397,7 @@ describe('Users view', () => { await wrapper.vm.loadResourcesTask.last expect(graphMock.users.listUsers).toHaveBeenCalledWith( 'displayName', - "appRoleAssignments/any(m:m/appRoleId eq '1') and appRoleAssignments/any(m:m/appRoleId eq '2')" + "(appRoleAssignments/any(m:m/appRoleId eq '1') or appRoleAssignments/any(m:m/appRoleId eq '2'))" ) }) })