Skip to content

feat: add PAT tab to admin organization details#1576

Open
rohanchkrabrty wants to merge 14 commits intomainfrom
admin-pat
Open

feat: add PAT tab to admin organization details#1576
rohanchkrabrty wants to merge 14 commits intomainfrom
admin-pat

Conversation

@rohanchkrabrty
Copy link
Copy Markdown
Contributor

Summary

  • Add a new PAT tab under the admin organization details page that lists the current admin user's personal access tokens for the org.
  • Implement OrganizationPatView in sdk/admin using FrontierService.searchCurrentUserPATs (read-only — no create/edit/revoke actions per the design).
  • Columns mirror the Figma spec: Title, Project (with overflow names in a 600px-wide tooltip), Created By (avatar + name from orgMembersMap), Created On / Expiry Date (DD MMM YYYY), Last used (relative time via dayjs).
  • Wire the tab into the org navbar chips and add the pat route in apps/admin.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Apr 29, 2026 0:29am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2026

Warning

Rate limit exceeded

@rohanchkrabrty has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 21 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 71b068a7-5515-45a4-ac60-5815e573b13c

📥 Commits

Reviewing files that changed from the base of the PR and between 34bdeb8 and 3b20d61.

📒 Files selected for processing (3)
  • web/sdk/admin/views/organizations/details/pat/columns.tsx
  • web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.tsx
  • web/sdk/admin/views/organizations/details/pat/index.tsx
📝 Walkthrough

Walkthrough

Adds an Organization Personal Access Tokens (PAT) management feature: new nested org route, exported view, navbar link, PAT list columns, styles, a details dialog component, and the OrganizationPatView with server-mode table and data fetching.

Changes

Cohort / File(s) Summary
Routing & Barrel Export
web/apps/admin/src/routes.tsx, web/sdk/admin/index.ts
Adds nested route /organizations/:organizationId/pat mounting OrganizationPatView and re-exports OrganizationPatView from the admin SDK barrel.
Organization Navbar
web/sdk/admin/views/organizations/details/layout/navbar.tsx
Inserts a new "PAT" navigation chip that links to the organization's /pat subroute.
PAT View & Data
web/sdk/admin/views/organizations/details/pat/index.tsx, web/sdk/admin/views/organizations/details/pat/columns.tsx
Adds OrganizationPatView component with server-mode DataTable, infinite query for PATs, project lookup, and getColumns returning column defs (Title, Project, Created By, Created On, Expiry Date, Last used).
PAT Details Dialog
web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.tsx, web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.module.css
New PatDetailsDialog component that displays scoped projects and resolved roles (with loading state) and associated CSS module for dialog layout and list styling.
PAT Styling
web/sdk/admin/views/organizations/details/pat/pat.module.css
New CSS module with layout, truncation, and table/empty-state styles for the PAT view.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • rohilsurana
  • rsbh
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 21 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Base automatically changed from worktree-feat-pat-tokens to main April 27, 2026 00:01
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 27, 2026

Coverage Report for CI Build 25108823581

Coverage remained the same at 42.353%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37069
Covered Lines: 15700
Line Coverage: 42.35%
Coverage Strength: 11.76 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (6)
web/sdk/admin/views/organizations/details/pat/pat.module.css (2)

19-23: Prefer overflow: auto over overflow: scroll.

overflow: scroll always renders scrollbars (both axes) even when content fits, which is visually noisy on macOS/Linux when the table is small. auto only shows them when needed.

♻️ Proposed fix
 .table-wrapper {
   /* Navbar Height + Toolbar height */
   max-height: calc(100vh - 90px);
-  overflow: scroll;
+  overflow: auto;
 }

20-21: Magic number for header/toolbar offset.

calc(100vh - 90px) hardcodes the combined navbar + toolbar height. If either control's size changes (zoom, density, theme), the table either over- or under-scrolls. Consider deriving the value via a CSS custom property or measuring with a ref/ResizeObserver.

web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.tsx (2)

33-33: Dialog open flips on every render after close.

const open = pat !== null; is fine, but combined with enabled: open on useQuery and defaultValue="projects" on <Tabs>, opening a different PAT after closing one preserves nothing — that's intentional. Just flagging that roleEntries (line 72) is recomputed on every render rather than memoized; not a correctness issue, but consider useMemo for symmetry with scopeProjects / rolesMap.


172-172: Nit: stray space in closing tag.

</Dialog > — minor, but inconsistent with the rest of the file.

♻️ Proposed fix
-    </Dialog >
+    </Dialog>
web/sdk/admin/views/organizations/details/pat/columns.tsx (1)

8-21: Module-level dayjs.extend(relativeTime) is fine but global.

Calling dayjs.extend(relativeTime) at module scope mutates the shared dayjs instance. If another part of the app already extends it (or expects vanilla dayjs), this is a no-op / harmless — just noting that side-effectful module init can surprise consumers of this barrel. No change required if dayjs is already centrally extended elsewhere.

