feat(ui): add OrganizationProfileApiKeysPanel mosaic component#9075
Conversation
🦋 Changeset detectedLatest commit: 94ca494 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds an Organization API Keys panel with create/revoke state machines, a controller hook, a presentational view, OrganizationProfile tab wiring, and Storybook/docs registration. ChangesOrganization API Keys Panel
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
76c5710 to
97961dc
Compare
Rebuilds the organization API keys experience (list, search, paginate, create + copy-secret, revoke-with-confirmation, permission gating) as a Mosaic machine/controller/view component, exposed via the OrganizationProfile compound namespace.
6b39e69 to
f392bbf
Compare
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
API Changes Report
Summary
No API Changes DetectedAll packages have stable APIs with no detected changes. Report generated by Break Check Last ran on |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.tsx (1)
6-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd JSDoc to the public
OrganizationProfileApiKeysPanelcomponent.This component is exposed via
OrganizationProfile.ApiKeysPaneland as a flat export, making it reference-facing. It currently has per-prop inline comments but no top-level JSDoc describing purpose/usage, which Docs generation relies on.As per path instructions, "check whether the corresponding JSDoc is present, accurate, and aligned with the implementation" for public/reference-facing APIs, and "leave a review note reminding the contributor that the Docs team may need to review the change."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.tsx` around lines 6 - 13, Add top-level JSDoc for OrganizationProfileApiKeysPanel so the public component has a clear purpose/usage description for Docs generation. Keep the existing prop comments, but add a concise component-level doc above OrganizationProfileApiKeysPanel that matches its implementation and mentions its reference-facing exposure through OrganizationProfile.ApiKeysPanel and the flat export; also leave a brief review note that the Docs team may need to review the change.Source: Path instructions
packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.view.tsx (1)
119-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an explicit return type to the exported view component.
As per coding guidelines,
**/*.{ts,tsx}files should "Always define explicit return types for functions, especially public APIs."♻️ Proposed fix
+import type { ReactElement } from 'react'; + export function OrganizationProfileApiKeysPanelView({ list, canManage, create, revoke, -}: OrganizationProfileApiKeysPanelViewProps) { +}: OrganizationProfileApiKeysPanelViewProps): ReactElement {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.view.tsx` around lines 119 - 124, The exported OrganizationProfileApiKeysPanelView component is missing an explicit return type, which violates the TypeScript API guideline for public functions. Update the OrganizationProfileApiKeysPanelView declaration to include a clear return type annotation for the JSX it renders, keeping the component signature explicit while preserving its current behavior.Source: Coding guidelines
packages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel.controller.test.tsx (1)
104-196: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the debounce and page-clamp effects.
The debounced search reset (controller lines 81-87) and the page-clamp-after-deletion effect (lines 89-94) aren't exercised by any test here.
As per coding guidelines,
**/*.{test,spec}.{ts,tsx,js,jsx}requires that tests "Verify proper error handling and edge cases."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel.controller.test.tsx` around lines 104 - 196, The test suite for useOrganizationProfileApiKeysPanelController is missing coverage for the debounce-based search reset and the page-clamp-after-deletion effect. Add focused tests in organization-profile-api-keys-panel.controller.test.tsx that exercise the search-related state path driven by the controller’s debounce logic and verify the selected page is reset/clamped when deletions reduce the total page count. Use the existing Harness, apiKeysArgs, and revalidate/setup patterns to locate and assert the behavior around the controller’s search and pagination effects.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/swingset/src/stories/organization-profile-api-keys-panel.mdx`:
- Around line 7-17: `OrganizationProfileApiKeysPanel` is a leaf panel, so its
MDX should not declare `OrganizationProfile` in the Story composition. Update
the `Story` in `organization-profile-api-keys-panel.mdx` to remove the inverted
`composition` entry and keep the file focused on the panel itself; use
`OrganizationProfile` only in the parent `organization-profile.mdx` where the
wiring actually happens.
In
`@packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.view.tsx`:
- Around line 244-253: The per-row Revoke button is still clickable while the
revoke flow is already in `confirming` or `revoking`, but `revoke.send({ type:
'REQUEST', ... })` is ignored in those states, causing a silent dead click.
Update the `organization-profile-api-keys-panel.view.tsx` row action around the
`Revoke` button to disable it or otherwise block clicks whenever the revoke
machine is not idle, using the existing `revoke` state in the component so a
second row cannot trigger a no-op request.
---
Nitpick comments:
In
`@packages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel.controller.test.tsx`:
- Around line 104-196: The test suite for
useOrganizationProfileApiKeysPanelController is missing coverage for the
debounce-based search reset and the page-clamp-after-deletion effect. Add
focused tests in organization-profile-api-keys-panel.controller.test.tsx that
exercise the search-related state path driven by the controller’s debounce logic
and verify the selected page is reset/clamped when deletions reduce the total
page count. Use the existing Harness, apiKeysArgs, and revalidate/setup patterns
to locate and assert the behavior around the controller’s search and pagination
effects.
In `@packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.tsx`:
- Around line 6-13: Add top-level JSDoc for OrganizationProfileApiKeysPanel so
the public component has a clear purpose/usage description for Docs generation.
Keep the existing prop comments, but add a concise component-level doc above
OrganizationProfileApiKeysPanel that matches its implementation and mentions its
reference-facing exposure through OrganizationProfile.ApiKeysPanel and the flat
export; also leave a brief review note that the Docs team may need to review the
change.
In
`@packages/ui/src/mosaic/organization/organization-profile-api-keys-panel.view.tsx`:
- Around line 119-124: The exported OrganizationProfileApiKeysPanelView
component is missing an explicit return type, which violates the TypeScript API
guideline for public functions. Update the OrganizationProfileApiKeysPanelView
declaration to include a clear return type annotation for the JSX it renders,
keeping the component signature explicit while preserving its current behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Repository UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 7b9397c6-e4c3-4dd9-9cca-77808db29f9d
📒 Files selected for processing (18)
.changeset/org-profile-api-keys-panel.mdpackages/swingset/src/components/DocsViewer.tsxpackages/swingset/src/lib/registry.tspackages/swingset/src/stories/organization-profile-api-keys-panel.mdxpackages/swingset/src/stories/organization-profile-api-keys-panel.stories.tsxpackages/swingset/src/stories/organization-profile.mdxpackages/swingset/src/stories/organization-profile.stories.tsxpackages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel-create.machine.test.tspackages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel-revoke.machine.test.tspackages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel.controller.test.tsxpackages/ui/src/mosaic/organization/__tests__/organization-profile-api-keys-panel.view.test.tsxpackages/ui/src/mosaic/organization/organization-profile-api-keys-panel-create.machine.tspackages/ui/src/mosaic/organization/organization-profile-api-keys-panel-revoke.machine.tspackages/ui/src/mosaic/organization/organization-profile-api-keys-panel.controller.tsxpackages/ui/src/mosaic/organization/organization-profile-api-keys-panel.tsxpackages/ui/src/mosaic/organization/organization-profile-api-keys-panel.view.tsxpackages/ui/src/mosaic/organization/organization-profile-view.tsxpackages/ui/src/mosaic/organization/organization-profile.tsx
REQUEST is only handled in the revoke machine's idle state, so clicking another row's Revoke while a revoke was confirming/revoking was a silent no-op. Disable the per-row button whenever the machine is not idle.
Summary
Org API keys as Mosaic component.
machine → controller → viewsplit (mirrors DeleteSection/ProfileSection). Parity w/ legacycomponents/APIKeys/APIKeys.tsx(org scope). Standalone onmain(profile-section merged #9068).Preview: https://swingset-git-feat-mosaic-org-profile-api-keys-panel.clerkstage.dev/organization/organization-profile-api-keys-panel
Included
*-create.machine.ts— create + copy-secret (closed→editing→creating→showingSecret), name-length guard, injectedcreateAPIKey.*-revoke.machine.ts— revoke (idle→confirming→revoking), "Revoke" word guard.*.controller.tsx— only Clerk-touching layer:useOrganization/useSessiongating,org:sys_api_keys:read/:manage,useAPIKeyslist+search+paginate, wires machines toclerk.apiKeys.create/revoke+revalidate, mapsAPIKeyResource→row,mapCreateApiKeyError.*.view.tsx— props-only plain HTML (search, create form, table+per-row revoke, prev/next, copy-secret dialog, revoke confirm).*.tsx— wrapper gatingstatus === "ready".OrganizationProfile.ApiKeysPanelnamespace only. No public/experimental export.Scope
OrganizationAPIKeysPagerouting untouched (backwards-compat).Tests
TDD, 47 tests (create 9, revoke 6, controller 14, view 18). Machines use
createActor; controller mocks@clerk/shared/react; view renders fake snapshots.Changeset
Empty — no user-facing surface (mosaic not publicly exported).
Summary by CodeRabbit