From e8078b2673446b39a8e20879751de0c2b3fe09c8 Mon Sep 17 00:00:00 2001 From: Julien Herr Date: Mon, 25 May 2026 17:59:55 +0200 Subject: [PATCH] refactor(admin): extract shared FeedChip, dedupe native/format chips NativeFeedChip duplicated ~all of FormatChip's accessible copy-script markup. Extract one FeedChip (copy + open + optional validate); both the Subscribe formats and native feeds now render through it, keeping the copyable-value/data-copy markup identical in one place. Co-Authored-By: Claude Opus 4.7 --- src/routes/admin/ui.tsx | 136 +++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 73 deletions(-) diff --git a/src/routes/admin/ui.tsx b/src/routes/admin/ui.tsx index ed3d16f..43ad489 100644 --- a/src/routes/admin/ui.tsx +++ b/src/routes/admin/ui.tsx @@ -182,45 +182,47 @@ const FORMAT_LABELS: Record = { json: "JSON", }; -const FormatChip = ({ +// One copyable feed chip: copy + open, plus an optional validate action. +// Shared by the KTN "Subscribe" formats and the detected native feeds, so the +// copy-script markup (`copyable-value`/`data-copy`) stays identical in one place. +const FeedChip = ({ + label, format, - feedId, - env, + url, + validateUrl, }: { + label: string; format: FeedFormat; - feedId: string; - env: Env; -}) => { - const url = feedFormatUrl(format, feedId, env); - const validateUrl = feedValidatorUrl(format, feedId, env); - const label = FORMAT_LABELS[format]; - return ( -
- {label} - - - - - - - - + url: string; + validateUrl?: string; +}) => ( +
+ {label} + + + + + + + - - - + + + + + {validateUrl && ( - -
- ); -}; + )} +
+
+); + +const FormatChip = ({ + format, + feedId, + env, +}: { + format: FeedFormat; + feedId: string; + env: Env; +}) => ( + +); export const FeedFormats = ({ feedId, @@ -257,40 +276,6 @@ export const FeedFormats = ({ // ── Native feed chips ───────────────────────────────────────────────────────── -const NativeFeedChip = ({ feed }: { feed: NativeFeed }) => { - const label = FORMAT_LABELS[feed.type]; - return ( -
- {label} - - - - - - - - - - - - - - -
- ); -}; - export const NativeFeeds = ({ feeds }: { feeds: NativeFeed[] }) => { if (feeds.length === 0) return null; return ( @@ -298,7 +283,12 @@ export const NativeFeeds = ({ feeds }: { feeds: NativeFeed[] }) => { Native feeds
{feeds.map((feed) => ( - + ))}