web/sdk/admin/views/organizations/details/pat/index.tsx (1)

152-153: Memoize data to avoid prop-identity churn.

infiniteData?.pages?.flatMap(...) ?? [] produces a new array every render, which causes DataTable to re-receive a new data reference each render even when content is unchanged. Wrap in useMemo keyed on infiniteData?.pages.

♻️ Proposed fix
-  const data =
-    infiniteData?.pages?.flatMap((page) => page?.organizationPats ?? []) ?? [];
+  const data = useMemo(
+    () => infiniteData?.pages?.flatMap((page) => page?.organizationPats ?? []) ?? [],
+    [infiniteData?.pages],
+  );

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 99248006-e1cb-4420-9d55-384ca65d31b0

📥 Commits

Reviewing files that changed from the base of the PR and between d11eb4e and 30fa2d9.

📒 Files selected for processing (8)
  • web/apps/admin/src/routes.tsx
  • web/sdk/admin/index.ts
  • web/sdk/admin/views/organizations/details/layout/navbar.tsx
  • web/sdk/admin/views/organizations/details/pat/columns.tsx
  • web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.module.css
  • web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.tsx
  • web/sdk/admin/views/organizations/details/pat/index.tsx
  • web/sdk/admin/views/organizations/details/pat/pat.module.css

Comment on lines +49 to +67
{
accessorKey: "scopes",
header: "Project",
classNames: { cell: styles["truncate-cell"] },
enableSorting: false,
cell: ({ row }) => {
const projectScope = row.original.scopes?.find(
(scope) => scope.resourceType === SCOPES.PROJECT,
);
const resourceIds = projectScope?.resourceIds ?? [];
if (resourceIds.length === 0) {
return <Text className={styles["truncate-text"]}>-</Text>;
}
const projectNamesText = resourceIds.map(
(id) => projectsMap[id]?.title || projectsMap[id]?.name || id,
).join(", ");
return <Text className={styles["truncate-text"]}>{projectNamesText}</Text>;
},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing tooltip for overflowing project names.

The PR description specifies that the Project column should show overflow names in a 600px-wide tooltip, but the current implementation only truncates via CSS — hovering reveals nothing. When a PAT is scoped to multiple projects, users can't see the full list. Consider wrapping the truncated text in a Tooltip showing the full comma-separated list (constrained to ~600px).

♻️ Sketch
-        return <Text className={styles["truncate-text"]}>{projectNamesText}</Text>;
+        return (
+          <Tooltip message={projectNamesText} side="top">
+            <Text className={styles["truncate-text"]}>{projectNamesText}</Text>
+          </Tooltip>
+        );

Comment on lines +115 to +140
<Tabs.Content value="projects" className={styles["tab-content"]}>
{scopeProjects.length === 0 ? null : (
<Flex direction="column">
{scopeProjects.map((project) => (
<div key={project.id} className={styles["list-item"]}>
<Text
size="small"
weight="medium"
className={styles["list-item-text"]}
>
{project.title || project.name}
</Text>
</div>
))}
</Flex>
)}
</Tabs.Content>
<Tabs.Content value="roles" className={styles["tab-content"]}>
{isRolesLoading ? (
<Skeleton
containerClassName={styles["skeleton"]}
height={20}
count={4}
/>
) : roleEntries.length === 0 ? (
null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Empty Projects / Roles tabs render nothing.

When scopeProjects.length === 0 (Projects tab) or roleEntries.length === 0 (Roles tab, post-load), the tab body is null — the user sees a tab labeled "Projects (0)" / "Roles (0)" with a blank panel. EmptyState is already imported; rendering it (or a minimal <Text>No projects</Text>) gives clearer feedback.

♻️ Proposed fix
-            <Tabs.Content value="projects" className={styles["tab-content"]}>
-              {scopeProjects.length === 0 ? null : (
+            <Tabs.Content value="projects" className={styles["tab-content"]}>
+              {scopeProjects.length === 0 ? (
+                <EmptyState
+                  classNames={{ container: styles["empty-state"] }}
+                  heading="No projects"
+                />
+              ) : (
                 <Flex direction="column">
                   ...
                 </Flex>
               )}
             </Tabs.Content>

Comment thread web/sdk/admin/views/organizations/details/pat/columns.tsx Outdated
Comment thread web/sdk/admin/views/organizations/details/pat/index.tsx Outdated

const fetchMore = async () => {
if (hasNextPage && !isFetchingNextPage && !isError) {
await fetchNextPage();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets handle the error here with try catch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch around await fetchNextPage() wouldn't catch anything in normal failure cases, useInfiniteQuery catches the error if any rather than rejecting the promise.
That same error is displayed as ErrorState in DataTable. This is a common pattern across all other pages

Comment thread web/sdk/admin/views/organizations/details/pat/components/pat-details-dialog.tsx Outdated
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.

4 participants