Skip to content

Commit 778fb7e

Browse files
jsell-rhclaude
andcommitted
refactor(ambient-ui): narrow CredentialManageSheet prop to non-nullable
Per amber's suggestion: credential prop narrowed from DomainCredential | null to DomainCredential. All call sites already conditionally mount the sheet, so the null guard is redundant. This makes the contract explicit and prevents future regression of the unbounded useRoleBindings query. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3328c8e commit 778fb7e

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

components/ambient-ui/src/app/(dashboard)/credentials/_components/credential-manage-sheet.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function CredentialManageSheet({
3737
onOpenChange,
3838
onNavigateToMatrix,
3939
}: {
40-
credential: DomainCredential | null
40+
credential: DomainCredential
4141
open: boolean
4242
onOpenChange: (open: boolean) => void
4343
onNavigateToMatrix?: (credentialName: string) => void
@@ -48,17 +48,13 @@ export function CredentialManageSheet({
4848
const updateCredential = useUpdateCredential()
4949
const deleteCredential = useDeleteCredential()
5050

51-
const { data: liveCredential } = useCredential(credential?.id ?? '')
51+
const { data: liveCredential } = useCredential(credential.id)
5252
const resolved = liveCredential ?? credential
5353

5454
const { data: bindingsData } = useRoleBindings(
55-
credential
56-
? { search: `credential_id = '${credential.id}'` }
57-
: undefined,
55+
{ search: `credential_id = '${credential.id}'` },
5856
)
5957

60-
if (!credential || !resolved) return null
61-
6258
const providerMeta = getProviderMeta(resolved.provider)
6359
const category = getCategoryForProvider(resolved.provider)
6460
const bindingCount = bindingsData?.items.length ?? 0

components/ambient-ui/src/app/(dashboard)/credentials/_components/credential-table.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,16 @@ export function CredentialTable({
208208
</Table>
209209
</div>
210210

211-
<CredentialManageSheet
212-
credential={selectedCredential}
213-
open={selectedCredential !== null}
214-
onOpenChange={(open) => {
215-
if (!open) setSelectedCredential(null)
216-
}}
217-
onNavigateToMatrix={onNavigateToMatrix}
218-
/>
211+
{selectedCredential && (
212+
<CredentialManageSheet
213+
credential={selectedCredential}
214+
open
215+
onOpenChange={(open) => {
216+
if (!open) setSelectedCredential(null)
217+
}}
218+
onNavigateToMatrix={onNavigateToMatrix}
219+
/>
220+
)}
219221
</>
220222
)
221223
}

0 commit comments

Comments
 (0)