[PR #6598] [CLOSED] feat(links): add the panel-side UI for the external links library #6369

Closed
opened 2026-11-02 04:08:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6598
Author: @BlindMaster24
Created: 9/18/2026
Status: ❌ Closed

Base: main ← Head: feat/external-links-ui


📝 Commits (6)

  • 5afa867 feat(links): make external links a panel-wide library with scopes
  • eac7ef0 feat(links): add the panel-side UI for the external links library
  • c920e1a test(links): cover the library page, its form and the assignment targets
  • 1d1c90c test(links): pin the id gating of the targets and client-links queries
  • 4e9c37b test(nodes): stop the history chart assertion racing its own effect
  • 07644eb fix(links): translate the refreshed toast and cover the refresh action

📊 Changes

71 files changed (+8827 additions, -330 deletions)

View changed files

📝 docs/content/docs/en/reference/api/clients.mdx (+29 -21)
➕ docs/content/docs/en/reference/api/external-links.mdx (+122 -0)
📝 docs/public/openapi.json (+1069 -2)
📝 frontend/public/openapi.json (+1069 -2)
➕ frontend/src/api/queries/useGroupOptions.ts (+22 -0)
➕ frontend/src/api/queries/useLinkMutations.ts (+85 -0)
➕ frontend/src/api/queries/useLinksQuery.ts (+80 -0)
📝 frontend/src/api/queryKeys.ts (+6 -0)
📝 frontend/src/generated/examples.ts (+69 -0)
📝 frontend/src/generated/schemas.ts (+338 -0)
📝 frontend/src/generated/types.ts (+74 -0)
📝 frontend/src/generated/zod.ts (+79 -0)
📝 frontend/src/layouts/AppSidebar.tsx (+5 -1)
📝 frontend/src/lib/clients/external-link.ts (+13 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+275 -3)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+42 -1)
➕ frontend/src/pages/links/LinkFormModal.tsx (+148 -0)
➕ frontend/src/pages/links/LinkTargetsModal.tsx (+194 -0)
➕ frontend/src/pages/links/LinksPage.tsx (+362 -0)
📝 frontend/src/routes.tsx (+2 -0)

...and 51 more files

📄 Description

What

Supply B of the external-links work: the panel side of the library that
#6571 added as an API. Until now the library could only be written with curl,
and a client's inherited links were invisible in the panel.

  • Links page (/links, sidebar entry + route): the library in display order
    with kind, value, remark, how many clients inherit each row, last fetch state,
    and per-row enable, move up/down, refresh (subscriptions), edit, delete, and
    the targets dialog (assign / unassign to client, group, inbound, every client,
    new clients).
  • Client card: a read-only "Inherited links" block naming the scope that
    granted each row, so an operator can see where a link comes from instead of
    only seeing what the client owns.
  • Data layer: src/schemas/api/link.ts (Zod, contract-shaped), link query
    keys, useLinksQuery / useLinkMutations / useGroupOptions.
  • i18n: 34 keys in all 13 locales, referenced from the frontend (the
    dead-keys test pins both directions).

Stacked on #6571

