Skip to content

Commit

Permalink
Change behaviour of user filters to OR (#8525)
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen authored Mar 6, 2023
1 parent 98ed5c4 commit f73683c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-user-group-filter
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-user-role-filter
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions packages/web-app-admin-settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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'))"
)
})
})
Expand All @@ -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 () => {
Expand All @@ -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'))"
)
})
})
Expand Down

0 comments on commit f73683c

Please sign in to comment.