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 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-05 00:48:33 -05:00
parent e060153798
commit 0eea9ba13b
2 changed files with 28 additions and 2 deletions

View file

@ -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 && <CopyLink url={manifest.idLink(form.id)} />}
{!isNew && form.updated_at && (
<p className="mt-2 text-xs text-muted">
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 (
<div className="mt-3 flex flex-wrap items-center gap-3">
<code className="break-all text-sm text-body">{url}</code>
<button
type="button"
onClick={() =>
navigator.clipboard?.writeText(url).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 1500);
})
}
className="btn inline-flex items-center gap-1.5 border border-link px-3 py-1 text-sm text-link transition-colors hover:bg-tint"
>
{copied ? <Check weight="bold" aria-hidden="true" /> : <Copy weight="bold" aria-hidden="true" />}
{copied ? "Copied" : "Copy link"}
</button>
</div>
);
}