Skip to content

Conversation

@david-crespo
Copy link
Collaborator

Ended up doing quite a bit of shuffling around, but the main thing is switching to apiqErrorsAllowed and displaying a different thing when it comes back as an error.

Jane Austen is a fleet viewer but not a fleet or silo admin:

image

@vercel
Copy link

vercel bot commented Oct 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
console Ready Ready Preview Oct 30, 2025 8:53pm

<TokenCreatedModal token={token} onDismiss={() => setModalState(false)} />
))
.with(false, () => null)
.exhaustive()}
Copy link
Collaborator Author

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 })),
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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()
Copy link
Collaborator Author

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.

@david-crespo david-crespo merged commit 60bbb98 into main Oct 30, 2025
7 checks passed
@david-crespo david-crespo deleted the scim-token-perms branch October 30, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants