-
Notifications
You must be signed in to change notification settings - Fork 15
Handle fleet viewers without permission to see SCIM tokens #2957
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| <TokenCreatedModal token={token} onDismiss={() => setModalState(false)} /> | ||
| )) | ||
| .with(false, () => null) | ||
| .exhaustive()} |
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.
addicted to ts-pattern
| .then((data) => ({ type: 'success' as const, data })) | ||
| .catch((data) => ({ type: 'error' as const, data })), | ||
| .then((data: Result<A[M]>) => ({ type: 'success' as const, data })) | ||
| .catch((data: ApiError) => ({ type: 'error' as const, data })), |
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 was a bug in apiqErrorsAllowed causing the data field to have type any in both arms. There is a better way to do this without casting but I'm going to do it later.
| type ModalState = | ||
| | { kind: 'create' } | ||
| | { kind: 'created'; token: ScimClientBearerTokenValue } | ||
| | false |
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 makes it impossible to accidentally have both modals rendered at once
| } | ||
|
|
||
| function TokensTable({ tokens }: { tokens: ScimClientBearerToken[] }) { | ||
| const siloSelector = useSiloSelector() |
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.
Moved the table logic to its own component that only renders on success responses so we don't have to pollute with if-else checks.
Ended up doing quite a bit of shuffling around, but the main thing is switching to
apiqErrorsAllowedand displaying a different thing when it comes back as an error.Jane Austen is a fleet viewer but not a fleet or silo admin: