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} + +
+ ); +}