docs(36): add UI design contract
This commit is contained in:
@@ -0,0 +1,651 @@
|
||||
---
|
||||
phase: "36"
|
||||
slug: "granular-mcp-oauth-api-token-scope-picker"
|
||||
status: approved
|
||||
reviewed_at: "2026-11-24"
|
||||
shadcn_initialized: false
|
||||
preset: none
|
||||
created: "2026-11-24"
|
||||
---
|
||||
|
||||
# Phase 36 — UI Design Contract
|
||||
|
||||
> Visual and interaction contract for frontend phases. Generated by msd-ui-researcher, verified by msd-ui-checker.
|
||||
|
||||
This phase replaces the flat scope checkbox list on both administrator scope-granting surfaces in the embedded admin SPA (`admin/`, served by `boardwalk`) with a shared 3-tier access selector (`Full *` | `Read-only admin:read` | `Custom`) and a scalable grouped `ScopePicker` designed for dozens of plugins and hundreds of feature-level scopes. No new design tokens, fonts, radii, shadows, or npm packages are added.
|
||||
|
||||
1. **Administrator MCP OAuth consent screen** (`admin/src/views/ConnectView.vue`, modified). Keeps its calm `480px` standalone white card on the navy gradient matching `LoginView.vue` (Phase 32.2). Replaces the flat scope checkbox list with `ScopeAccessControl.vue` (3-tier selector defaulting to `Read-only (admin:read)` when requested and grantable, D-03, plus compact elevated-first summary box) and a Reka `Dialog` **Customize scopes** modal (full-screen `100dvh` sheet on `< 640px`, centered `max-w-[640px] max-h-[85dvh]` modal on `≥ 640px`, D-10) hosting `ScopePicker.vue` pinned to light-literal tokens (D-12).
|
||||
2. **Personal API token creation dialog** (`admin/src/components/account/ApiTokenCreateDialog.vue`, modified). Keeps its `max-w-[560px]` Reka `Dialog` width across all views and its unchanged Step 2 show-once plaintext screen. Replaces the flat scope list in Step 1 with `ScopeAccessControl.vue` (defaulting to `Read-only (admin:read)`, falling back to `Full (*)`, D-08) and swaps the dialog body in place to `ScopePicker.vue` (`← Back to token` / `Apply scopes`, never stacking a second modal overlay, D-02, D-13).
|
||||
3. **Shared scope selection module** (`admin/src/app/scopeCatalog.ts`, `admin/src/components/scopes/useScopeSelection.ts`, `ScopeAccessControl.vue`, `ScopePicker.vue`, new). Encapsulates feature-level scope grouping by `(plugin_id, group)` (D-01, D-17), opt-in combinable `admin:read` locking with `via admin:read` badges (D-04), elevated-first summary chips capped at 6 with `+N more` (D-06), smart accordion expansion (D-07), tier memory + auto-open Custom when empty (D-09), and draft-until-apply semantics (D-11).
|
||||
4. **Personal API token list compatibility** (`admin/src/components/account/ApiTokensPanel.vue`, unchanged). Confirmed backwards-compatible with the additive `plugin_id` and `group` fields on `AdminAPITokenScope` (D-15).
|
||||
|
||||
Out of scope: Go backend `pact.TokenScope.Group`, `cabana` fallback resolution, `pier.Mount` boot warnings, core plugin `HasTokenScopes` rollouts (`sm-seo-plugin`, `sm-sitemap-plugin`), frontend member (`usr_` / `vue-oauth-layer`) consent flows, and production deployment of `sm-grzybyfunkcjonalne-app`.
|
||||
|
||||
Sources:
|
||||
- `36-CONTEXT.md` D-01 through D-20 (locked) and Claude's Discretion items.
|
||||
- `.planning/notes/2026-11-24-mcp-consent-granular-scope-picker.md` (Option D layout, `admin:read` PII footgun, feature-level granularity).
|
||||
- `32.2-UI-SPEC.md` (approved Phase 32.2 consent screen contract and light-literal palette).
|
||||
- Codebase scan: `admin/src/views/ConnectView.vue`, `admin/src/components/account/ApiTokenCreateDialog.vue`, `admin/src/components/account/ApiTokensPanel.vue`, `admin/src/components/ui/Button.vue`, `admin/src/components/form/control.ts`, `admin/src/app/i18n.ts`, `admin/src/app/hotkeys.ts`, `admin/src/api/types.ts`, `admin/src/styles/main.css`, `modules/cabana/account_tokens.go`, `modules/cabana/token_scopes.go`, `modules/phrasebook/backend/lang/{en,pl}/lang.yaml`.
|
||||
|
||||
---
|
||||
|
||||
## Design System
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Tool | none. There is no shadcn: this is a Vue 3 SPA with its own Direction C v2 system (same ruling as Phases 10.1, 12.1, 12.2, 16.3, 32.2, 35) |
|
||||
| Preset | not applicable |
|
||||
| Component library | Reka UI 2.9.10 (headless `Dialog*`, `RadioGroup*` primitives) plus local components in `admin/src/components/` |
|
||||
| Icon library | `@lucide/vue` 1.17.0, named imports only. Sizes: 24px in the 48px client/expired circle, 20px in the wordmark, 18px in `ConnectView` alert blocks, 16px in buttons/search/chevrons/dialog close/back, 14px in inline notes, error lines, and `via admin:read` lock badges |
|
||||
| Font | DM Sans 400/600/700 (self-hosted `@fontsource/dm-sans`). DM Mono 400 (`font-mono`) for scope codes, redirect host, and plaintext tokens. `tabular-nums` on every count and date |
|
||||
|
||||
**This contract adds no new CSS custom properties (`--c-*`), colors, fonts, radii, shadows, or npm dependencies.** Every visual style reuses existing tokens from `admin/src/styles/main.css`.
|
||||
|
||||
---
|
||||
|
||||
## Component Inventory
|
||||
|
||||
Enumerated by `node --input-type=module -e "import * as r from 'reka-ui'; import pkg from './node_modules/reka-ui/package.json' with { type: 'json' }; console.log(pkg.version, Object.keys(r).length)"` (run in `admin/`) — 478 exports — reka-ui@2.9.10 — 2026-11-24.
|
||||
Local components enumerated by `find admin/src/components -name '*.vue' | wc -l` — 69 components — summercms-admin@unversioned (private workspace package with no `version` in `admin/package.json`; pinned by repo commit `c6b1a2bf`) — 2026-11-24.
|
||||
Icons verified by `node --input-type=module -e "import * as l from '@lucide/vue'; import pkg from './node_modules/@lucide/vue/package.json' with { type: 'json' }; console.log(pkg.version, Object.keys(l).length); for (const n of ['Search','X','ChevronDown','ChevronRight','Lock','ArrowLeft','SlidersHorizontal','Info','CircleAlert','Check','LoaderCircle','Bot','Clock','Sun','Copy','TriangleAlert']) console.log(n, n in l)"` (run in `admin/`) — 5882 exports — @lucide/vue@1.17.0 — 2026-11-24. All 16 icons are confirmed exported.
|
||||
|
||||
This table is a **non-exhaustive** list of known-good components for this phase, never a closed allowlist. Checking for another Reka export or local component is the expected path.
|
||||
|
||||
| Component / Primitive | Import path | Role in Phase 36 |
|
||||
|-----------------------|-------------|------------------|
|
||||
| `DialogRoot`, `DialogPortal`, `DialogOverlay`, `DialogContent`, `DialogTitle`, `DialogDescription` | `reka-ui` | Powers both `ApiTokenCreateDialog.vue` (existing) and `ConnectView.vue`'s Customize scopes modal (new, D-10) |
|
||||
| `RadioGroupRoot`, `RadioGroupItem` | `reka-ui` | Powers the 3-tier **Access level** segmented selector in `ScopeAccessControl.vue` (and existing Expiration selector in `ApiTokenCreateDialog.vue`) |
|
||||
| `Button` | `admin/src/components/ui/Button.vue` | Footer actions inside `ApiTokenCreateDialog.vue` (and inside `ScopePicker.vue` when rendered through semantic tokens, where `.connect-light-surface` in `main.css` pins both `--c-*` and `--color-*` on `ConnectView`'s modal) |
|
||||
| `controlClass` | `admin/src/components/form/control.ts` | Shared 44px input border/surface/focus styling for the token Name input and `ScopePicker` search input |
|
||||
| `t`, `tc`, `currentLocale` | `admin/src/app/i18n.ts` | All localized copy, CLDR plurals (`tc`), and locale-aware alphabetical group collation (`currentLocale`) |
|
||||
| `shortcutHint` | `admin/src/app/hotkeys.ts` | Tooltip for `Create token` (`mod+s mod+enter`), active only when `ApiTokenCreateDialog` is on the token form view |
|
||||
| `api`, `AdminAPITokenScope`, `MCPConsent` | `admin/src/api/client.ts`, `admin/src/api/types.ts` | Generated OpenAPI client and types (updated with additive `plugin_id: string` and `group: string` via `scripts/check-admin-openapi.sh`) |
|
||||
| `ConnectView.vue` | `admin/src/views/ConnectView.vue` | Standalone consent screen integrating `ScopeAccessControl` + light-literal Customize modal |
|
||||
| `ApiTokenCreateDialog.vue` | `admin/src/components/account/ApiTokenCreateDialog.vue` | Two-step token creation dialog integrating `ScopeAccessControl` + in-dialog `ScopePicker` view swap |
|
||||
| `ApiTokensPanel.vue` | `admin/src/components/account/ApiTokensPanel.vue` | Unchanged list consumer; verified compatible with additive `plugin_id` / `group` fields |
|
||||
| `scopeCatalog.ts` *(new)* | `admin/src/app/scopeCatalog.ts` | Pure functions: catalog partitioning, `(plugin_id, group)` grouping & locale sort, query matching, smart expand defaults, elevated-first chip builder, submitted-scope serializer |
|
||||
| `useScopeSelection.ts` *(new)* | `admin/src/components/scopes/useScopeSelection.ts` | Reactive composable: 3-tier state, tier memory, auto-open empty Custom, draft cloning, apply/discard with tier revert |
|
||||
| `ScopeAccessControl.vue` *(new)* | `admin/src/components/scopes/ScopeAccessControl.vue` | 3-tier `RadioGroupRoot` + compact effective-access summary box with capped chips, `+N more`, subtitle, and **Customize scopes…** button |
|
||||
| `ScopePicker.vue` *(new)* | `admin/src/components/scopes/ScopePicker.vue` | Surface-agnostic sticky-header / scrollable-accordion / sticky-footer scope picker |
|
||||
|
||||
---
|
||||
|
||||
## Visual Hierarchy & Focal Points
|
||||
|
||||
Every screen and sub-view has one primary visual anchor and at most one primary-filled CTA visible at a time.
|
||||
|
||||
| Screen / View | Primary Visual Anchor | Reading & Scanning Hierarchy (Top to Bottom) | Primary CTA (Single `bg-primary`) |
|
||||
|---------------|-----------------------|----------------------------------------------|-----------------------------------|
|
||||
| **1. `ConnectView.vue` — Consent Card (`480px`)** | `h1` decision heading (`"Allow :client to use the admin as you?"`, 22px/700) anchored by the 48px client mark | (1) Client mark + `h1` + subline + optional previously-allowed note → (2) Signed-in admin & redirect-host fact box (`bg-[#f3f5f8]`) → (3) `ScopeAccessControl` (3-tier radio bar + compact effective-access summary box) → (4) Optional `offline_access` checkbox row → (5) Inline error slot → (6) Deny (outline) + Allow (primary) button pair | **Allow** (bottom right; never auto-focused, no hotkey) |
|
||||
| **2. `ConnectView.vue` — Customize Scopes Modal (`Dialog`, light-literal)** | Modal `DialogTitle` (`"Customize scopes"`, 20px/700) + sticky search input framing the scrollable plugin/group accordion list | (1) Sticky title bar (title, description, Close `X`) → (2) Sticky `ScopePicker` controls (Search input → `All \| Selected \| Read-only` filter pills → opt-in `admin:read` banner) → (3) Scrollable flat `(plugin_id, group)` accordions with count badges and per-group `Read` / `All` / `Clear` actions → (4) Sticky footer (live draft count + **Discard changes** + **Apply scopes**) | **Apply scopes** (sticky footer right) |
|
||||
| **3. `ApiTokenCreateDialog.vue` — Token Form View (Step 1, `max-w-[560px]`)** | `DialogTitle` (`"New API token"`, 20px/700) and auto-focused Name input | (1) Dialog header (title, description, Close `X`) → (2) Scrollable form stack: Name input → Expiration 4-segment radio bar + expiry preview → `ScopeAccessControl` (3-tier radio bar + compact summary box) → (3) Footer (**Discard token** + **Create token**) | **Create token** (footer right; `mod+s` / `mod+enter` active only here) |
|
||||
| **4. `ApiTokenCreateDialog.vue` — Swapped ScopePicker View (`max-w-[560px]`)** | `← Back to token` header + `DialogTitle` (`"Customize scopes"`, 20px/700) + auto-focused search input | (1) Fixed dialog header (`← Back to token` button + `"Customize scopes"` title + Close `X`) → (2) Sticky `ScopePicker` controls (Search → filter pills → opt-in `admin:read` banner) → (3) Scrollable flat accordions → (4) Sticky footer (live draft count + **Back to token** + **Apply scopes**) | **Apply scopes** (sticky footer right) |
|
||||
|
||||
### Icon-Only Controls & Accessible Labels
|
||||
|
||||
Every icon-only button and compact per-group quick action declares an explicit translated `aria-label`; all decorative icons carry `aria-hidden="true"`.
|
||||
|
||||
| Control | Icon (`@lucide/vue`) | Visible Label | Required `aria-label` (EN / PL) |
|
||||
|---------|----------------------|---------------|---------------------------------|
|
||||
| Dialog close button (`ConnectView` modal & `ApiTokenCreateDialog`) | `X` (16px) | none (icon-only) | `backend::lang.form.close` ("Close" / "Zamknij") |
|
||||
| Scope search clear button (`ScopePicker`) | `X` (16px) | none (icon-only) | `backend::lang.api_tokens.scope_search_clear` ("Clear search" / "Wyczyść wyszukiwanie") |
|
||||
| Accordion header toggle button | `ChevronDown` / `ChevronRight` (16px, `aria-hidden="true"`) | Group label + `selected/total` badge | None needed (visible text labels the button; carries `aria-expanded` and `aria-controls`) |
|
||||
| Per-group `Read` quick action | none | `Read` / `Odczyt` | `backend::lang.api_tokens.group_select_read_named` ("Select read-only scopes in :group" / "Zaznacz zakresy tylko do odczytu w grupie :group") |
|
||||
| Per-group `All` quick action | none | `All` / `Wszystkie` | `backend::lang.api_tokens.group_select_all_named` ("Select all scopes in :group" / "Zaznacz wszystkie zakresy w grupie :group") |
|
||||
| Per-group `Clear` quick action | none | `Clear` / `Wyczyść` | `backend::lang.api_tokens.group_clear_named` ("Clear selected scopes in :group" / "Wyczyść wybrane zakresy w grupie :group") |
|
||||
| Locked read-only badge (`via admin:read`) | `Lock` (14px, `aria-hidden="true"`) | `via admin:read` / `przez admin:read` | None needed (visible text accompanies icon; never communicates lock by icon or color alone) |
|
||||
| Decorative icons (`Search`, `SlidersHorizontal`, `ArrowLeft`, `Info`, `CircleAlert`, `LoaderCircle`, `Bot`, `Clock`, `Sun`) | 14–24px, `aria-hidden="true"` | Always paired with visible label/placeholder/text | Not focusable |
|
||||
|
||||
---
|
||||
|
||||
## Spacing Scale
|
||||
|
||||
All new Phase 36 layout spacing uses the 8-point scale strictly (multiples of 4 only; zero new non-4-multiple spacing values).
|
||||
|
||||
| Token | Value | Tailwind | Usage in Phase 36 |
|
||||
|-------|-------|----------|-------------------|
|
||||
| xs | 4px | `gap-1`, `p-1` | Segmented tier radio track padding; filter pill bar padding and button gap; per-group quick action gap; label-to-mono-code gap; `Lock`-to-text gap inside `via admin:read` and `admin:read` chips |
|
||||
| sm | 8px | `gap-2`, `px-2`, `py-2` | Summary box internal stack gap; summary chip wrap gap and chip horizontal padding (`px-2`); `ScopePicker` sticky header vertical stack gap and sticky footer button pair gap (`gap-2`); accordion list vertical gap; accordion header padding (`py-2`) and toggle icon-to-label gap; quick action horizontal padding (`px-2`); search clear button inset (`right-2`); empty-state vertical stack gap |
|
||||
| md | 16px | `gap-4`, `p-4`, `px-4`, `py-4` | Summary box padding (`p-4`); `ScopePicker` sticky header, scrollable body, and sticky footer padding (`p-4`); modal header padding (`p-4`); filter pill horizontal padding (`px-4`); accordion header horizontal padding (`px-4`); dialog section stack gap (`gap-4`) |
|
||||
| lg | 24px | `gap-6`, `p-6`, `px-6` | Wordmark-to-card column gap on `ConnectView` (inherited); `ApiTokenCreateDialog` Step 1/2 outer padding (`p-6`, inherited); empty-state horizontal padding (`px-6`) |
|
||||
| xl | 32px | `p-8`, `py-8` | `ConnectView` consent card padding (inherited); `ScopePicker` empty-state vertical padding (`py-8`) |
|
||||
| 2xl | 48px | `size-12` | `ConnectView` client mark / expired clock circle (size, inherited) |
|
||||
| 3xl | 64px | — | Not used |
|
||||
|
||||
Additional multiple-of-4 utility used on `ScopePicker` search icon inset: `12px` (`left-3`, matching the 40px `pl-10` text start with 16px icon + 12px left/right clearance).
|
||||
|
||||
**Inherited Direction C exceptions (copied verbatim from existing components; zero new non-4-multiple exceptions introduced):**
|
||||
- `18px` (`gap-[18px]`): `ConnectView` card stack gap and `ApiTokenCreateDialog` Step 1 fieldset stack gap (inherited from `LoginView`, `ConnectView`, `ApiTokenCreateDialog`).
|
||||
- `12px` (`py-3`, `gap-3`), `56px` (`min-h-[56px]`), `2px` (`mt-0.5`): scope row vertical padding, checkbox-to-text gap, minimum row height, and checkbox optical nudge (inherited from `ApiTokenCreateDialog` and `ConnectView` scope rows).
|
||||
- `10px` (`gap-2.5`, `px-2.5`): existing footer button pair gap (`ConnectView` Allow/Deny and `ApiTokenCreateDialog` Step 1 form footer) and inherited `Read-only` pill horizontal padding (`px-2.5`).
|
||||
- `14px` (`px-3.5`): `controlClass` horizontal input padding (overridden by `pl-10 pr-10` on the `ScopePicker` search input) and `LoginView`-style alert block horizontal padding (`px-3.5 py-3`).
|
||||
- `6px` (`gap-1.5`): label-to-control stack gap inside form fields (`ApiTokenCreateDialog`, `ConnectView`, and the `ScopeAccessControl` root that replaces their existing `data-field="scopes"` stack).
|
||||
|
||||
**Fixed component dimensions (sizes, not spacing):**
|
||||
- `44px` (`h-input`): `ConnectView` Allow/Deny buttons, search input, Name input, `admin:read` toggle row minimum height.
|
||||
- `42px` (`h-button`): `Button` (`size="md"`), `ScopePicker` footer buttons.
|
||||
- `38px` (`h-[38px]`): `Button` (`size="sm"`), **Customize scopes…** button, tier radio segment min-height, accordion toggle hit target.
|
||||
- `34px` (`size-[34px]`, `h-[34px]`): dialog Close `X` button, `← Back to token` header button, inherited wordmark circle.
|
||||
- `32px` (`h-8`): filter pills (`All`, `Selected`, `Read-only`) and per-group quick action buttons (`Read`, `All`, `Clear`).
|
||||
- `24px` (`h-6`): summary chips, `+N more` chip, `Read-only` badge, `via admin:read` badge, group count badge.
|
||||
- `20px` (`size-5`): checkboxes (`rounded-[6px]`).
|
||||
- Widths/heights: `ConnectView` card `max-w-[480px]`; `ConnectView` Customize modal `100dvh` full-screen on `< 640px` and `max-w-[640px] max-h-[85dvh]` on `≥ 640px` (D-10); `ApiTokenCreateDialog` fixed `max-w-[560px]` across all views (D-13).
|
||||
|
||||
---
|
||||
|
||||
## Typography
|
||||
|
||||
Four sizes total. All inherit DM Sans (`14px / 1.5`) from `html` in `admin/src/styles/main.css`.
|
||||
|
||||
| Role | Size | Weight | Line Height | Used by |
|
||||
|------|------|--------|-------------|---------|
|
||||
| Meta / Code | 13px | 400 / 600 | 1.5 | Scope mono code (`font-mono`), scope description, redirect host (`font-mono`), `admin:read` toggle subtext, summary subtitle (`tabular-nums`), footer draft count (`tabular-nums`), empty-state body; **600** for summary chips, `+N more` chip, `Read-only` pill, `via admin:read` badge, group selection count badge (`tabular-nums`), active filter pill, per-group quick actions (`Read`/`All`/`Clear`), inactive/active tier radio tab text |
|
||||
| Body / Label | 14px | 400 / 600 | 1.5 | **400**: consent subline, dialog description, search input text, signed-in admin value, alert text, expired/error copy. **600**: field labels (`Access level`, `Scopes`), tier active label, group accordion title, scope row title, `admin:read` toggle title, summary full/read-only heading, `← Back to token`, **Customize scopes…**, **Apply scopes**, **Discard changes**, **Allow**, **Deny**, **Create token** |
|
||||
| Dialog Heading | 20px | 700 *(inherited)* | 1.2 (`tracking-[-0.01em]`) | `ApiTokenCreateDialog` `DialogTitle` (all views: `"New API token"`, `"Customize scopes"`, `"Copy your new token"`) and `ConnectView` Customize scopes `DialogTitle` (`"Customize scopes"`) |
|
||||
| Consent Heading | 22px | 700 *(inherited)* | 1.2 (`tracking-[-0.02em]`) | `ConnectView` card `h1` across all states (copied verbatim from `LoginView` / Phase 32.2) |
|
||||
|
||||
**Weight rule:** All new content in Phase 36 uses weights **400 and 600 only**. Weight **700 is the inherited heading-only exception** locked in Phase 16.3 and re-applied in Phase 32.2 — it appears exclusively on the 22px `ConnectView` `h1`, the 20px `DialogTitle`, and the unchanged inherited 18px wordmark / `ApiTokensPanel` `h2`.
|
||||
**Monospace & numerals:** DM Mono (`font-mono`) is used only for scope codes (`*`, `admin:read`, `journal:read`), redirect host, and the Step 2 plaintext token. `tabular-nums` is required on every counter (`selected/total`, filter pill counts, `+N more`, summary counts, footer draft counts) and every date.
|
||||
|
||||
---
|
||||
|
||||
## Color
|
||||
|
||||
### Surface-Matched Theming Mechanism (D-12, Zero New Tokens)
|
||||
|
||||
`ScopeAccessControl.vue` and `ScopePicker.vue` use **only semantic Direction C v2 Tailwind utilities** (`bg-surface`, `bg-subtle`, `bg-hover`, `border-border`, `border-border-strong`, `text-text`, `text-muted`, `placeholder:text-placeholder`, `bg-primary`, `text-on-primary`, `accent-primary`, `text-danger`, `border-danger`, `bg-danger-soft`, `bg-skel`).
|
||||
|
||||
- **`ApiTokenCreateDialog.vue` (authenticated admin shell):** Inherits `:root` in light mode and `.dark` in dark mode automatically.
|
||||
- **`ConnectView.vue` (standalone login/consent flow):** Applies `.connect-light-surface` — defined definitively in `@layer components` in `admin/src/styles/main.css` (never Vue `<style scoped>`, because Reka `DialogPortal` teleports `DialogOverlay` and `DialogContent` directly into `document.body` outside `<main>`) — on BOTH the consent card container AND the portaled Reka `DialogOverlay` + `DialogContent` of the Customize scopes modal.
|
||||
|
||||
**Why `.connect-light-surface` re-declares both `--c-*` and `--color-*`:** In `admin/src/styles/main.css`, Tailwind v4 `@theme` compiles `--color-surface: var(--c-surface);` (etc.) onto `:root`, and Tailwind color utilities (`bg-surface`, `text-text`, `border-border`, `bg-overlay`, etc.) read `var(--color-*)`. When `<html class="dark">` is active, `--color-*` resolves to the dark `.dark` values at `:root` and descendants inherit those computed dark values — overriding only `--c-*` on a descendant does **not** re-evaluate `--color-*`. Declaring both the light-literal `--c-*` values (read directly by base `:focus-visible`, `::placeholder`, and partial rules) AND re-binding the existing `--color-*` aliases inside `.connect-light-surface` forces CSS custom property re-evaluation against the scoped light `--c-*` values without adding any new tokens to `:root` or `.dark`:
|
||||
|
||||
```css
|
||||
/* Inside @layer components in admin/src/styles/main.css */
|
||||
.connect-light-surface {
|
||||
color-scheme: light;
|
||||
--c-bg: #f4f6f9;
|
||||
--c-surface: #ffffff;
|
||||
--c-subtle: #f3f5f8;
|
||||
--c-border: #e6e9ef;
|
||||
--c-border-strong: #d2d8e2;
|
||||
--c-text: #141b2d;
|
||||
--c-muted: #566175;
|
||||
--c-placeholder: #6b7588;
|
||||
--c-primary: #22304d;
|
||||
--c-on-primary: #ffffff;
|
||||
--c-danger: #c62828;
|
||||
--c-danger-soft: #fdf0f0;
|
||||
--c-ring: rgba(252, 196, 40, 0.55);
|
||||
--c-hover: #f1f3f7;
|
||||
--c-sel: #fdf3cf;
|
||||
--c-skel: #eceff4;
|
||||
--c-overlay: rgba(20, 27, 45, 0.5);
|
||||
|
||||
--color-bg: var(--c-bg);
|
||||
--color-surface: var(--c-surface);
|
||||
--color-subtle: var(--c-subtle);
|
||||
--color-border: var(--c-border);
|
||||
--color-border-strong: var(--c-border-strong);
|
||||
--color-text: var(--c-text);
|
||||
--color-muted: var(--c-muted);
|
||||
--color-placeholder: var(--c-placeholder);
|
||||
--color-primary: var(--c-primary);
|
||||
--color-on-primary: var(--c-on-primary);
|
||||
--color-danger: var(--c-danger);
|
||||
--color-danger-soft: var(--c-danger-soft);
|
||||
--color-ring: var(--c-ring);
|
||||
--color-hover: var(--c-hover);
|
||||
--color-sel: var(--c-sel);
|
||||
--color-skel: var(--c-skel);
|
||||
--color-overlay: var(--c-overlay);
|
||||
}
|
||||
```
|
||||
|
||||
### 60 / 30 / 10 Color Split
|
||||
|
||||
#### Surface A: `ConnectView.vue` Card & Customize Modal (Light-Literal via `.connect-light-surface`)
|
||||
|
||||
| Role | Share | Values | Usage |
|
||||
|------|-------|--------|-------|
|
||||
| Dominant | 60% | Page gradient `radial-gradient(ellipse at 50% 35%, #2b3a5c 0%, #1d2740 60%)`; `#ffffff` (`--c-surface`) | Page backdrop; consent card; Customize modal header/body/footer; accordion rows; active radio/filter tab; outline buttons |
|
||||
| Secondary | 30% | `#f3f5f8` (`--c-subtle`), `#e6e9ef` (`--c-border`), `#d2d8e2` (`--c-border-strong`), `#f1f3f7` (`--c-hover`), `#141b2d` (`--c-text`), `#566175` (`--c-muted`), `#6b7588` (`--c-placeholder`), `#eceff4` (`--c-skel`), `rgba(20,27,45,0.5)` (`--c-overlay`) | Fact box, segmented radio track, summary box, `admin:read` banner, accordion headers, locked `via admin:read` row tint, dividers, borders, meta/body text, skeletons, modal backdrop |
|
||||
| Accent | 10% | `#22304d` (`--c-primary`) with `#ffffff` (`--c-on-primary`); inherited wordmark `#fcd34d` (`accent`) / `rgba(252,211,77,0.14)` (`accent-soft`); focus ring `rgba(252,196,40,0.55)` (`--c-ring`) | Strictly limited to the exhaustive list below |
|
||||
| Destructive | — | `#c62828` (`--c-danger`) / `#fdf0f0` (`--c-danger-soft`) | Error alert blocks (`load_failed`, `decide_failed`, `none_grantable`, `scopes_required`) and invalid summary box border only |
|
||||
|
||||
#### Surface B: `ApiTokenCreateDialog.vue` Token Form & Swapped ScopePicker (Semantic Tokens — Light & Dark)
|
||||
|
||||
| Role | Share | Light / Dark Token Values | Usage |
|
||||
|------|-------|---------------------------|-------|
|
||||
| Dominant | 60% | `bg-surface` (`#ffffff` / `#182033`), `bg-overlay` (`rgba(20,27,45,0.5)` / `rgba(5,8,16,0.7)`) | Dialog canvas, accordion rows, active radio/filter tab, inputs, outline buttons, modal backdrop |
|
||||
| Secondary | 30% | `bg-subtle` (`#f3f5f8` / `#1f283d`), `border-border` (`#e6e9ef` / `#29334b`), `border-border-strong` (`#d2d8e2` / `#3a4661`), `bg-hover` (`#f1f3f7` / `#212b42`), `text-text` (`#141b2d` / `#eef1f6`), `text-muted` (`#566175` / `#a9b3c6`), `text-placeholder` (`#6b7588` / `#8a95ab`), `bg-skel` (`#eceff4` / `#263049`), `bg-sel` (`#fdf3cf` / `#3a3622` Step 2 notice) | Segmented tracks, summary box, `admin:read` toggle banner, accordion headers, locked `via admin:read` row tint, badges, chips, dividers, text, skeletons |
|
||||
| Accent | 10% | `bg-primary` / `text-on-primary` / `accent-primary` (`#22304d`+`#ffffff` light / `#fcd34d`+`#1b2540` dark); focus ring `--c-ring` | Strictly limited to the exhaustive list below |
|
||||
| Destructive | — | `text-danger` / `border-danger` / `bg-danger-soft` (`#c62828`+`#fdf0f0` light / `#f58a8a`+`#3a1d24` dark) | Validation errors, `scopes_failed` alert, and Step 2 uncopied-close confirm dialog only |
|
||||
|
||||
### Accent Reserved For (Exhaustive)
|
||||
|
||||
1. **Single primary CTA button per active view (`bg-primary text-on-primary`):** **Allow** on the consent card, **Create token** on the token form, **Done, hide token** on Step 2, and **Apply scopes** in `ScopePicker`.
|
||||
2. **Checked checkbox tint (`accent-primary`):** scope checkboxes, the opt-in `admin:read` toggle checkbox, and the `ConnectView` "Stay connected" checkbox.
|
||||
3. **Input focus border (`border-primary`) & 3px keyboard focus ring (`--c-ring`):** `:focus-visible` on every interactive element (base style in `main.css`, never removed).
|
||||
4. **Wordmark sun circle and `"CMS"` (`accent` / `accent-soft`):** inherited from `LoginView` on `ConnectView` only.
|
||||
|
||||
### Accent Never Used For
|
||||
|
||||
- Secondary/neutral action buttons: **Deny**, **Discard changes**, **Back to token**, **Discard token**, **Customize scopes…**, **Clear search**, **Show all scopes**, **Try again**, **Go to the admin panel**, **Use another account**, and Close (`X`).
|
||||
- Segmented tier tabs (`Full (*)`, `Read-only`, `Custom`) and filter pills (`All`, `Selected`, `Read-only`) — these use the neutral elevated tab style (`bg-surface text-text shadow-tab font-semibold` inside a `bg-subtle` track).
|
||||
- Per-group quick action buttons (`Read`, `All`, `Clear`).
|
||||
- Summary chips (`admin:read`, write, read-only), `+N more` chip, `Read-only` pills, `via admin:read` lock badges, and accordion count badges (`selected/total`).
|
||||
- Accordion headers, scope mono codes, redirect host, or empty-state icons.
|
||||
- **Deny** and **Discard changes** are never styled as destructive; they are safe, reversible choices.
|
||||
|
||||
---
|
||||
|
||||
## Copywriting Contract
|
||||
|
||||
Polish is the design language; English pairs ship alongside it in `modules/phrasebook/backend/lang/{en,pl}/lang.yaml`. Placeholders use phrasebook `:name` syntax. Pluralized keys use CLDR categories (`one`/`other` for English; `one`/`few`/`many`/`other` for Polish), evaluated by `tc()` in `admin/src/app/i18n.ts`. Server-delivered scope labels, descriptions, and resolved group names always render as text, never HTML.
|
||||
|
||||
### New & Updated Keys under `backend::lang.api_tokens.*`
|
||||
|
||||
All shared scope-tier and picker strings live under `api_tokens:` so both `ConnectView.vue` and `ApiTokenCreateDialog.vue` consume one canonical set of keys.
|
||||
|
||||
| Key (`backend::lang.api_tokens.*`) | English (`en/lang.yaml`) | Polish (`pl/lang.yaml`) | Usage |
|
||||
|------------------------------------|--------------------------|-------------------------|-------|
|
||||
| `access_level` | `Access level` | `Poziom dostępu` | Label above the 3-tier `RadioGroupRoot` |
|
||||
| `tier_full` | `Full (*)` | `Pełny (*)` | Tier 1 radio label |
|
||||
| `tier_read_only` | `Read-only` | `Tylko odczyt` | Tier 2 radio label |
|
||||
| `tier_custom` | `Custom` | `Własny` | Tier 3 radio label |
|
||||
| `scope_customize` | `Customize scopes…` | `Dostosuj zakresy…` | Button in Custom summary box that opens `ScopePicker` |
|
||||
| `scope_more` | `+:count more` | `+:count więcej` | Clickable overflow chip when selected chips exceed 6 |
|
||||
| `scope_count` *(CLDR plural)* | `one: ":count scope"` / `other: ":count scopes"` | `one: ":count zakres"` / `few: ":count zakresy"` / `many: ":count zakresów"` / `other: ":count zakresu"` | Scope count fragment for summary & footer |
|
||||
| `scope_write_count` *(CLDR plural)* | `one: ":count write scope"` / `other: ":count write scopes"` | `one: ":count zakres zapisu"` / `few: ":count zakresy zapisu"` / `many: ":count zakresów zapisu"` / `other: ":count zakresu zapisu"` | Write-scope count fragment when `admin:read` is enabled |
|
||||
| `scope_plugin_count` *(CLDR plural)* | `one: ":count plugin"` / `other: ":count plugins"` | `one: ":count wtyczce"` / `few: ":count wtyczkach"` / `many: ":count wtyczkach"` / `other: ":count wtyczki"` | Locative plugin count fragment for `across :plugins` / `w :plugins` |
|
||||
| `scope_summary_line` | `:scopes across :plugins` | `:scopes w :plugins` | Custom summary subtitle when `admin:read` is OFF and ≥ 1 plugin scope is selected (e.g. `3 scopes across 2 plugins` / `3 zakresy w 2 wtyczkach`) |
|
||||
| `scope_summary_admin_read_only` | `Read-only across the whole admin` | `Tylko odczyt w całym panelu` | Custom summary subtitle when `admin:read` is ON and 0 write scopes are selected |
|
||||
| `scope_summary_admin_read_plus` | `All read-only + :scopes across :plugins` | `Cały odczyt + :scopes w :plugins` | Custom summary subtitle when `admin:read` is ON and ≥ 1 write scope is selected |
|
||||
| `scope_summary_empty` | `No scopes selected yet. Choose Customize scopes to pick access.` | `Nie wybrano jeszcze żadnych zakresów. Kliknij Dostosuj zakresy, aby określić dostęp.` | Custom summary empty state (actionable) |
|
||||
| `scope_picker_title` | `Customize scopes` | `Dostosuj zakresy` | `DialogTitle` in both `ConnectView` modal and `ApiTokenCreateDialog` swapped view |
|
||||
| `scope_picker_description` | `Choose which scopes this token may use.` | `Wybierz zakresy, których może używać ten token.` | `DialogDescription` in `ApiTokenCreateDialog` swapped view |
|
||||
| `scope_picker_apply` | `Apply scopes` | `Zastosuj zakresy` | Primary CTA in `ScopePicker` sticky footer |
|
||||
| `scope_picker_discard` | `Discard changes` | `Odrzuć zmiany` | Secondary CTA in `ConnectView` Customize modal footer |
|
||||
| `scope_picker_back` | `Back to token` | `Wróć do tokenu` | Back button in `ApiTokenCreateDialog` swapped view header and footer |
|
||||
| `scope_picker_selected` | `:scopes selected` | `Wybrano: :scopes` | `ScopePicker` footer live summary when `admin:read` is OFF and ≥ 1 scope ticked |
|
||||
| `scope_picker_selected_admin_read` | `All read-only + :scopes` | `Cały odczyt + :scopes` | `ScopePicker` footer live summary when `admin:read` is ON and ≥ 1 write scope ticked |
|
||||
| `scope_picker_none_selected` | `Choose at least one scope to apply.` | `Wybierz co najmniej jeden zakres, aby zastosować.` | `ScopePicker` footer hint when draft has 0 effective scopes (explains why **Apply scopes** is disabled) |
|
||||
| `scope_search_label` | `Search scopes` | `Szukaj zakresów` | `aria-label` on `ScopePicker` search input |
|
||||
| `scope_search_placeholder` | `Search plugins, groups, or scopes…` | `Szukaj wtyczek, grup lub zakresów…` | Placeholder on `ScopePicker` search input |
|
||||
| `scope_search_clear` | `Clear search` | `Wyczyść wyszukiwanie` | `aria-label` on search clear `X` button and CTA in empty search state |
|
||||
| `scope_filter_label` | `Filter scopes` | `Filtruj zakresy` | `aria-label` on the filter pill group |
|
||||
| `scope_filter_all` | `All (:count)` | `Wszystkie (:count)` | Filter pill 1 |
|
||||
| `scope_filter_selected` | `Selected (:count)` | `Wybrane (:count)` | Filter pill 2 |
|
||||
| `scope_filter_read_only` | `Read-only (:count)` | `Tylko odczyt (:count)` | Filter pill 3 |
|
||||
| `scope_filter_reset` | `Show all scopes` | `Pokaż wszystkie zakresy` | Action CTA in empty `Selected` / `Read-only` filter states |
|
||||
| `scope_also_admin_read` | `Also allow reading all other plugins` | `Zezwól także na odczyt ze wszystkich pozostałych wtyczek` | Opt-in `admin:read` toggle label inside Custom (D-04; mono `admin:read` renders beside it) |
|
||||
| `scope_also_admin_read_hint` | `Locks every read-only scope below. Leave unticked to block reading specific resources.` | `Blokuje jako zaznaczone wszystkie poniższe zakresy tylko do odczytu. Pozostaw odznaczone, aby wykluczyć odczyt wybranych zasobów.` | Opt-in `admin:read` toggle helper line |
|
||||
| `via_admin_read` | `via admin:read` | `przez admin:read` | Lock badge shown on every `read_only` scope row when `admin:read` toggle is ON (D-04) |
|
||||
| `group_select_read` | `Read` | `Odczyt` | Compact per-group quick action label |
|
||||
| `group_select_all` | `All` | `Wszystkie` | Compact per-group quick action label |
|
||||
| `group_clear` | `Clear` | `Wyczyść` | Compact per-group quick action label |
|
||||
| `group_select_read_named` | `Select read-only scopes in :group` | `Zaznacz zakresy tylko do odczytu w grupie :group` | Screen-reader `aria-label` for per-group `Read` button |
|
||||
| `group_select_all_named` | `Select all scopes in :group` | `Zaznacz wszystkie zakresy w grupie :group` | Screen-reader `aria-label` for per-group `All` button |
|
||||
| `group_clear_named` | `Clear selected scopes in :group` | `Wyczyść wybrane zakresy w grupie :group` | Screen-reader `aria-label` for per-group `Clear` button |
|
||||
| `scope_empty_search_title` | `No matching scopes` | `Brak pasujących zakresów` | Empty state heading when search query matches 0 scopes |
|
||||
| `scope_empty_search_body` | `No plugins, groups, or scopes match “:query”. Clear the search or try another term.` | `Żadne wtyczki, grupy ani zakresy nie pasują do „:query”. Wyczyść wyszukiwanie lub wpisz inne słowo.` | Empty state actionable body for search |
|
||||
| `scope_empty_selected_title` | `No scopes selected yet` | `Nie wybrano jeszcze żadnych zakresów` | Empty state heading when `Selected` filter is active with 0 selected scopes |
|
||||
| `scope_empty_selected_body` | `Switch to All scopes to pick what this grant may access.` | `Przełącz na Wszystkie zakresy, aby wybrać uprawnienia.` | Empty state actionable body for `Selected` filter |
|
||||
| `scope_empty_readonly_title` | `No read-only scopes in this list` | `Brak zakresów tylko do odczytu na tej liście` | Empty state heading when `Read-only` filter is active with 0 read-only plugin scopes |
|
||||
| `scope_empty_readonly_body` | `Switch to All scopes to view the available write scopes.` | `Przełącz na Wszystkie zakresy, aby zobaczyć dostępne zakresy zapisu.` | Empty state actionable body for `Read-only` filter |
|
||||
|
||||
### New & Updated Keys under `backend::lang.mcp_connect.*`
|
||||
|
||||
| Key (`backend::lang.mcp_connect.*`) | English (`en/lang.yaml`) | Polish (`pl/lang.yaml`) | Usage |
|
||||
|-------------------------------------|--------------------------|-------------------------|-------|
|
||||
| `subline` *(updated)* | `The agent gets your permissions, limited to the access you choose. It never gets more access than your own account.` | `Agent otrzyma Twoje uprawnienia w granicach wybranego dostępu. Nigdy nie dostanie szerszego dostępu niż Twoje konto.` | Replaces `"scopes you tick"` phrasing now that access uses 3-tier + modal |
|
||||
| `scope_picker_description` *(new)* | `Choose which scopes :client may use on your behalf.` | `Wybierz zakresy, których aplikacja :client może używać w Twoim imieniu.` | `DialogDescription` in `ConnectView` Customize scopes modal (client name stays in nominative in Polish after `aplikacja`) |
|
||||
|
||||
### Error States (Preserved & Reused)
|
||||
|
||||
- `ConnectView` load failure (`mcp_connect.load_failed` + `Try again`), expired (`mcp_connect.expired_heading` / `expired_body` + `Go to the admin panel`), no grantable scopes (`mcp_connect.none_grantable`, Deny only), 422 `no_grantable_scopes` (`api_tokens.scopes_required` shown under `ScopeAccessControl`), submit failure (`mcp_connect.decide_failed`), 401 (`expireSession` → login): **unchanged from Phase 32.2**.
|
||||
- `ApiTokenCreateDialog` scopes load failure (`api_tokens.scopes_failed`: *"The scopes could not be loaded. Close this window and try again."*) and 422 field validation (`errors.name`, `errors.scopes`, `errors.expires`) and network failure toast (`api_tokens.create_failed`): **unchanged from Phase 16.3**.
|
||||
|
||||
### Destructive Actions
|
||||
|
||||
| Action | Confirmation Approach | Copy (EN / PL) |
|
||||
|--------|----------------------|----------------|
|
||||
| **Discard changes** / **Back to token** / **Escape** in `ScopePicker` | **No confirmation.** Draft edits inside the picker are lightweight and immediately re-selectable; discarding never mutates persisted tokens or consents | `api_tokens.scope_picker_discard` ("Discard changes" / "Odrzuć zmiany") and `api_tokens.scope_picker_back` ("Back to token" / "Wróć do tokenu") |
|
||||
| **Deny** (consent screen) | **No confirmation.** Reversible: the agent can request connection again (Phase 32.2) | `mcp_connect.deny` ("Deny" / "Odmów") |
|
||||
| **Discard token** (Step 1 close) | **No confirmation.** No token has been minted yet (Phase 16.3) | `api_tokens.create_cancel` ("Discard token" / "Odrzuć token") |
|
||||
| **Close without copying plaintext token** (Step 2) | **ConfirmDialog (`danger: true`), unchanged from Phase 16.3.** Plaintext cannot be viewed again once closed | `api_tokens.close_uncopied_confirm` / `api_tokens.close_uncopied_submit` ("Close and hide token" / "Zamknij i ukryj token") |
|
||||
| **Revoke token** (`ApiTokensPanel.vue`) | **ConfirmDialog (`danger: true`), unchanged from Phase 16.3.** | `api_tokens.revoke_confirm` / `api_tokens.revoke_submit` ("Revoke token" / "Unieważnij token") |
|
||||
|
||||
---
|
||||
|
||||
## Component Contracts
|
||||
|
||||
### C1. Shared Scope Logic & Grouping — `admin/src/app/scopeCatalog.ts` & `admin/src/components/scopes/useScopeSelection.ts`
|
||||
|
||||
**Types (`scopeCatalog.ts`):**
|
||||
- Consumes generated `AdminAPITokenScope` (`{ name: string; label: string; description: string; read_only: boolean; known: boolean; plugin_id: string; group: string }`, D-15).
|
||||
- `export type AccessTier = 'full' | 'read_only' | 'custom'`
|
||||
- `export type ScopeFilter = 'all' | 'selected' | 'read_only'`
|
||||
- `export interface ScopeGroup { key: string; pluginId: string; label: string; scopes: AdminAPITokenScope[] }`
|
||||
- `export interface CustomScopeSelection { adminRead: boolean; scopes: Set<string> }`
|
||||
- `export interface ScopeSummaryChip { key: string; name: string; label: string; kind: 'admin_read' | 'write' | 'read_only' }`
|
||||
|
||||
**Pure Functions (`scopeCatalog.ts`):**
|
||||
1. **`partitionCatalog(catalog)`:** Splits `catalog` into:
|
||||
- `fullScope`: scope with `name === '*'` (or `null`)
|
||||
- `adminReadScope`: scope with `name === 'admin:read'` (or `null`)
|
||||
- `pluginScopes`: all other scopes in server catalog order
|
||||
2. **`groupPluginScopes(pluginScopes, locale, fallbackGroupLabel)` (D-17):**
|
||||
- Keys each distinct `(plugin_id, group)` pair by `${scope.plugin_id}\0${scope.group}` so two plugins never collide even when their translated group label matches.
|
||||
- Resolved label: `scope.group.trim() || scope.plugin_id.trim() || fallbackGroupLabel` (`backend::lang.permissioneditor.other`).
|
||||
- Preserves the plugin's declared scope order inside each group.
|
||||
- Sorts groups alphabetically with `new Intl.Collator(locale, { sensitivity: 'base' }).compare(a.label, b.label)`, tie-breaking lexicographically on `a.pluginId.localeCompare(b.pluginId)`.
|
||||
3. **`matchesScopeQuery(scope, groupLabel, query)`:**
|
||||
- Normalized (`query.trim().toLowerCase()`). Empty query matches all.
|
||||
- Substring match across `scope.name`, `scope.label`, `scope.description`, `scope.plugin_id`, and `groupLabel`.
|
||||
4. **`isEffectivelySelected(scope, selection)` (D-04):**
|
||||
- Returns `true` when `selection.scopes.has(scope.name)` OR `(selection.adminRead && scope.read_only)`.
|
||||
5. **`computeDefaultExpanded(groups, totalPluginScopes, selection, searching)` (D-07):**
|
||||
- If `searching`: returns `new Set(groups.map(g => g.key))` (every matching group expanded).
|
||||
- Else if `groups.length <= 3 || totalPluginScopes <= 12`: returns `new Set(groups.map(g => g.key))` (small catalog expands all).
|
||||
- Else: returns only group keys where at least one scope has `isEffectivelySelected(scope, selection) === true` (all collapsed when none selected).
|
||||
6. **`buildSummaryModel(catalog, selection, maxVisible = 6)` (D-06):**
|
||||
- Builds elevated-first chips:
|
||||
1. If `selection.adminRead && adminReadScope`: `{ key: 'admin:read', name: 'admin:read', label: 'admin:read', kind: 'admin_read' }`
|
||||
2. Every selected non-`read_only` plugin scope in catalog order (`kind: 'write'`, `label: scope.label`)
|
||||
3. Only when `!selection.adminRead`: every selected `read_only` plugin scope in catalog order (`kind: 'read_only'`, `label: scope.label`)
|
||||
- `visible`: `chips.slice(0, maxVisible)`; `overflowCount`: `Math.max(0, chips.length - maxVisible)`.
|
||||
- `selectedWriteCount`: count of selected non-`read_only` plugin scopes.
|
||||
- `selectedPluginCount`: count of selected plugin scopes (when `!selection.adminRead`, all selected plugin scopes; when `selection.adminRead`, `selectedWriteCount`).
|
||||
- `distinctPluginCount`: count of unique `(scope.plugin_id || scope.group || scope.name)` keys among the counted plugin scopes.
|
||||
7. **`computeSubmittedScopes(tier, catalog, custom)` (D-04):**
|
||||
- `'full'` → `fullScope ? ['*'] : []`
|
||||
- `'read_only'` → `adminReadScope ? ['admin:read'] : []`
|
||||
- `'custom'`:
|
||||
- When `custom.adminRead && adminReadScope`: `['admin:read', ...pluginScopes.filter(s => !s.read_only && custom.scopes.has(s.name)).map(s => s.name)]` (keeps token scope list concise because `admin:read` already grants all `GET`/`HEAD`, while preserving prior `:read` ticks in `custom.scopes` memory if the user later toggles `admin:read` back OFF).
|
||||
- When `!custom.adminRead`: `pluginScopes.filter(s => custom.scopes.has(s.name)).map(s => s.name)` (omits `admin:read` so unticking any `:read` scope genuinely blocks read access, D-04).
|
||||
8. **`resolveInitialState(catalog, mode: 'connect' | 'token')` (D-03, D-08):**
|
||||
- `'connect'` (D-03):
|
||||
1. If `adminReadScope !== null` → `{ tier: 'read_only', custom: { adminRead: false, scopes: new Set() } }`
|
||||
2. Else if `pluginScopes.length > 0` (client requested only a narrow subset without `admin:read` or `*`) → `{ tier: 'custom', custom: { adminRead: false, scopes: new Set(pluginScopes.map(s => s.name)) } }`
|
||||
3. Else if `fullScope !== null` → `{ tier: 'full', custom: { adminRead: false, scopes: new Set() } }`
|
||||
4. Else → `{ tier: 'read_only', custom: { adminRead: false, scopes: new Set() } }` (ConnectView renders `none_grantable` because `catalog.length === 0`).
|
||||
- `'token'` (D-08):
|
||||
1. If `adminReadScope !== null` → `{ tier: 'read_only', custom: { adminRead: false, scopes: new Set() } }`
|
||||
2. Else if `fullScope !== null` → `{ tier: 'full', custom: { adminRead: false, scopes: new Set() } }`
|
||||
3. Else → `{ tier: 'custom', custom: { adminRead: false, scopes: new Set() } }`.
|
||||
|
||||
**Composable (`useScopeSelection.ts`, D-03, D-09, D-11):**
|
||||
- Exposes `availableTiers` (order: `'full'` if `fullScope`, `'read_only'` if `adminReadScope`, `'custom'` if `pluginScopes.length > 0` — hides `Custom` when no plugin scopes exist, D-03), `tier`, `custom`, `pickerOpen`, `draft`, `submittedScopes`, `summary`, `canSubmitScopes`.
|
||||
- **`selectTier(next: AccessTier)`:**
|
||||
- If `next === tier.value`, no-op.
|
||||
- Switching away from `'custom'` to `'full'` or `'read_only'` preserves `custom.value` in memory (D-09).
|
||||
- Switching to `'custom'` when `!custom.value.adminRead && custom.value.scopes.size === 0` sets `autoOpenedFrom = previousTier`, sets `tier.value = 'custom'`, and calls `openPicker()` immediately (D-09).
|
||||
- Switching to `'custom'` when `custom.value` is already non-empty restores the saved custom selection on the summary card without forcing the picker open (D-09).
|
||||
- **`openPicker()`:** Clones `custom.value` (`adminRead` + `new Set(custom.value.scopes)`) into `draft.value` and sets `pickerOpen.value = true`.
|
||||
- **`applyPicker()`:** Commits `draft.value` to `custom.value`, sets `tier.value = 'custom'`, clears `autoOpenedFrom = null`, and sets `pickerOpen.value = false` (D-11).
|
||||
- **`discardPicker()`:** Drops `draft.value`, leaves `custom.value` untouched, closes `pickerOpen.value = false`, and if `autoOpenedFrom !== null`, restores `tier.value = autoOpenedFrom` and clears `autoOpenedFrom = null` (D-11).
|
||||
|
||||
---
|
||||
|
||||
### C2. `ScopeAccessControl.vue` (`admin/src/components/scopes/ScopeAccessControl.vue`)
|
||||
|
||||
**Props:**
|
||||
- `catalog: readonly AdminAPITokenScope[]`
|
||||
- `availableTiers: readonly AccessTier[]`
|
||||
- `tier: AccessTier`
|
||||
- `custom: CustomScopeSelection`
|
||||
- `disabled?: boolean`
|
||||
- `invalid?: boolean`
|
||||
- `idPrefix: string` (e.g. `'connect'` or `'api-token'`)
|
||||
|
||||
**Emits:**
|
||||
- `'update:tier': [tier: AccessTier]`
|
||||
- `'customize': []`
|
||||
|
||||
**Markup & Layout:**
|
||||
- Outer wrapper: `flex min-w-0 flex-col gap-1.5` (inherited field-label stack).
|
||||
- Label: `<span :id="`${idPrefix}-access-label`" class="font-semibold text-text">{{ t('backend::lang.api_tokens.access_level') }}</span>`.
|
||||
- **3-tier `RadioGroupRoot`** (`v-if="availableTiers.length > 1"`, `:model-value="tier"`, `orientation="horizontal"`, `:disabled="disabled"`, `:aria-labelledby="`${idPrefix}-access-label`"`, `data-access-tiers`):
|
||||
- Track: `grid gap-1 rounded-inner border border-border bg-subtle p-1` with `grid-cols-3` when 3 tiers are available, `grid-cols-2` when 2 tiers are available.
|
||||
- Each `RadioGroupItem` (`:value="item"`, `:data-access-tier="item"`):
|
||||
`inline-flex min-h-[38px] items-center justify-center rounded-tab px-2 py-2 text-center text-[13px] text-muted transition-colors duration-150 ease-out hover:text-text data-[state=checked]:bg-surface data-[state=checked]:text-text data-[state=checked]:shadow-tab data-[state=checked]:font-semibold disabled:cursor-not-allowed disabled:opacity-60`.
|
||||
- Labels: `'full'` → `api_tokens.tier_full`, `'read_only'` → `api_tokens.tier_read_only`, `'custom'` → `api_tokens.tier_custom`.
|
||||
- **Compact Summary Box** (`data-scope-summary`, `role="region"`, `:aria-labelledby="`${idPrefix}-access-label`"`, `:aria-invalid="invalid ? 'true' : undefined"`, `:class="invalid ? 'border-danger' : 'border-border'"`, `flex flex-col gap-2 rounded-inner border bg-subtle p-4`):
|
||||
- **When `tier === 'full'`:**
|
||||
- Row 1 (`flex flex-wrap items-center gap-1`): `<span class="font-semibold text-text">{{ fullScope.label }}</span>` + `<span class="font-mono text-[13px] text-muted">*</span>`.
|
||||
- Row 2: `<p class="text-[13px] text-muted [overflow-wrap:anywhere]">{{ fullScope.description }}</p>`.
|
||||
- Row 3 (`data-scope-all-note`, `flex items-center gap-2 text-[13px] text-muted`): `<Info :size="14" class="shrink-0" aria-hidden="true" />` + `t('backend::lang.api_tokens.scope_all_includes')`.
|
||||
- **When `tier === 'read_only'`:**
|
||||
- Row 1 (`flex flex-wrap items-center gap-1`): `<span class="font-semibold text-text">{{ adminReadScope.label }}</span>` + `<span class="font-mono text-[13px] text-muted">admin:read</span>` + inherited `Read-only` pill (`inline-flex h-6 items-center rounded-pill border border-border bg-surface px-2.5 text-[13px] font-semibold whitespace-nowrap text-muted`).
|
||||
- Row 2: `<p class="text-[13px] text-muted [overflow-wrap:anywhere]">{{ adminReadScope.description }}</p>`.
|
||||
- **When `tier === 'custom'`:**
|
||||
- Header row (`flex flex-wrap items-center justify-between gap-2`):
|
||||
- Subtitle `<p data-scope-summary-count class="text-[13px] text-muted tabular-nums [overflow-wrap:anywhere]">` using `scope_summary_empty` / `scope_summary_admin_read_only` / `scope_summary_admin_read_plus` / `scope_summary_line`.
|
||||
- **Customize scopes…** button (`ref="customizeButton"`, `type="button"`, `data-action="customize-scopes"`, `:disabled="disabled"`, `inline-flex h-[38px] shrink-0 items-center justify-center gap-2 rounded-control border border-border-strong bg-surface px-4 text-[14px] font-semibold whitespace-nowrap text-text transition-colors duration-150 ease-out hover:bg-hover disabled:cursor-not-allowed disabled:opacity-60`): `<SlidersHorizontal :size="16" aria-hidden="true" />` + `t('backend::lang.api_tokens.scope_customize')`.
|
||||
- Chip list (`v-if="summary.visible.length > 0"`, `data-scope-summary-chips`, `flex flex-wrap gap-2`):
|
||||
- `admin_read` chip (`data-summary-chip="admin:read"`, `:title="adminReadScope?.label"`): `inline-flex h-6 items-center gap-1 rounded-pill border border-border-strong bg-surface px-2 font-mono text-[13px] font-semibold whitespace-nowrap text-text` with `<Lock :size="14" class="shrink-0 text-muted" aria-hidden="true" />` + `admin:read`.
|
||||
- `write` chip (`:data-summary-chip="chip.name"`, `:title="chip.name"`): `inline-flex h-6 max-w-full items-center rounded-pill border border-border-strong bg-surface px-2 text-[13px] font-semibold text-text` with `<span class="truncate">{{ chip.label }}</span>`.
|
||||
- `read_only` chip (`:data-summary-chip="chip.name"`, `:title="chip.name"`): `inline-flex h-6 max-w-full items-center rounded-pill border border-border bg-surface px-2 text-[13px] font-normal text-muted` with `<span class="truncate">{{ chip.label }}</span>`.
|
||||
- Overflow `+N more` button (`v-if="summary.overflowCount > 0"`, `type="button"`, `data-action="customize-scopes-more"`, `:disabled="disabled"`, `inline-flex h-6 items-center rounded-pill border border-dashed border-border-strong bg-surface px-2 text-[13px] font-semibold tabular-nums whitespace-nowrap text-text hover:bg-hover disabled:cursor-not-allowed disabled:opacity-60`, `@click="emit('customize')"`): `t('backend::lang.api_tokens.scope_more', { count: summary.overflowCount })`.
|
||||
- Exposes `focusPrimaryControl()` (focuses **Customize scopes…** button if visible, else the checked tier radio button) for parent focus restoration and validation focus.
|
||||
|
||||
---
|
||||
|
||||
### C3. `ScopePicker.vue` (`admin/src/components/scopes/ScopePicker.vue`)
|
||||
|
||||
**Props:**
|
||||
- `catalog: readonly AdminAPITokenScope[]`
|
||||
- `draftAdminRead: boolean`
|
||||
- `draftScopes: ReadonlySet<string>`
|
||||
- `cancelLabel: string` (`"Discard changes"` in `ConnectView`, `"Back to token"` in `ApiTokenCreateDialog`)
|
||||
- `disabled?: boolean`
|
||||
|
||||
**Emits:**
|
||||
- `'update:draftAdminRead': [value: boolean]`
|
||||
- `'update:draftScopes': [value: Set<string>]`
|
||||
- `'apply': []`
|
||||
- `'cancel': []`
|
||||
|
||||
**Internal State:**
|
||||
- `query = ref('')`
|
||||
- `filter = ref<ScopeFilter>('all')`
|
||||
- `expanded = ref<Set<string>>(new Set())` — initialized on mount via `computeDefaultExpanded(...)` (D-07). While `query.trim() !== ''`, every matching group renders expanded without erasing the user's pre-search `expanded` set; clearing the search restores pre-search expansion state.
|
||||
- Exposes `focusSearch()` so parent modal/view-swap places initial focus into the search input.
|
||||
|
||||
**Structure (`data-scope-picker`, `flex min-h-0 flex-1 flex-col`):**
|
||||
|
||||
1. **Sticky Header** (`shrink-0 flex flex-col gap-2 border-b border-border bg-surface p-4`):
|
||||
- **Search input row** (`relative flex items-center`):
|
||||
- `<Search :size="16" class="pointer-events-none absolute left-3 text-muted" aria-hidden="true" />`
|
||||
- `<input ref="searchInput" v-model="query" type="search" data-scope-search autocomplete="off" :aria-label="t('backend::lang.api_tokens.scope_search_label')" :placeholder="t('backend::lang.api_tokens.scope_search_placeholder')" :class="controlClass(false)" class="h-input pl-10 pr-10" />`
|
||||
- Clear button (`v-if="query !== ''"`, `type="button"`, `data-action="clear-scope-search"`, `:aria-label="t('backend::lang.api_tokens.scope_search_clear')"`, `absolute right-2 flex size-8 items-center justify-center rounded-tab text-muted hover:bg-hover hover:text-text`, `@click="clearSearch"`): `<X :size="16" aria-hidden="true" />`. Clicking clears `query` and returns focus to `searchInput`.
|
||||
- **Filter pills** (`role="group"`, `:aria-label="t('backend::lang.api_tokens.scope_filter_label')"`, `inline-flex flex-wrap gap-1 self-start rounded-inner border border-border bg-subtle p-1`):
|
||||
- Three `<button type="button">` items (`data-scope-filter="all" | "selected" | "read_only"`, `:aria-pressed="filter === id"`, `inline-flex h-8 items-center rounded-tab px-4 text-[13px] tabular-nums whitespace-nowrap transition-colors duration-150 ease-out`):
|
||||
- Active: `bg-surface text-text shadow-tab font-semibold`
|
||||
- Inactive: `text-muted hover:text-text`
|
||||
- Live counts are computed across the full plugin catalog (unaffected by the active filter, updated immediately as scopes or `admin:read` change):
|
||||
- `all`: total plugin scopes
|
||||
- `selected`: plugin scopes where `isEffectivelySelected(scope, draft)` is true
|
||||
- `read_only`: plugin scopes where `scope.read_only` is true
|
||||
- **Opt-in `admin:read` toggle banner** (`v-if="hasAdminRead"`, `data-admin-read-toggle`, `rounded-inner border border-border bg-subtle px-4 py-2`):
|
||||
- `<label class="flex min-h-[44px] cursor-pointer items-start gap-3 py-2">`
|
||||
- `<input type="checkbox" data-admin-read-checkbox class="mt-0.5 size-5 shrink-0 rounded-[6px] accent-primary" :checked="draftAdminRead" :disabled="disabled" @change="emit('update:draftAdminRead', ($event.target as HTMLInputElement).checked)" />`
|
||||
- `<span class="flex min-w-0 flex-col">`
|
||||
- `<span class="flex flex-wrap items-center gap-1"><span class="font-semibold text-text">{{ t('backend::lang.api_tokens.scope_also_admin_read') }}</span><span class="font-mono text-[13px] text-muted">admin:read</span></span>`
|
||||
- `<span class="text-[13px] text-muted [overflow-wrap:anywhere]">{{ t('backend::lang.api_tokens.scope_also_admin_read_hint') }}</span>`
|
||||
|
||||
2. **Scrollable Accordion Body** (`min-h-0 flex-1 overflow-y-auto p-4`):
|
||||
- **Empty state** (`v-if="visibleGroups.length === 0"`, `data-scope-picker-empty`, `flex flex-col items-center gap-2 rounded-inner border border-dashed border-border-strong px-6 py-8 text-center`):
|
||||
- Displays the specific heading + actionable body for `query.trim() !== ''` (`scope_empty_search_*`) vs `filter === 'selected'` (`scope_empty_selected_*`) vs `filter === 'read_only'` (`scope_empty_readonly_*`).
|
||||
- Action button (outline style, `h-[38px] px-4 rounded-control border border-border-strong bg-surface font-semibold text-text hover:bg-hover`):
|
||||
- When `query.trim() !== ''`: **Clear search** (`data-action="reset-scope-search"`, clears `query` and focuses search input).
|
||||
- Otherwise: **Show all scopes** (`data-action="reset-scope-filter"`, resets `filter = 'all'`).
|
||||
- **Flat Accordion List** (`v-else`, `flex flex-col gap-2`):
|
||||
- One section per visible `(plugin_id, group)` group (`data-scope-group`, `overflow-hidden rounded-inner border border-border bg-surface`):
|
||||
- **Header bar** (`flex flex-wrap items-center justify-between gap-2 bg-subtle px-4 py-2`):
|
||||
- Toggle `<button type="button" data-scope-group-toggle :aria-expanded="isGroupExpanded(group.key)" :aria-controls="panelId(group.key)" class="flex min-h-[38px] min-w-0 flex-1 items-center gap-2 text-left" @click="toggleGroup(group.key)">`:
|
||||
- `<ChevronDown v-if="isGroupExpanded(group.key)" :size="16" class="shrink-0 text-muted" aria-hidden="true" />`
|
||||
- `<ChevronRight v-else :size="16" class="shrink-0 text-muted" aria-hidden="true" />`
|
||||
- `<span class="font-semibold text-text [overflow-wrap:anywhere]">{{ group.label }}</span>`
|
||||
- `<span data-scope-group-count :class="groupSelectedCount > 0 ? 'border-border-strong text-text' : 'border-border text-muted'" class="inline-flex h-6 shrink-0 items-center rounded-pill border bg-surface px-2 text-[13px] font-semibold tabular-nums">{{ groupSelectedCount }}/{{ group.allScopes.length }}</span>`
|
||||
- Per-group quick actions (`flex shrink-0 items-center gap-1`):
|
||||
- `Read` (`data-group-action="read"`): disabled when `disabled || draftAdminRead || readOnlyScopesInGroup.length === 0 || allReadOnlySelectedInGroup` (D-17). Click adds every `read_only` scope in `group.allScopes` to `draftScopes`.
|
||||
- `All` (`data-group-action="all"`): disabled when `disabled || unlockedScopesInGroup.length === 0 || allUnlockedSelectedInGroup`. Click adds every unlocked scope in `group.allScopes` to `draftScopes`.
|
||||
- `Clear` (`data-group-action="clear"`): disabled when `disabled || unlockedSelectedInGroup.length === 0` (D-17: unticks only unlocked non-`read_only` scopes when `draftAdminRead` is ON; unticks all scopes in the group when `draftAdminRead` is OFF).
|
||||
- Each quick action button uses `inline-flex h-8 items-center rounded-tab px-2 text-[13px] font-semibold text-muted transition-colors duration-150 ease-out hover:bg-hover hover:text-text disabled:cursor-not-allowed disabled:opacity-40` and carries its `:aria-label` naming `:group`.
|
||||
- **Panel** (`v-show="isGroupExpanded(group.key)"`, `:id="panelId(group.key)"`, `role="group"`, `:aria-label="group.label"`):
|
||||
- Each visible scope in `group.visibleScopes` (`<label :data-scope="scope.name">`, `flex min-h-[56px] items-start gap-3 border-t border-border px-4 py-3`, `:class="isLocked(scope) ? 'cursor-not-allowed bg-subtle' : 'cursor-pointer hover:bg-hover'"`):
|
||||
- `<input type="checkbox" class="mt-0.5 size-5 shrink-0 rounded-[6px] accent-primary" :checked="isEffectiveSelected(scope)" :disabled="disabled || isLocked(scope)" @change="toggleScope(scope.name, ($event.target as HTMLInputElement).checked)" />`
|
||||
- Text column (`flex min-w-0 flex-1 flex-col`):
|
||||
- Line 1 (`flex flex-wrap items-center gap-1`):
|
||||
- `<span class="font-semibold text-text [overflow-wrap:anywhere]">{{ scope.label }}</span>`
|
||||
- `<span class="font-mono text-[13px] text-muted [overflow-wrap:anywhere]">{{ scope.name }}</span>`
|
||||
- If `scope.read_only && draftAdminRead`: `<span data-via-admin-read class="inline-flex h-6 items-center gap-1 rounded-pill border border-border-strong bg-surface px-2 text-[13px] font-semibold whitespace-nowrap text-muted"><Lock :size="14" aria-hidden="true" />{{ t('backend::lang.api_tokens.via_admin_read') }}</span>` (D-04).
|
||||
- Else if `scope.read_only`: `<span class="inline-flex h-6 items-center rounded-pill bg-subtle px-2.5 text-[13px] font-semibold whitespace-nowrap text-muted">{{ t('backend::lang.api_tokens.read_only') }}</span>`.
|
||||
- Line 2: `<span class="text-[13px] text-muted [overflow-wrap:anywhere]">{{ scope.description }}</span>`.
|
||||
|
||||
3. **Sticky Footer** (`shrink-0 flex flex-wrap items-center justify-between gap-2 border-t border-border bg-surface p-4`):
|
||||
- Live status text (`data-scope-picker-summary`, `text-[13px] text-muted tabular-nums`, `aria-live="polite"`):
|
||||
- Draft has 0 effective scopes → `api_tokens.scope_picker_none_selected`
|
||||
- `draftAdminRead` ON and 0 write scopes → `api_tokens.scope_summary_admin_read_only`
|
||||
- `draftAdminRead` ON and ≥ 1 write scope → `api_tokens.scope_picker_selected_admin_read`
|
||||
- `draftAdminRead` OFF and ≥ 1 scope → `api_tokens.scope_picker_selected`
|
||||
- Action button pair (`flex items-center gap-2 max-sm:w-full`):
|
||||
- Secondary button (`type="button"`, `data-action="scope-picker-discard"`, `inline-flex h-button items-center justify-center gap-2 rounded-control border border-border-strong bg-surface px-4 font-semibold whitespace-nowrap text-text transition-colors duration-150 ease-out hover:bg-hover disabled:cursor-not-allowed disabled:opacity-60 max-sm:flex-1`, `@click="emit('cancel')"`): `{{ cancelLabel }}`.
|
||||
- Primary button (`type="button"`, `data-action="scope-picker-apply"`, `:disabled="disabled || !canApply"`, `inline-flex h-button items-center justify-center gap-2 rounded-control bg-primary px-4 font-semibold whitespace-nowrap text-on-primary transition-colors duration-150 ease-out hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60 max-sm:flex-1`, `@click="emit('apply')"`): `t('backend::lang.api_tokens.scope_picker_apply')`.
|
||||
|
||||
---
|
||||
|
||||
### C4. `ConnectView.vue` Integration (`admin/src/views/ConnectView.vue`)
|
||||
|
||||
**Preserved Phase 32.2 invariants:**
|
||||
- Standalone `480px` white card on the navy radial gradient; no sidebar or top bar.
|
||||
- All 5 states (`loading`, `ready`, `expired`, `load_error`, `returning`) and `none_grantable` alert when `scopes.length === 0`.
|
||||
- Hidden ungrantable scopes (SPA renders only what `GET /mcp/consent/{request}` returns).
|
||||
- `offline_access` row ticked by default when requested.
|
||||
- No auto-allow when `consent_required === false`; no initial focus or hotkey on **Allow** / **Deny**; `safeDestination` redirect URI validation; `window.location.assign`; `switchAccount` calls `logout()` without router argument.
|
||||
|
||||
**Phase 36 changes:**
|
||||
1. Add `.connect-light-surface` to the consent card `<form>` / `<div>` so `ScopeAccessControl` renders strictly in light-literal palette regardless of dark mode (D-12).
|
||||
2. Replace `checked` / `toggleScope` / `initialTicks` with `useScopeSelection(scopes, 'connect')`. On `GET /mcp/consent/{request}` success, initialize via `resolveInitialState(view.scopes, 'connect')` (defaults to `Read-only (admin:read)` when grantable; narrow plugin subset opens in `Custom` with those scopes selected; `*`-only starts in `Full (*)`; hides `Custom` when no plugin scopes are grantable, D-03).
|
||||
3. Update the `loading` skeleton scope block to mirror the new compact control: one `h-10 rounded-inner bg-[#eceff4]` segmented-bar skeleton plus one `rounded-inner border border-[#e6e9ef] bg-[#f3f5f8] p-4` summary-box skeleton with two bars (`h-3 w-48`, `h-3 w-32`).
|
||||
4. Replace the flat checkbox list inside `<fieldset>` with `<ScopeAccessControl id-prefix="connect" ... @customize="openPicker" />`. Keep the `scopes_required` inline alert immediately beneath it.
|
||||
5. **Customize scopes Reka `Dialog` modal (D-10, D-11, D-12):**
|
||||
- Mounted inside `ConnectView.vue` (`<DialogRoot :open="pickerOpen" @update:open="onPickerOpenChange">`).
|
||||
- `<DialogOverlay data-dialog-overlay class="connect-light-surface fixed inset-0 z-40 bg-overlay" />`
|
||||
- `<DialogContent data-scope-picker-dialog data-dialog-content aria-modal="true" class="connect-light-surface fixed inset-0 z-50 flex h-[100dvh] w-full flex-col overflow-hidden bg-surface text-text sm:inset-auto sm:top-1/2 sm:left-1/2 sm:h-auto sm:max-h-[85dvh] sm:w-[calc(100%-32px)] sm:max-w-[640px] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-modal sm:shadow-pop" @open-auto-focus="onPickerOpenAutoFocus" @close-auto-focus="onPickerCloseAutoFocus">`
|
||||
- Modal header (`shrink-0 flex items-start gap-4 border-b border-border bg-surface p-4`):
|
||||
- `DialogTitle` (`text-[20px] font-bold tracking-[-0.01em] text-text`): `t('backend::lang.api_tokens.scope_picker_title')`.
|
||||
- `DialogDescription` (`text-[13px] text-muted [overflow-wrap:anywhere]`): `t('backend::lang.mcp_connect.scope_picker_description', { client: clientName })`.
|
||||
- Close button (`type="button"`, `data-action="close-scope-picker"`, `:aria-label="t('backend::lang.form.close')"`, `flex size-[34px] shrink-0 items-center justify-center rounded-tab bg-subtle text-muted hover:bg-hover hover:text-text`, `@click="discardPicker"`): `<X :size="16" aria-hidden="true" />`.
|
||||
- Body + sticky footer: `<ScopePicker ref="scopePickerRef" :catalog="scopes" v-model:draft-admin-read="draftAdminRead" v-model:draft-scopes="draftScopes" :cancel-label="t('backend::lang.api_tokens.scope_picker_discard')" @apply="applyPicker" @cancel="discardPicker" />`.
|
||||
- Focus management: `@open-auto-focus` prevents default and calls `scopePickerRef.focusSearch()`; `@close-auto-focus` prevents default and calls `scopeAccessRef.focusPrimaryControl()`.
|
||||
- Escape, backdrop click, `X`, and **Discard changes** all call `discardPicker()` (restoring prior selection and reverting tier if Custom was auto-opened empty, D-09, D-11).
|
||||
- **Allow** submits `submittedScopes.value`. `canAllow` requires `!locked && grantable && submittedScopes.value.length > 0`.
|
||||
|
||||
---
|
||||
|
||||
### C5. `ApiTokenCreateDialog.vue` Integration (`admin/src/components/account/ApiTokenCreateDialog.vue`)
|
||||
|
||||
**Preserved Phase 16.3 invariants:**
|
||||
- Step 2 (show-once plaintext token, copy button, clipboard fallback, uncopied-close `ConfirmDialog`, unmount cleanup) is **100% unchanged**.
|
||||
- `DialogContent` stays fixed at `max-w-[560px]` across all views (`form`, `scopes`, and Step 2) to prevent any horizontal resize jump (D-13).
|
||||
- Zero nested modal overlay (D-02, D-13).
|
||||
|
||||
**Phase 36 changes:**
|
||||
1. Replace `checked` / `toggleScope` / `selectedScopes` with `useScopeSelection(scopes, 'token')`. After `GET /account/tokens/scopes` resolves with a non-empty catalog, initialize via `resolveInitialState(list, 'token')` — defaults to **`Read-only (admin:read)`**, falling back to **`Full (*)`** if `admin:read` is unavailable (D-08).
|
||||
2. Add sub-view state `stepView = computed(() => (step.value === 1 && pickerOpen.value ? 'scopes' : 'form'))` (so closing/resetting the dialog always resets `pickerOpen = false` and `step = 1`).
|
||||
3. **Outer `DialogContent` layout:**
|
||||
- Keeps `fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100vh-32px)] w-[calc(100%-32px)] max-w-[560px] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-modal bg-surface text-text shadow-pop`.
|
||||
- When `step === 1 && !pickerOpen` (token form) or `step === 2` (plaintext): inner content wrapper carries `flex min-h-0 flex-1 flex-col gap-4 p-6` (identical padding and rhythm to Phase 16.3).
|
||||
- When `step === 1 && pickerOpen` (swapped `ScopePicker` view): renders a dedicated header (`shrink-0 flex items-start gap-4 border-b border-border bg-surface p-4`) + `<ScopePicker>` directly inside `DialogContent` so sticky search header, scrollable accordion body, and sticky footer fit edge-to-edge cleanly within `max-h-[calc(100vh-32px)]` without nested scrollbars.
|
||||
4. **Swapped `ScopePicker` view header (`step === 1 && pickerOpen`):**
|
||||
- Left column (`flex min-w-0 flex-1 flex-col gap-1`):
|
||||
- Back button (`type="button"`, `data-action="scope-picker-back"`, `inline-flex h-[34px] self-start items-center gap-1 rounded-tab px-2 text-[14px] font-semibold text-muted hover:bg-hover hover:text-text`, `@click="onPickerCancel"`): `<ArrowLeft :size="16" aria-hidden="true" />` + `t('backend::lang.api_tokens.scope_picker_back')`.
|
||||
- `DialogTitle` (`text-[20px] font-bold tracking-[-0.01em]`): `t('backend::lang.api_tokens.scope_picker_title')`.
|
||||
- `DialogDescription` (`text-[13px] text-muted`): `t('backend::lang.api_tokens.scope_picker_description')`.
|
||||
- Right: existing Close `X` button (`data-action="close"`, calls `requestClose()`).
|
||||
5. **Token form (`step === 1 && !pickerOpen`):**
|
||||
- Keeps Name input, Expiration `RadioGroupRoot`, and replaces the flat scope checkbox list with `<ScopeAccessControl id-prefix="api-token" ... :invalid="Boolean(errors.scopes)" @customize="onPickerOpen" />`.
|
||||
- Loading skeleton for scopes mirrors `ScopeAccessControl` (`h-10 rounded-inner bg-skel` + `rounded-inner border border-border bg-subtle p-4` with two skeleton bars).
|
||||
- `scopesFailed` error block remains identical (`api_tokens.scopes_failed`).
|
||||
- `canSubmit` checks `!scopesLoading && !scopesFailed && scopes.value.length > 0 && submittedScopes.value.length > 0 && !busy`.
|
||||
- `onSubmit()` posts `{ name: name.value, expires: expires.value, scopes: submittedScopes.value }`.
|
||||
- `focusFirstInvalid()` focuses `scopeAccessRef.focusPrimaryControl()` when `errors.scopes` is set.
|
||||
- `mod+s mod+enter` hotkey stays on the **Create token** button inside `v-if="step === 1 && !pickerOpen"`, so pressing `Ctrl+S` / `Cmd+Enter` while inside the swapped `ScopePicker` view never submits the token form.
|
||||
6. **Escape & View-Swap Focus Contract (D-11, D-13):**
|
||||
- In `onEscapeKey(event)`: when `step.value === 1 && pickerOpen.value`, call `event.preventDefault()` and invoke `onPickerCancel()` (discards draft, reverts tier if auto-opened empty, returns to token form preserving `name` and `expires`, and does **not** close the dialog).
|
||||
- `onPickerOpen()`: opens picker, awaits `nextTick()`, calls `scopePickerRef.focusSearch()`.
|
||||
- `onPickerApply()`: commits draft, clears `errors.scopes`, returns to token form preserving `name` and `expires`, awaits `nextTick()`, calls `scopeAccessRef.focusPrimaryControl()`.
|
||||
- `onPickerCancel()`: discards draft (with auto-open tier revert), returns to token form preserving `name` and `expires`, awaits `nextTick()`, calls `scopeAccessRef.focusPrimaryControl()`.
|
||||
|
||||
---
|
||||
|
||||
### C6. `ApiTokensPanel.vue` Compatibility (`admin/src/components/account/ApiTokensPanel.vue`)
|
||||
|
||||
- Confirmed no markup or script changes required: `ApiTokensPanel.vue` reads only `scope.name`, `scope.label`, and `scope.known` from `AdminAPIToken.scopes`, and wraps pill lists with `flex-wrap gap-2`.
|
||||
- Additive `plugin_id: string` and `group: string` fields (D-15) pass through TypeScript cleanly after `scripts/check-admin-openapi.sh` regenerates `admin/src/api/schema.d.ts`.
|
||||
|
||||
---
|
||||
|
||||
## UI Considerations
|
||||
|
||||
Applicable state considerations resolved: 29 probe checks in 29 rows (22 covered, 7 backstop, 0 dismissed, 0 unresolved).
|
||||
|
||||
| Category | Element(s) | Status | Resolution / Reason |
|
||||
|----------|------------|--------|---------------------|
|
||||
| loading | `ConnectView` consent card | ✅ covered | Skeleton card (`aria-busy="true"`) mirrors client mark + segmented tier bar + summary box; no buttons until loaded |
|
||||
| loading | `ApiTokenCreateDialog` scope catalog | ✅ covered | Skeleton segmented tier bar + summary box while `GET /account/tokens/scopes` is in flight; **Create token** stays disabled |
|
||||
| loading | `ConnectView` / `ApiTokenCreateDialog` submit | ✅ covered | Fieldset disabled, buttons disabled with `LoaderCircle` spinner; Customize modal cannot be opened while busy |
|
||||
| empty | `ConnectView` zero grantable scopes | ✅ covered | Existing `none_grantable` alert replaces `ScopeAccessControl`; only **Deny** is offered |
|
||||
| empty | `ScopeAccessControl` Custom with 0 selected | ✅ covered | Actionable `scope_summary_empty` copy + **Customize scopes…** button; **Allow** / **Create token** stays disabled |
|
||||
| empty | `ScopePicker` search with 0 matches | ✅ covered | Dashed empty block with `scope_empty_search_title`, `scope_empty_search_body` naming `:query`, and **Clear search** button |
|
||||
| empty | `ScopePicker` `Selected` filter with 0 selected | ✅ covered | Dashed empty block with `scope_empty_selected_*` and **Show all scopes** button |
|
||||
| empty | `ScopePicker` `Read-only` filter with 0 read-only scopes | ✅ covered | Dashed empty block with `scope_empty_readonly_*` and **Show all scopes** button |
|
||||
| empty | `ScopePicker` draft empty on Apply | ✅ covered | **Apply scopes** is disabled and live footer reads `scope_picker_none_selected`; user must pick ≥ 1 scope or discard |
|
||||
| error | `ConnectView` load/submit/404/401/422/bad URI | ✅ covered | All Phase 32.2 error states preserved; 422 `scopes_required` highlights `ScopeAccessControl` border in `border-danger` |
|
||||
| error | `ApiTokenCreateDialog` scopes load failed / 422 | ✅ covered | Existing `scopes_failed` alert; 422 `errors.scopes` marks `ScopeAccessControl` invalid and moves focus to it |
|
||||
| populated | Small catalog (`≤ 3` groups or `≤ 12` scopes) | ✅ covered | All accordions expand automatically on open (D-07) |
|
||||
| populated | Large catalog (`> 3` groups and `> 12` scopes) | ✅ covered | Only groups with active selections expand on open (all collapsed if none selected); typing a search auto-expands all matching groups (D-07) |
|
||||
| populated | Elevated-first summary chips | ✅ covered | `admin:read` (if ON) and write scopes appear before read-only scopes, capped at 6 + clickable `+N more` chip + `"X scopes across Y plugins"` subtitle (D-06) |
|
||||
| partial | Catalog without `admin:read` or without `*` or without plugin scopes | ✅ covered | Missing tiers are omitted from `RadioGroupRoot`; if no plugin scopes exist beyond `*` and `admin:read`, `Custom` tier is hidden (D-03); `ApiTokenCreateDialog` falls back to `Full (*)` when `admin:read` is absent (D-08); `ConnectView` opens in `Custom` when client requested only a narrow plugin subset (D-03) |
|
||||
| partial | Two plugins with identical translated `group` label | ✅ covered | Accordions keyed by `${plugin_id}\0${group}` never collide; tie-broken alphabetically by `plugin_id` (D-17) |
|
||||
| zero-one-many | Scope counts and plugin counts (EN + PL) | ✅ covered | Full CLDR plural keys (`one`/`few`/`many`/`other` in PL, `one`/`other` in EN) evaluated via `tc()` for scopes, write scopes, and plugins |
|
||||
| overflow | Mobile viewport (`< 640px`) on `ConnectView` Customize modal | ✅ covered | `100dvh` full-screen sheet with sticky search/filter header, independently scrollable accordion body, and sticky footer (D-10) |
|
||||
| overflow | Desktop viewport (`≥ 640px`) on both surfaces | ✅ covered | `ConnectView` modal capped at `max-w-[640px] max-h-[85dvh]`; `ApiTokenCreateDialog` fixed at `max-w-[560px] max-h-[calc(100vh-32px)]` with sticky header/footer and zero double scrollbars (D-10, D-13) |
|
||||
| long-text | Long plugin group names, scope labels, mono codes, descriptions | ✅ covered | `[overflow-wrap:anywhere]` on group headers, scope labels, mono codes, and descriptions; summary chips truncate safely inside `max-w-full` pills with full scope name in `:title` |
|
||||
| dark-mode | Surface-matched theming in `<html class="dark">` | ✅ covered | `ApiTokenCreateDialog` inherits `.dark` tokens automatically; `ConnectView` card + portaled modal apply `.connect-light-surface` (defined in `admin/src/styles/main.css` `@layer components`, pinning both `--c-*` and `--color-*` aliases so Tailwind v4 `@theme` utilities stay light) (D-12) |
|
||||
| keyboard | Focus trap, Escape, and hotkeys | ✅ covered | Opening picker focuses search input; closing restores focus to **Customize scopes…** (or tier radio); Escape in `ApiTokenCreateDialog` picker view returns to token form preserving name/expiry without closing dialog (D-13); `mod+s`/`mod+enter` inactive inside picker view |
|
||||
| populated | Initial default tiers (`ConnectView` + `ApiTokenCreateDialog`) | 🧪 backstop | Vitest (`ConnectView.test.ts`, `AccountView.test.ts`): both default to `Read-only (admin:read)` when grantable; `ConnectView` opens narrow subset in `Custom`, `*`-only in `Full`, hides `Custom` when no plugin scopes exist; `ApiTokenCreateDialog` falls back to `Full (*)` when `admin:read` absent |
|
||||
| populated | `admin:read` toggle & lock semantics (PII footgun fix) | 🧪 backstop | Vitest (`ScopePicker.test.ts`, `ConnectView.test.ts`): Custom omits `admin:read` by default; enabling opt-in toggle locks every `read_only` row checked with `via admin:read` badge, disables per-group `Read`, makes `Clear` untick only unlocked scopes, renders `admin:read` chip first, and submits `['admin:read', ...writes]`; toggling OFF restores prior `:read` ticks |
|
||||
| populated | Tier memory, auto-open empty Custom, and draft/discard revert | 🧪 backstop | Vitest: clicking `Custom` when empty auto-opens picker; Discard/Escape reverts to previous tier; applying then switching to `Read-only` and back to `Custom` restores saved selection in memory without reopening picker |
|
||||
| populated | Grouping, sorting, search, filter pills, and smart expand | 🧪 backstop | Vitest (`scopeCatalog.test.ts`, `ScopePicker.test.ts`): `(plugin_id, group)` key prevents collisions, alphabetical group sort with `plugin_id` tie-break preserves intra-group scope order, search matches plugin/group/label/code/description and auto-expands matches, filter pills show live counts, small vs large catalog expand rules hold |
|
||||
| keyboard | `ApiTokenCreateDialog` in-dialog swap + Escape preservation | 🧪 backstop | Vitest (`AccountView.test.ts`): clicking **Customize scopes…** swaps view in place (zero second dialog overlay), pressing Escape discards draft and returns to token form with `name` and `expires` intact, and `mod+s` does not submit while in picker view |
|
||||
| populated | `ConnectView` modal light-surface & mobile classes | 🧪 backstop | Vitest (`ConnectView.test.ts`): portaled `DialogOverlay` and `DialogContent` carry `.connect-light-surface`, mobile full-screen sheet classes (`h-[100dvh]`), and desktop `sm:max-w-[640px] sm:max-h-[85dvh]` |
|
||||
| populated | Elevated-first chip cap at 6 + `+N more` | 🧪 backstop | Vitest (`ScopeAccessControl.test.ts`): `admin:read` and write scopes sort ahead of read-only scopes; 8 selected scopes render 6 chips + clickable `+2 more` chip that opens `ScopePicker` |
|
||||
|
||||
---
|
||||
|
||||
## Registry Safety
|
||||
|
||||
| Registry | Blocks Used | Safety Gate |
|
||||
|----------|-------------|-------------|
|
||||
| shadcn official | none (shadcn not used) | not applicable |
|
||||
| third-party registries | none | not applicable |
|
||||
| npm (new admin SPA deps) | none — reuses installed `reka-ui@2.9.10`, `@lucide/vue@1.17.0`, `vue`, `vue-router`, `openapi-fetch` | not applicable. Mandatory repository release gates apply: `scripts/check-admin-openapi.sh --check` (after adding `plugin_id` and `group` to `cabana.AdminAPITokenScope`) and `scripts/check-admin-dist.sh` (rebuilt and committed `modules/boardwalk/dist`) |
|
||||
|
||||
---
|
||||
|
||||
## Checker Sign-Off
|
||||
|
||||
- [x] Dimension 1 Copywriting: FLAG (non-blocking — compact locked `Read`/`All`/`Clear` quick actions paired with verb+noun `aria-label`s, plus inherited Phase 32.2 `Allow`/`Deny`)
|
||||
- [x] Dimension 2 Visuals: PASS
|
||||
- [x] Dimension 3 Color: PASS
|
||||
- [x] Dimension 4 Typography: PASS
|
||||
- [x] Dimension 5 Spacing: PASS
|
||||
- [x] Dimension 6 Registry Safety: PASS
|
||||
- [x] Dimension 7 Inventory Provenance: PASS
|
||||
|
||||
**Approval:** approved 2026-11-24 (msd-ui-checker)
|
||||
Reference in New Issue
Block a user