From 0eea9ba13b3bcdd497238cb31e65e3ed6034decb Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Mon, 5 Oct 2026 00:48:33 -0500 Subject: [PATCH] Links/redirects: Copy link on a saved redirect A manifest's idLink gives a saved record's own address, shown on its URL ID card with a Copy link button; redirects use it for the /go/ link. Co-Authored-By: Claude Opus 5.5 --- src/lib/adminSchema/redirects.ts | 4 +++- src/pages/admin/EntityEdit.tsx | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/lib/adminSchema/redirects.ts b/src/lib/adminSchema/redirects.ts index 06a5acb..c766d2b 100644 --- a/src/lib/adminSchema/redirects.ts +++ b/src/lib/adminSchema/redirects.ts @@ -5,7 +5,7 @@ /go/, and passed on with the link's UTM tags. Server side: server/src/admin-schema/redirects.js and routes/redirects.js. */ -import { SITE_ORIGIN } from "../site.ts"; +import { SITE_ORIGIN, siteUrl } from "../site.ts"; const GO = `${SITE_ORIGIN.replace(/^https?:\/\//, "").replace(/\/$/, "")}/go/`; @@ -15,6 +15,8 @@ export const redirects = { singular: "redirect", idLabel: "URL ID", idPrefix: GO, + // The address to share, copied from the saved redirect's page. + idLink: (id: string) => siteUrl(`/go/${id}`), list: { columns: [ diff --git a/src/pages/admin/EntityEdit.tsx b/src/pages/admin/EntityEdit.tsx index bf37f84..7a12bfa 100644 --- a/src/pages/admin/EntityEdit.tsx +++ b/src/pages/admin/EntityEdit.tsx @@ -46,7 +46,7 @@ why the array form exists and teams uses it. ═══════════════════════════════════════════════════════════════ */ -import { ArrowLeft } from "@phosphor-icons/react"; +import { ArrowLeft, Check, Copy } from "@phosphor-icons/react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useLocation, useNavigate, useParams } from "react-router-dom"; @@ -450,6 +450,7 @@ export default function EntityEdit() { change("id", `${prefixOf(form)}${slugify(value)}`); }} /> + {!isNew && manifest.idLink && } {!isNew && form.updated_at && (

Last saved {form.updated_at} @@ -649,3 +650,26 @@ function RequestedChanges({ request, isNew, form, onUse, onAdd }: any) { ); } +/* A saved record's own link (the manifest's `idLink`, eg. a redirect's + /go/ address), with a button to copy it. */ +function CopyLink({ url }: { url: string }) { + const [copied, setCopied] = useState(false); + return ( +

+ {url} + +
+ ); +}