-
Notifications
You must be signed in to change notification settings - Fork 13
Sort IAM role assignments with groups first, then by name #1237
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
62c45e0
prefetch groups list on silo, org, and project access pages
david-crespo 23cbd04
sort groups first, then users, and by name within each
david-crespo c7e1b82
simultaneity tests for user name and group name
david-crespo 40062f9
silo access page e2e test
david-crespo a4a75b5
test byGroupThenName
david-crespo 68fccad
Merge branch 'main' into fix-iam-sort-bug
zephraph 0d37bee
Fix id references in test
zephraph 0903824
Merge main into fix-iam-sort-bug
david-crespo 61203b2
update silo access test with mock user changes
david-crespo 82b09fe
pull in SessionMe from API
david-crespo a79067b
update omicron for the better comment
david-crespo edb9f42
Merge branch 'main' into fix-iam-sort-bug
david-crespo 9cd091a
regen API for the new omicron commit
david-crespo 3075c54
Merge main into fix-iam-sort-bug
david-crespo a0993d7
update new code for id changes from main
david-crespo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
bce0f5ddf7f9f3be498fa9afb1fee8d3336c1f30 | ||
2ea34d0369fd26bc4f438ea0b3c8ab1b50314048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { user1, user3, user4, userGroup3 } from '@oxide/api-mocks' | ||
|
||
import { | ||
expectNotVisible, | ||
expectRowVisible, | ||
expectSimultaneous, | ||
expectVisible, | ||
} from 'app/test/e2e' | ||
|
||
test('Click through silo access page', async ({ page }) => { | ||
await page.goto('/orgs') | ||
|
||
const table = page.locator('role=table') | ||
|
||
// page is there, we see user 1 and 2 but not 3 | ||
await page.click('role=link[name*="Access & IAM"]') | ||
|
||
// has to be before anything else is checked. ensures we've prefetched | ||
// users list and groups list properly | ||
await expectSimultaneous(page, [ | ||
`role=cell[name="${userGroup3.id}"]`, | ||
'role=cell[name="real-estate-devs Group"]', | ||
`role=cell[name="${user1.id}"]`, | ||
'role=cell[name="Hannah Arendt"]', | ||
]) | ||
|
||
await expectVisible(page, ['role=heading[name*="Access & IAM"]']) | ||
await expectRowVisible(table, { | ||
ID: userGroup3.id, | ||
// no space because expectRowVisible uses textContent, not accessible name | ||
Name: 'real-estate-devsGroup', | ||
'Silo role': 'admin', | ||
}) | ||
await expectRowVisible(table, { | ||
ID: user1.id, | ||
Name: 'Hannah Arendt', | ||
'Silo role': 'admin', | ||
}) | ||
await expectNotVisible(page, [`role=cell[name="${user4.id}"]`]) | ||
|
||
// Add user 2 as collab | ||
await page.click('role=button[name="Add user or group"]') | ||
await expectVisible(page, ['role=heading[name*="Add user or group"]']) | ||
|
||
await page.click('role=button[name="User"]') | ||
// only users not already on the org should be visible | ||
await expectNotVisible(page, ['role=option[name="Hannah Arendt"]']) | ||
await expectVisible(page, [ | ||
'role=option[name="Hans Jonas"]', | ||
'role=option[name="Jacob Klein"]', | ||
'role=option[name="Simone de Beauvoir"]', | ||
]) | ||
|
||
await page.click('role=option[name="Jacob Klein"]') | ||
|
||
await page.click('role=button[name="Role"]') | ||
await expectVisible(page, [ | ||
'role=option[name="Admin"]', | ||
'role=option[name="Collaborator"]', | ||
'role=option[name="Viewer"]', | ||
]) | ||
|
||
await page.click('role=option[name="Collaborator"]') | ||
await page.click('role=button[name="Add user"]') | ||
|
||
// User 3 shows up in the table | ||
await expectRowVisible(table, { | ||
ID: user3.id, | ||
Name: 'Jacob Klein', | ||
'Silo role': 'collaborator', | ||
}) | ||
|
||
// now change user 3's role from collab to viewer | ||
await page | ||
.locator('role=row', { hasText: user3.id }) | ||
.locator('role=button[name="Row actions"]') | ||
.click() | ||
await page.click('role=menuitem[name="Change role"]') | ||
|
||
await expectVisible(page, ['role=heading[name*="Change user role"]']) | ||
await expectVisible(page, ['button:has-text("Collaborator")']) | ||
|
||
await page.click('role=button[name="Role"]') | ||
await page.click('role=option[name="Viewer"]') | ||
await page.click('role=button[name="Update role"]') | ||
|
||
await expectRowVisible(table, { ID: user3.id, 'Silo role': 'viewer' }) | ||
|
||
// now delete user 3 | ||
await page | ||
.locator('role=row', { hasText: user3.id }) | ||
.locator('role=button[name="Row actions"]') | ||
.click() | ||
await expectVisible(page, [`role=cell[name="${user3.id}"]`]) | ||
await page.click('role=menuitem[name="Delete"]') | ||
await expectNotVisible(page, [`role=cell[name="${user3.id}"]`]) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import type { LoaderFunctionArgs } from 'react-router-dom' | |
|
||
import { | ||
apiQueryClient, | ||
byGroupThenName, | ||
getEffectiveRole, | ||
setUserRole, | ||
useApiMutation, | ||
|
@@ -23,7 +24,7 @@ import { | |
TableActions, | ||
TableEmptyBox, | ||
} from '@oxide/ui' | ||
import { groupBy, isTruthy, sortBy } from '@oxide/util' | ||
import { groupBy, isTruthy } from '@oxide/util' | ||
|
||
import { AccessNameCell } from 'app/components/AccessNameCell' | ||
import { RoleBadgeCell } from 'app/components/RoleBadgeCell' | ||
|
@@ -53,6 +54,7 @@ ProjectAccessPage.loader = async ({ params }: LoaderFunctionArgs) => { | |
apiQueryClient.prefetchQuery('projectPolicyView', { path: { orgName, projectName } }), | ||
// used to resolve user names | ||
apiQueryClient.prefetchQuery('userList', {}), | ||
apiQueryClient.prefetchQuery('groupList', {}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this very much re-enforces the fact that this should only be a short term impl. |
||
]) | ||
} | ||
|
||
|
@@ -84,8 +86,8 @@ export function ProjectAccessPage() { | |
const projectRows = useUserRows(projectPolicy?.roleAssignments, 'project') | ||
|
||
const rows = useMemo(() => { | ||
const users = groupBy(siloRows.concat(orgRows, projectRows), (u) => u.id).map( | ||
([userId, userAssignments]) => { | ||
return groupBy(siloRows.concat(orgRows, projectRows), (u) => u.id) | ||
.map(([userId, userAssignments]) => { | ||
const siloRole = userAssignments.find((a) => a.roleSource === 'silo')?.roleName | ||
const orgRole = userAssignments.find((a) => a.roleSource === 'org')?.roleName | ||
const projectRole = userAssignments.find( | ||
|
@@ -108,9 +110,8 @@ export function ProjectAccessPage() { | |
} | ||
|
||
return row | ||
} | ||
) | ||
return sortBy(users, (u) => u.name) | ||
}) | ||
.sort(byGroupThenName) | ||
}, [siloRows, orgRows, projectRows]) | ||
|
||
const queryClient = useApiQueryClient() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the kind of bug I was concerned about in #1232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tricky, tricky