This branch is based on feat/external-links-library (head of #6571), so the
diff below also contains that PR's commit — 5afa8677 is A, eac7ef04 is B.
Merge #6571 first and I will rebase this onto main; the diff then shrinks to
the UI commit alone. Nothing here is merged.

Two defects found while reviewing this change

Both were introduced by this change and are fixed in it:

  1. The form offered to clear User-Agent / cache TTL, and clearing silently did
    nothing.
    ExternalLinkLibrarySave writes those two columns only when they
    carry a value (internal/web/service/external_link_library.go:132), so an
    empty field was a change the endpoint dropped — the operator cleared it,
    reopened the row, and found the old value. The payload now omits a blank
    field instead of sending one, and both fields carry a hint saying a blank
    value keeps the stored one. Pinned by a red-first test
    (toLinkSaveRequest): with the two deletes reverted the test fails, with
    them restored it passes.

    Residual limitation, deliberately not papered over: the panel can set or
    replace those two fields but cannot remove them, because the endpoint has no
    way to express "clear" — that needs the column to become nullable, which is a
    separate change to the API contract, not part of a UI PR.

  2. The "Last fetch" column ignored the panel's datepicker setting. It used
    new Date(value).toLocaleString(), unlike the rest of the panel, which goes
    through IntlUtil.formatDate(value, datepicker); on a Jalali panel, and in
    any language, it rendered a different format from every other table. Now it
    uses the house helper.

Verification

  • npx tsc --noEmit clean, npm run lint (oxlint) 0/0, oxfmt --check clean,
    npm run build succeeds.
  • npx vitest run --project unit — 79/80 files pass, 11 tests green in the
    files this change touches (links-request-payloads, i18n-dead-keys,
    client-external-link-expiry).
  • Locale key parity checked across all 13 files: 0 missing, 0 extra.
  • node scripts/build-openapi.mjs — no drift; this change adds no routes and no
    Go structs, so frontend/public/openapi.json and docs/public/openapi.json
    are untouched.

Three failure classes are local-environment only, not this change — none of them
can see the code here, and CI is the arbiter:

  • src/test/input-number-guard.test.ts (pre-existing): the installed oxlint is
    1.82.0 while frontend/package.json pins 1.83.0, so the AST-walking
    guard reports nothing to the test's execFileSync. The fixtures and the rule
    are untouched by this branch; run directly, the guard still reports all three
    hits.
  • FormField.stories.tsx > Traffic Transform: the story asserts
    107,374,182,400 bytes, but the storybook browser takes the host locale
    (ru-RU) and renders NBSP separators.
  • TextModal / NotificationLayout stories: Failed to fetch dynamically imported module from the Vitest browser server (one of them axe-core) —
    infrastructure flake in the local runner.

Go and DB-backed tests cannot run on this machine (no C compiler, so
internal/database does not build); CI runs them.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6598 **Author:** [@BlindMaster24](https://github.com/BlindMaster24) **Created:** 9/18/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/external-links-ui` --- ### 📝 Commits (6) - [`5afa867`](https://github.com/MHSanaei/3x-ui/commit/5afa86772f75ea3591ff6b9f5d70a4395006dc9d) feat(links): make external links a panel-wide library with scopes - [`eac7ef0`](https://github.com/MHSanaei/3x-ui/commit/eac7ef04d33605c3cb3521d7cfbb81ad549f0de9) feat(links): add the panel-side UI for the external links library - [`c920e1a`](https://github.com/MHSanaei/3x-ui/commit/c920e1a2f4808f5c50d3ae4cf9018af09f303336) test(links): cover the library page, its form and the assignment targets - [`1d1c90c`](https://github.com/MHSanaei/3x-ui/commit/1d1c90ca7a62eff5169bff8e3ef2b9174f3e20a5) test(links): pin the id gating of the targets and client-links queries - [`4e9c37b`](https://github.com/MHSanaei/3x-ui/commit/4e9c37bcfd60fb40d1b10acfb4d30801063c5587) test(nodes): stop the history chart assertion racing its own effect - [`07644eb`](https://github.com/MHSanaei/3x-ui/commit/07644eb9370e08025aec556d6e3a91b6858993be) fix(links): translate the refreshed toast and cover the refresh action ### 📊 Changes **71 files changed** (+8827 additions, -330 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/reference/api/clients.mdx` (+29 -21) ➕ `docs/content/docs/en/reference/api/external-links.mdx` (+122 -0) 📝 `docs/public/openapi.json` (+1069 -2) 📝 `frontend/public/openapi.json` (+1069 -2) ➕ `frontend/src/api/queries/useGroupOptions.ts` (+22 -0) ➕ `frontend/src/api/queries/useLinkMutations.ts` (+85 -0) ➕ `frontend/src/api/queries/useLinksQuery.ts` (+80 -0) 📝 `frontend/src/api/queryKeys.ts` (+6 -0) 📝 `frontend/src/generated/examples.ts` (+69 -0) 📝 `frontend/src/generated/schemas.ts` (+338 -0) 📝 `frontend/src/generated/types.ts` (+74 -0) 📝 `frontend/src/generated/zod.ts` (+79 -0) 📝 `frontend/src/layouts/AppSidebar.tsx` (+5 -1) 📝 `frontend/src/lib/clients/external-link.ts` (+13 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+275 -3) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+42 -1) ➕ `frontend/src/pages/links/LinkFormModal.tsx` (+148 -0) ➕ `frontend/src/pages/links/LinkTargetsModal.tsx` (+194 -0) ➕ `frontend/src/pages/links/LinksPage.tsx` (+362 -0) 📝 `frontend/src/routes.tsx` (+2 -0) _...and 51 more files_ </details> ### 📄 Description ## What Supply B of the external-links work: the panel side of the library that #6571 added as an API. Until now the library could only be written with `curl`, and a client's inherited links were invisible in the panel. - **Links page** (`/links`, sidebar entry + route): the library in display order with kind, value, remark, how many clients inherit each row, last fetch state, and per-row enable, move up/down, refresh (subscriptions), edit, delete, and the targets dialog (assign / unassign to client, group, inbound, every client, new clients). - **Client card**: a read-only "Inherited links" block naming the scope that granted each row, so an operator can see where a link comes from instead of only seeing what the client owns. - **Data layer**: `src/schemas/api/link.ts` (Zod, contract-shaped), link query keys, `useLinksQuery` / `useLinkMutations` / `useGroupOptions`. - **i18n**: 34 keys in all 13 locales, referenced from the frontend (the dead-keys test pins both directions). ## Stacked on #6571 This branch is based on `feat/external-links-library` (head of #6571), so the diff below **also contains that PR's commit** — 5afa8677 is A, eac7ef04 is B. Merge #6571 first and I will rebase this onto `main`; the diff then shrinks to the UI commit alone. Nothing here is merged. ## Two defects found while reviewing this change Both were introduced by this change and are fixed in it: 1. **The form offered to clear User-Agent / cache TTL, and clearing silently did nothing.** `ExternalLinkLibrarySave` writes those two columns only when they carry a value (`internal/web/service/external_link_library.go:132`), so an empty field was a change the endpoint dropped — the operator cleared it, reopened the row, and found the old value. The payload now omits a blank field instead of sending one, and both fields carry a hint saying a blank value keeps the stored one. Pinned by a red-first test (`toLinkSaveRequest`): with the two `delete`s reverted the test fails, with them restored it passes. Residual limitation, deliberately not papered over: the panel can set or replace those two fields but cannot remove them, because the endpoint has no way to express "clear" — that needs the column to become nullable, which is a separate change to the API contract, not part of a UI PR. 2. **The "Last fetch" column ignored the panel's datepicker setting.** It used `new Date(value).toLocaleString()`, unlike the rest of the panel, which goes through `IntlUtil.formatDate(value, datepicker)`; on a Jalali panel, and in any language, it rendered a different format from every other table. Now it uses the house helper. ## Verification - `npx tsc --noEmit` clean, `npm run lint` (oxlint) 0/0, `oxfmt --check` clean, `npm run build` succeeds. - `npx vitest run --project unit` — 79/80 files pass, 11 tests green in the files this change touches (`links-request-payloads`, `i18n-dead-keys`, `client-external-link-expiry`). - Locale key parity checked across all 13 files: 0 missing, 0 extra. - `node scripts/build-openapi.mjs` — no drift; this change adds no routes and no Go structs, so `frontend/public/openapi.json` and `docs/public/openapi.json` are untouched. Three failure classes are local-environment only, not this change — none of them can see the code here, and CI is the arbiter: - `src/test/input-number-guard.test.ts` (pre-existing): the installed oxlint is **1.82.0** while `frontend/package.json` pins **1.83.0**, so the AST-walking guard reports nothing to the test's `execFileSync`. The fixtures and the rule are untouched by this branch; run directly, the guard still reports all three hits. - `FormField.stories.tsx > Traffic Transform`: the story asserts `107,374,182,400 bytes`, but the storybook browser takes the host locale (`ru-RU`) and renders NBSP separators. - `TextModal` / `NotificationLayout` stories: `Failed to fetch dynamically imported module` from the Vitest browser server (one of them `axe-core`) — infrastructure flake in the local runner. Go and DB-backed tests cannot run on this machine (no C compiler, so `internal/database` does not build); CI runs them. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6369
No description provided.