-
Notifications
You must be signed in to change notification settings - Fork 358
chore(clerk-js): Add API Keys component descriptors #6095
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
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
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.
Actionable comments posted: 0
🧹 Nitpick comments (6)
packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (1)
3-3
: Import list is getting long – consider multi-line formattingThe utilities import now spans many identifiers; for readability consider:
-import { Box, Button, Col, descriptors, Flex, FormLabel, localizationKeys, Text } from '@/ui/customizables'; +import { + Box, + Button, + Col, + descriptors, + Flex, + FormLabel, + localizationKeys, + Text, +} from '@/ui/customizables';packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
462-482
: Manual list maintenance is error-proneThe API-keys keys are appended in three places:
ElementsConfig
APPEARANCE_KEYS
(here)- Component usage
A single source of truth (e.g. generating
APPEARANCE_KEYS
fromElementsConfig
at build-time) would prevent future omissions & cut review overhead.packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx (2)
84-87
: Consider adding a row-specificelementId
for stronger selector granularity
Card.Root
gains anelementDescriptor
, which is great, but without a complementaryelementId
the selector will match every revoke-modal in the DOM.
If multiple revoke modals can coexist (e.g. in tests or storybook), distinguishing them becomes impossible.- <Card.Root - role='alertdialog' - elementDescriptor={descriptors.apiKeysRevokeModal} - > + <Card.Root + role='alertdialog' + elementDescriptor={descriptors.apiKeysRevokeModal} + elementId={descriptors.apiKeysRevokeModal.setId(apiKeyId ?? 'revoke-modal')} + >
46-55
: Make the confirmation check case-insensitiveUsers frequently type revoke in lowercase; failing the check feels unnecessarily strict.
-const canSubmit = revokeField.value === 'Revoke'; +const canSubmit = revokeField.value.trim().toLowerCase() === 'revoke';packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx (2)
54-56
:aria-label
not updated when state changesYou already added descriptor metadata to
CopySecretButton
; while you’re touching this block, consider toggling thearia-label
after the copy operation so screen-reader users know the button’s new purpose.-aria-label={hasCopied ? 'Copied API key to clipboard' : 'Copy API key'} +aria-label={hasCopied ? 'Copied API key to clipboard' : 'Copy API key'}(You may instead expose the string through
localizationKeys
like the rest of the UI.)
98-100
:Show key
label becomes stale after revealWhen
revealed
toggles, the button continues to say Show key. Swap the label to Hide key (and localise) for accurate accessibility.-aria-label={'Show key'} +aria-label={revealed ? 'Hide key' : 'Show key'}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.changeset/chilly-pears-film.md
(1 hunks)packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx
(6 hunks)packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx
(8 hunks)packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx
(4 hunks)packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx
(4 hunks)packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts
(0 hunks)packages/clerk-js/src/ui/customizables/elementDescriptors.ts
(1 hunks)packages/types/src/appearance.ts
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/clerk-js/src/ui/components/ApiKeys/useApiKeys.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (1)
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
descriptors
(545-545)
packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (1)
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
descriptors
(545-545)
⏰ Context from checks skipped due to timeout of 90000ms (24)
- GitHub Check: Integration Tests (react-router, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 15)
- GitHub Check: Integration Tests (astro, chrome)
- GitHub Check: Integration Tests (nextjs, chrome, 14)
- GitHub Check: Integration Tests (nextjs, chrome, 13)
- GitHub Check: Integration Tests (expo-web, chrome)
- GitHub Check: Integration Tests (tanstack-react-start, chrome)
- GitHub Check: Integration Tests (elements, chrome)
- GitHub Check: Integration Tests (sessions, chrome)
- GitHub Check: Integration Tests (billing, chrome)
- GitHub Check: Integration Tests (generic, chrome)
- GitHub Check: Integration Tests (tanstack-react-router, chrome)
- GitHub Check: Integration Tests (ap-flows, chrome)
- GitHub Check: Integration Tests (nuxt, chrome)
- GitHub Check: Integration Tests (vue, chrome)
- GitHub Check: Integration Tests (express, chrome)
- GitHub Check: Integration Tests (quickstart, chrome)
- GitHub Check: Integration Tests (localhost, chrome)
- GitHub Check: Unit Tests (22, **)
- GitHub Check: Publish with pkg-pr-new
- GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
- GitHub Check: Static analysis
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
packages/types/src/appearance.ts (1)
589-609
: API-keys descriptors correctly wired intoElementsConfig
The new
apiKeys*
entries are all declared with the properWithOptions
signature (WithOptions<string>
for id-based parts, plainWithOptions
for the rest) and the naming matches the keys used elsewhere (elementDescriptors.ts
, components). No functional issues spotted.packages/clerk-js/src/ui/components/ApiKeys/CreateApiKeyForm.tsx (2)
100-106
: Good:FormContainer
is now targettableSupplying
elementDescriptor={descriptors.apiKeysCreateForm}
ensures the form container can be themed or queried in tests – nice.
196-202
: ```shell
#!/bin/bashLocate the definition of SubmitButton in Form.tsx to check supported props
rg -n --context 5 "SubmitButton" packages/clerk-js/src/ui/elements/Form.tsx
</details> <details> <summary>packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx (4)</summary> `8-18`: **Import keeps file-local barrel pattern consistent** Including `descriptors` in the barrel import keeps consistency with other pages. Looks good. --- `94-108`: **Root & header containers now descriptor-enabled** Adding `elementDescriptor` on the main `<Col>` and header `<Flex>` gives users fine-grained styling hooks – nice improvement. --- `118-129`: **Search input and “Add” button descriptors** These are the primary interactive controls; descriptor coverage here is valuable for e2e tests. --- `144-148`: **Table descriptor wired through** `ApiKeysTable` now receives `elementDescriptor={descriptors.apiKeysTable}` — make sure `ApiKeysTableProps` includes this optional prop (it was marked optional in the PR description). </details> <details> <summary>.changeset/chilly-pears-film.md (1)</summary> `1-7`: **Changeset OK** Version bumps & summary look correct. </details> <details> <summary>packages/clerk-js/src/ui/components/ApiKeys/RevokeAPIKeyConfirmationModal.tsx (1)</summary> `99-103`: **`Form.ControlRow` lacks an `elementId`; localisation fallback still hard-coded** 1. As with the modal root, adding an `elementId` would allow tests/themes to target the exact input when several modals are open. 2. The label/placeholder text (`"Revoke"`) remains hard-coded and English-only. There is already a TODO for localisation – consider wiring `localizationKeys` now so this PR is fully i18n-ready. ```diff - <Form.ControlRow - elementId={revokeField.id} - elementDescriptor={descriptors.apiKeysRevokeModalInput} - > + <Form.ControlRow + elementId={descriptors.apiKeysRevokeModalInput.setId(revokeField.id)} + elementDescriptor={descriptors.apiKeysRevokeModalInput} + >
Likely an incorrect or invalid review comment.
packages/clerk-js/src/ui/components/ApiKeys/ApiKeysTable.tsx (1)
125-127
: Passing a possiblyundefined
elementDescriptor
is fine—guard insideTable
to avoid prop-bleedIf
Table
spreads incoming props onto a DOM element,undefined
is harmless in React but can leak intodata-
attributes if not filtered. Ensure theTable
component strips falsy descriptors internally. No action required here if that guard already exists.
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.
Looking good, I do think we should remove the id usage. There is also a handful of elements with internal only classNames.
@@ -93,6 +104,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr | |||
alignItems: 'stretch', | |||
}, | |||
}} | |||
elementDescriptor={descriptors.apiKeysHeader} | |||
> | |||
<Box> |
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.
Box
should also include a descriptor here.
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.
Added, thanks!
export const Th = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Th))); | ||
export const Td = makeCustomizable(makeLocalizable(sanitizeDomProps(Primitives.Td))); |
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.
Should we also include defaultDescriptors for th and td below?
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.
added!
Description
This PR adds element descriptors to the
<APIKeys />
AIO component for customization.Coverage:
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
Summary by CodeRabbit