Files
supabase/apps/studio/components/ui/DocsButton.tsx
kemal.earth 33482bdc88 feat(studio): lifecycle and role-aware scoped token view sheet (#48848)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Extracts the token view sheet slice of #48742
(w3b6x9/scoped-pat-access-feedback, commit 56ef87a). The role-evaluation
logic (estimateRoleLevel, computeTokenRoleContext,
applySelectionToRoleContext, groupFailingResources) already landed on
master via #48805 and #48809 — this PR only wires the view sheet up to
it:

- Bindings whose project/org was deleted (FGA bindings erased) render a
"resources no longer exist" state; bindings the user can no longer reach
render an anonymous count with a "No longer accessible" badge and a
"removed from" admonition.
- Accessible resources list their name plus ref/slug; capabilities show
"Exceeds your role" pills and the risk badge reflects what the owner's
current role actually allows.
- Header split into separate "Access control" and "API docs" buttons.
- Everything recomputes from live org/project/permission queries (no
stored state) and degrades to no warnings while loading or on
self-hosted.

Also gives DocsButton an optional `label` prop (defaults preserve
existing behavior for every other consumer) so the two header buttons
can carry distinct text.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Enhanced access-token details with permission categories, risk
summaries, endpoint, and MCP information.
  * Added warnings for permissions exceeding the token’s role.
* Clearly identifies inaccessible, deleted, or unavailable organizations
and projects.
  * Added resource details and remediation guidance for unusable tokens.
  * Documentation links can now display custom labels.

* **Bug Fixes**
* Improved access evaluation when organization or project data is
incomplete or access has changed.
  * Deferred resource loading until token details are opened.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-07 17:19:30 +01:00

33 lines
803 B
TypeScript

import { BookOpen } from 'lucide-react'
import { Button } from 'ui'
interface DocsButtonProps {
href: string
abbrev?: boolean
className?: string
topic?: string
/** Custom button text, e.g. to distinguish multiple docs buttons side by side. */
label?: string
}
export const DocsButton = ({ href, abbrev = true, className, topic, label }: DocsButtonProps) => {
return (
<Button
asChild
variant="default"
className={className}
icon={<BookOpen />}
onClick={(e) => e.stopPropagation()}
>
<a
target="_blank"
rel="noopener noreferrer"
href={href}
aria-label={topic ? `${topic} documentation (opens in new tab)` : undefined}
>
{label ?? (abbrev ? 'Docs' : 'Documentation')}
</a>
</Button>
)
}