v1.13.1-data: links/redirects, captions, partner picks, Plausible reports, migration baseline #28

Merged
ngu-git-admin merged 16 commits from data into main 2026-10-06 10:10:57 +01:00
3 changed files with 41 additions and 3 deletions
Showing only changes of commit e060153798 - Show all commits

View file

@ -106,6 +106,8 @@ export const OPTION_QUERIES = {
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",
person_tag_types: "SELECT id, name AS label FROM person_tag_types ORDER BY sort_order, name",
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
// Link fields with `redirects: true` pick from these (068).
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
// org_id rides along so the affiliation row can filter the list

View file

@ -62,6 +62,10 @@
the file's name and first-page preview. `filesWhen` limits it to
rows that match, as `when` does for the field.
`redirects: true` on a link field adds "Pick a redirect": a list of
Data → Links/redirects (the `redirects` options) that fills the
field with the short link's full address, <site>/go/<URL ID>.
`widget: "testNotice"` is a text box of email addresses with a
"Send a test notice" button (TestNoticeInput below), for Site
settings → Notices.
@ -97,6 +101,7 @@ import ContentBlocks from "../ContentBlocks.tsx";
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
import { ChooseFileButton } from "./DriveFiles.tsx";
import { siteUrl } from "../../lib/site.ts";
/* Live previews a collection can name with `preview`. Each gets the
row as the form holds it, which is the API's shape. */
@ -434,6 +439,21 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
<ChooseFileButton value={value} onPick={pickFile} />
</div>
)}
{field.redirects && !locked && options?.redirects?.length > 0 && (
<select
value=""
onChange={(e) => e.target.value && onChange(siteUrl(`/go/${e.target.value}`))}
aria-label={`${typeof field.label === "function" ? field.label(row) : field.label}: pick a redirect`}
className={`mt-2 ${common.className}`}
>
<option value="">Pick a redirect (Data → Links/redirects)</option>
{options.redirects.map((option) => (
<option key={option.id} value={option.id}>
{option.label}
</option>
))}
</select>
)}
</div>
{error ? (

View file

@ -103,7 +103,18 @@ const sourceOf = (part: NewsletterPart): PickSource => (SOURCES.includes(part.so
/* Every part is a row: one editor for blocks and the email's own
parts, so any of them can be moved, copied or removed. */
const blockFields = blocksChild.fields.filter((field) => !['slot', 'team_id', 'type', 'captions'].includes(field.path))
/* Every link a block or its items carry can be a short link
(Data → Links/redirects), so its clicks are counted. */
const LINK_PATHS = ['href', 'url']
const withRedirects = (field: any) => (LINK_PATHS.includes(field.path) ? { ...field, redirects: true } : field)
const withRedirectsChild = (child: any) => ({
...child,
fields: child.fields.map(withRedirects),
children: child.children?.map(withRedirectsChild),
})
const blockFields = blocksChild.fields
.filter((field) => !['slot', 'team_id', 'type', 'captions'].includes(field.path))
.map(withRedirects)
const PARTS_SPEC = {
key: 'parts',
label: 'Parts',
@ -188,7 +199,7 @@ const PARTS_SPEC = {
{ path: 'space', label: 'Space above', widget: 'number', when: { path: 'type', value: 'divider' }, help: 'In pixels, 0 to 64. Default: 24' },
],
children: [
...(blocksChild.children ?? []),
...(blocksChild.children ?? []).map(withRedirectsChild),
{
key: 'socials',
label: 'Links',
@ -254,6 +265,7 @@ export default function AdminNewsletter() {
const [posts, setPosts] = useState<PostRow[] | null>(null)
const [postDetails, setPostDetails] = useState<Record<string, BlogPostRecord>>({})
const [copied, setCopied] = useState<'html' | 'text' | null>(null)
const [redirects, setRedirects] = useState<{ id: string; label: string }[]>([])
// The draft being edited: null is a new one, not saved yet.
const [drafts, setDrafts] = useState<DraftRow[]>([])
@ -269,6 +281,9 @@ export default function AdminNewsletter() {
get('/admin/blog_posts?is_published=1&is_listed=1&limit=200', { ttl: 0 })
.then((data: { rows: PostRow[] }) => setPosts(data.rows))
.catch(() => setPosts([]))
get('/admin/options?only=redirects', { ttl: 0 })
.then((data: { options: { redirects: { id: string; label: string }[] } }) => setRedirects(data.options.redirects))
.catch(() => setRedirects([]))
}, [])
const loadDrafts = () =>
@ -411,8 +426,9 @@ export default function AdminNewsletter() {
countdownEvents: events
.filter((event) => !event.is_series && event.starts_on)
.map((event) => ({ id: event.id, label: [event.title, event.date_label].filter(Boolean).join(', ') })),
redirects,
}),
[events, posts, cards],
[events, posts, cards, redirects],
)
const newsletter = useMemo(() => {