Skip to content

feat(spec-100): admin routes + translate cleanup + wrapper removal#23

Merged
hendrikebbers merged 4 commits into
mainfrom
feat/100-admin-routes-translate-cleanup
May 21, 2026
Merged

feat(spec-100): admin routes + translate cleanup + wrapper removal#23
hendrikebbers merged 4 commits into
mainfrom
feat/100-admin-routes-translate-cleanup

Conversation

@herbie-bot

Copy link
Copy Markdown

Summary

Three structural cleanups bundled into one wave of releases:

  1. Admin route consolidation — move /api-keys and /webhooks under
    /admin/*. Both are IT-ADMIN-gated and the sidebar already groups them
    with the other admin pages; the URL now matches the role contract.
  2. Translate components → @open-elements/uiTranslateButton and
    TranslateDialog move to the lib (see paired PR
    open-elements-ui#3).
    The five usage sites pass configured, onTranslate, and the
    translations bundle as props.
  3. Wrapper-file cleanup — pass-through re-export files left over from
    spec 098 are deleted; every importer points directly at
    @open-elements/nextjs-app-layer.

Spec

  • Folder: specs/100-admin-routes-translate-cleanup/
  • Design: specs/100-admin-routes-translate-cleanup/design.md
  • Behaviors: specs/100-admin-routes-translate-cleanup/behaviors.md
  • Steps: specs/100-admin-routes-translate-cleanup/steps.md

Changes

Admin route move

  • (app)/api-keys/page.tsx(app)/admin/api-keys/page.tsx
  • (app)/webhooks/page.tsx(app)/admin/webhooks/page.tsx
  • (app)/layout.tsx: NavItem hrefs + active matchers → /admin/api-keys
    and /admin/webhooks. ADMIN_PREFIXES collapses to ["/admin"].

Translate swap (4 sites)

  • components/company-detail.tsx
  • components/contact-detail.tsx
  • components/company-comments.tsx
  • components/contact-comments.tsx

Each: import { TranslateButton } from "@open-elements/ui" + inline
configured (via useTranslationConfig), onTranslate (via
translateText), and a translations bundle from t.translation.*.
Local translate-dialog.tsx and translate-button.tsx deleted.

Wrapper deletions

Deleted Replaced by
components/session-provider.tsx @open-elements/nextjs-app-layer
components/forbidden-page.tsx @open-elements/nextjs-app-layer
components/add-comment-dialog.tsx @open-elements/nextjs-app-layer
components/bearer-token-card.tsx (unused) (no consumers)
lib/roles.ts @open-elements/nextjs-app-layer
lib/forbidden-error.ts @open-elements/nextjs-app-layer
tests of the above

lib/api.ts now imports ForbiddenError directly from
@open-elements/nextjs-app-layer.

Dependency bumps

  • @open-elements/ui: ^0.6.0^0.8.0
  • @open-elements/nextjs-app-layer: ^0.1.0^0.2.0

Test coverage

  • 165 passing locally (built against file:../../open-elements-ui and
    file:../../nextjs-app-layer to verify the integration).
  • 42 pre-existing companies/contacts-client localStorage failures
    unchanged — same set as on main and on the previous spec PRs.
  • Existing detail-view test mocks gained getTranslationSettings +
    translateText (the swap to the lib's TranslateButton means
    useTranslationConfig runs inside these components).

Acceptance checks

  • grep -r "@/components/session-provider|@/components/forbidden-page|@/components/add-comment-dialog|@/components/translate-button|@/components/translate-dialog|@/lib/roles|@/lib/forbidden-error" src/ → zero matches.
  • grep -r "translate-button|translate-dialog" src/ → zero matches.
  • grep -r '"/api-keys"|"/webhooks"' src/ → zero matches.
  • .next/server/middleware-manifest.json matcher unchanged (regression
    guard for spec-098's production fix preserved).

CI dependency

CI on this PR is red until the two paired lib PRs are merged and
published to npm
:

After both libs are released, run pnpm install on this branch once to
regenerate pnpm-lock.yaml against the registry resolutions, then push.
CI will then pass.

Closes #22

🤖 Generated with Claude Code

hendrikebbers and others added 4 commits May 20, 2026 09:33
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three structural cleanups landed in one wave:

1. Admin route consolidation
   - Moved `(app)/api-keys/page.tsx` → `(app)/admin/api-keys/page.tsx`.
   - Moved `(app)/webhooks/page.tsx` → `(app)/admin/webhooks/page.tsx`.
   - Updated sidebar NavItem hrefs + active matchers to /admin/api-keys
     and /admin/webhooks.
   - Simplified ADMIN_PREFIXES from ["/admin","/api-keys","/webhooks"]
     to just ["/admin"].

2. Translate components → @open-elements/ui
   - Deleted local `components/translate-dialog.tsx`, `translate-button.tsx`,
     and the translate-button test (lib carries equivalent tests).
   - Updated four usage sites (company-detail, contact-detail,
     company-comments, contact-comments) to import TranslateButton from
     @open-elements/ui and wire in `configured` (from useTranslationConfig),
     `onTranslate` (translateText), and the translations bundle.

3. Wrapper-file cleanup (finishes the spec-098 migration tail)
   - Deleted pass-through wrappers:
     - components/session-provider.tsx
     - components/forbidden-page.tsx
     - components/add-comment-dialog.tsx
     - components/bearer-token-card.tsx (unused leftover)
     - lib/roles.ts
     - lib/forbidden-error.ts
     and their tests under the same paths.
   - Re-pointed every importer at `@open-elements/nextjs-app-layer`.
   - `lib/api.ts`'s ForbiddenError import now resolves to the lib too.

Test fixtures: added `getTranslationSettings` + `translateText` to the
`@/lib/api` mock in `company-detail.test.tsx` and `contact-detail.test.tsx`
because the swap to the lib's TranslateButton means useTranslationConfig
runs inside these components.

Dependency bumps:
- @open-elements/ui: ^0.6.0 → ^0.8.0 (TranslateButton + TranslateDialog).
- @open-elements/nextjs-app-layer: ^0.1.0 → ^0.2.0 (admin /admin/* defaultRoute).

Verification (local, against file: checkouts of the two lib branches):
- `pnpm exec next build` exits 0; middleware-manifest matcher preserved.
- Test suite: 165 passing, 42 pre-existing companies/contacts-client
  localStorage failures unchanged from main.
- grep -r "@/components/session-provider|@/components/forbidden-page|
  @/components/add-comment-dialog|@/components/translate-button|
  @/components/translate-dialog|@/lib/roles|@/lib/forbidden-error" src/
  returns nothing.
- grep -r "translate-button|translate-dialog" src/ returns nothing.
- grep -r '"/api-keys"|"/webhooks"' src/ returns nothing.

CI on this PR will be red until the two paired lib PRs are merged and
published to npm (open-elements-ui#3 → 0.8.0, nextjs-app-layer#1 → 0.2.0).
After both releases, a `pnpm install` on this branch regenerates the
lockfile against the registry resolutions; push that as an additional
commit to turn CI green.

Closes #22

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hendrikebbers hendrikebbers merged commit 881765e into main May 21, 2026
2 checks passed
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.

Frontend cleanup: admin routes, translate components → ui-lib, wrapper file removal (supersedes #092 scope)

2 participants