Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change behaviour of user filters to OR #8525

Merged
merged 2 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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