-
Notifications
You must be signed in to change notification settings - Fork 21
Add System Access page #3095
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
Open
charliepark
wants to merge
23
commits into
main
Choose a base branch
from
system_level_access_page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+609
−42
Open
Add System Access page #3095
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3752493
Add System Access page
charliepark ec6f242
a few small refactors
charliepark 376b153
Remove some casts; change import
charliepark fb0e217
List system roles with least permissions first, like silo/project
charliepark 2c912ab
Fix a few small inconsistencies between System / Silo / Project acces…
charliepark cb3680b
Add warning about deleting own access
charliepark 0f0f6b4
copy adjustment
charliepark d8715ef
Clean up a few bits of legacy logic
charliepark fb50d25
use getEffectiveRole to handle edge case in role assignments
charliepark 7a9ebbc
Add test for limited permission user
charliepark 518b6e6
tweak test for error message
charliepark 9423ea7
simplify test
charliepark 636b90e
R -> Role for generic, to cut down on R[emeda] confusion/collisions
charliepark 83c12c4
R -> Role for generic, to cut down on R[emeda] confusion/collisions
charliepark 99d0009
type predicate to specify fleetRoles as FleetRole[] instead of RoleKey[]
charliepark c3d6755
Use more precise FleetRole type; add warning on Silo Access removal
charliepark 8ec9546
tweaks
david-crespo 5260d0c
convert locators in e2e test to getByRole
david-crespo 4fd561b
fleet access
charliepark 56ec1fd
merge main and resolve conflict
charliepark 2f4bf12
fix TS issue
charliepark 09b03d6
Added placeholder copy about fleet role mapping to silos
charliepark 74246ea
Better copy on fleet role mappings
charliepark 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
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,128 @@ | ||
| /* | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * Copyright Oxide Computer Company | ||
| */ | ||
| import { useForm } from 'react-hook-form' | ||
|
|
||
| import { | ||
| api, | ||
| queryClient, | ||
| updateRole, | ||
| useActorsNotInPolicy, | ||
| useApiMutation, | ||
| type FleetRole, | ||
| } from '@oxide/api' | ||
| import { Access16Icon } from '@oxide/design-system/icons/react' | ||
|
|
||
| import { ListboxField } from '~/components/form/fields/ListboxField' | ||
| import { SideModalForm } from '~/components/form/SideModalForm' | ||
| import { SideModalFormDocs } from '~/ui/lib/ModalLinks' | ||
| import { ResourceLabel } from '~/ui/lib/SideModal' | ||
| import { docLinks } from '~/util/links' | ||
|
|
||
| import { | ||
| actorToItem, | ||
| RoleRadioField, | ||
| type AddRoleModalProps, | ||
| type EditRoleModalProps, | ||
| } from './access-util' | ||
|
|
||
| export function SystemAccessAddUserSideModal({ | ||
| onDismiss, | ||
| policy, | ||
| }: AddRoleModalProps<FleetRole>) { | ||
| const actors = useActorsNotInPolicy(policy) | ||
|
|
||
| const updatePolicy = useApiMutation(api.systemPolicyUpdate, { | ||
| onSuccess: () => { | ||
| queryClient.invalidateEndpoint('systemPolicyView') | ||
| onDismiss() | ||
| }, | ||
| }) | ||
|
|
||
| const form = useForm<{ identityId: string; roleName: FleetRole }>({ | ||
| defaultValues: { identityId: '', roleName: 'viewer' }, | ||
| }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="create" | ||
| resourceName="role" | ||
| title="Add user or group" | ||
| submitLabel="Assign role" | ||
| onDismiss={() => { | ||
| updatePolicy.reset() // clear API error state so it doesn't persist on next open | ||
| onDismiss() | ||
| }} | ||
| onSubmit={({ identityId, roleName }) => { | ||
| // actor is guaranteed to be in the list because it came from there | ||
| const identityType = actors.find((a) => a.id === identityId)!.identityType | ||
|
|
||
| updatePolicy.mutate({ | ||
| body: updateRole({ identityId, identityType, roleName }, policy), | ||
| }) | ||
| }} | ||
| loading={updatePolicy.isPending} | ||
| submitError={updatePolicy.error} | ||
| > | ||
| <ListboxField | ||
| name="identityId" | ||
| items={actors.map(actorToItem)} | ||
| label="User or group" | ||
| required | ||
| control={form.control} | ||
| /> | ||
| <RoleRadioField name="roleName" control={form.control} scope="Fleet" /> | ||
| <SideModalFormDocs docs={[docLinks.access]} /> | ||
| </SideModalForm> | ||
| ) | ||
| } | ||
|
|
||
| export function SystemAccessEditUserSideModal({ | ||
| onDismiss, | ||
| name, | ||
| identityId, | ||
| identityType, | ||
| policy, | ||
| defaultValues, | ||
| }: EditRoleModalProps<FleetRole>) { | ||
| const updatePolicy = useApiMutation(api.systemPolicyUpdate, { | ||
| onSuccess: () => { | ||
| queryClient.invalidateEndpoint('systemPolicyView') | ||
| onDismiss() | ||
| }, | ||
| }) | ||
| const form = useForm({ defaultValues }) | ||
|
|
||
| return ( | ||
| <SideModalForm | ||
| form={form} | ||
| formType="edit" | ||
| resourceName="role" | ||
| title="Edit role" | ||
| subtitle={ | ||
| <ResourceLabel> | ||
| <Access16Icon /> {name} | ||
| </ResourceLabel> | ||
| } | ||
| onSubmit={({ roleName }) => { | ||
| updatePolicy.mutate({ | ||
| body: updateRole({ identityId, identityType, roleName }, policy), | ||
| }) | ||
| }} | ||
| loading={updatePolicy.isPending} | ||
| submitError={updatePolicy.error} | ||
| onDismiss={() => { | ||
| updatePolicy.reset() // clear API error state so it doesn't persist on next open | ||
| onDismiss() | ||
| }} | ||
| > | ||
| <RoleRadioField name="roleName" control={form.control} scope="Fleet" /> | ||
| <SideModalFormDocs docs={[docLinks.access]} /> | ||
| </SideModalForm> | ||
| ) | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.