@igstack/app-catalog-frontend-core 6.12.0 → 6.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/api/infra/trpc.d.ts +27 -0
- package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js +0 -1
- package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js +0 -1
- package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js.map +1 -1
- package/dist/esm/modules/communityTools/siteOpen.d.ts +10 -0
- package/dist/esm/modules/communityTools/siteOpen.js +18 -0
- package/dist/esm/modules/communityTools/siteOpen.js.map +1 -0
- package/dist/esm/modules/communityTools/timeAgo.d.ts +2 -0
- package/dist/esm/modules/communityTools/timeAgo.js +11 -0
- package/dist/esm/modules/communityTools/timeAgo.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/CardScreenshot.js +10 -12
- package/dist/esm/modules/communityTools/ui/CardScreenshot.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/CardTitleBlock.d.ts +1 -1
- package/dist/esm/modules/communityTools/ui/CardTitleBlock.js +5 -13
- package/dist/esm/modules/communityTools/ui/CardTitleBlock.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/CommunityPage.js +2 -4
- package/dist/esm/modules/communityTools/ui/CommunityPage.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/FeedRow.d.ts +6 -3
- package/dist/esm/modules/communityTools/ui/FeedRow.js +14 -8
- package/dist/esm/modules/communityTools/ui/FeedRow.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/ShelfTile.js +4 -7
- package/dist/esm/modules/communityTools/ui/ShelfTile.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/ToolCard.js +15 -3
- package/dist/esm/modules/communityTools/ui/ToolCard.js.map +1 -1
- package/dist/esm/modules/communityTools/ui/ToolFormDialog.js +0 -1
- package/dist/esm/modules/communityTools/ui/ToolFormDialog.js.map +1 -1
- package/dist/esm/modules/communityTools/useCommunityTools.d.ts +2 -0
- package/dist/esm/modules/communityTools/useCommunityTools.js +0 -1
- package/dist/esm/modules/communityTools/useCommunityTools.js.map +1 -1
- package/package.json +4 -4
- package/src/modules/communityTools/siteOpen.ts +20 -0
- package/src/modules/communityTools/timeAgo.ts +12 -0
- package/src/modules/communityTools/ui/CardScreenshot.tsx +21 -9
- package/src/modules/communityTools/ui/CardTitleBlock.tsx +4 -9
- package/src/modules/communityTools/ui/CommunityPage.tsx +2 -5
- package/src/modules/communityTools/ui/FeedRow.tsx +19 -15
- package/src/modules/communityTools/ui/ShelfTile.tsx +4 -5
- package/src/modules/communityTools/ui/ToolCard.tsx +11 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolFormDialog.js","sources":["../../../../../src/modules/communityTools/ui/ToolFormDialog.tsx"],"sourcesContent":["import type { ToolPreview } from '@igstack/app-catalog-backend-core'\nimport type {\n CommunityTag,\n CommunityTool,\n PersonRef,\n} from '@igstack/app-catalog-shared-core'\nimport { TAG_VALUE_MAX, hostOf } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { Link } from '@tanstack/react-router'\nimport {\n AlertCircle,\n AlertTriangle,\n Archive,\n Camera,\n CheckCircle2,\n ImageOff,\n Loader2,\n X,\n} from 'lucide-react'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { cn } from '~/lib/utils'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { MarkdownText } from '~/modules/appCatalog/ui/components/MarkdownText'\nimport { useAuth } from '~/modules/auth'\nimport { useDismissable } from '~/modules/dismiss/DismissStack'\nimport { Dialog, DialogContent, DialogTitle } from '~/ui/dialog'\nimport { formatCardDate } from './CardScreenshot'\nimport { screenshotUrl } from './FeedRow'\nimport { FIELD_BAD, FIELD_BOX, OwnerPicker, personName } from './OwnerPicker'\nimport { TagPicker } from './TagPicker'\n\n/** How long the address must sit still before the site is read. */\nconst PREVIEW_DELAY_MS = 400\n\nconst NAME_MAX = 80\nconst SUMMARY_MAX = 160\nconst DESCRIPTION_MAX = 5000\n\nexport const GHOST_BUTTON =\n 'inline-flex h-[34px] items-center gap-[7px] rounded-[10px] border border-border bg-card px-[11px] text-[13px] font-bold whitespace-nowrap hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50'\n\nexport const PRIMARY_BUTTON =\n 'inline-flex h-[34px] items-center gap-2 rounded-[10px] bg-primary px-4 text-[13.5px] font-extrabold whitespace-nowrap text-primary-foreground shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-50'\n\nconst LABEL = 'text-[13px] font-bold'\nconst HINT = 'text-[12.5px] text-muted-foreground'\n\ntype Field = 'name' | 'owners' | 'tags'\n\nexport interface ToolFormDialogProps {\n mode: 'add' | 'edit'\n /** The tool being edited. */\n initial?: CommunityTool\n /** What the visitor searched for: a first guess at the name. */\n prefillName?: string\n /** Published, saved or archived. */\n onDone: (slug: string) => void\n onClose: () => void\n /** The address is already listed, and they chose to look at that card. */\n onOpenCard?: (slug: string) => void\n}\n\n/** A field's error, next to it; the form points at the first one on submit. */\nfunction FieldError({ id, children }: { id: string; children: string }) {\n return (\n <p\n id={id}\n role=\"alert\"\n className=\"flex items-center gap-1.5 text-[12.5px] font-bold text-destructive\"\n >\n <AlertCircle aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n {children}\n </p>\n )\n}\n\n/**\n * Add a tool, or edit one: the same form. The address comes first; once it\n * sits still the backend reads the page, the title fills the name and a\n * screenshot preview shows. A host already listed is caught before anything\n * else is asked. Publish makes the tool live at once and puts it in the\n * review list.\n */\nexport function ToolFormDialog({\n mode,\n initial,\n prefillName,\n onDone,\n onClose,\n onOpenCard,\n}: ToolFormDialogProps) {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { user } = useAuth()\n const { persons, resources } = useAppCatalogContext()\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const formId = useId()\n const ids = {\n url: `${formId}-url`,\n name: `${formId}-name`,\n summary: `${formId}-summary`,\n owners: `${formId}-owners`,\n tags: `${formId}-tags`,\n description: `${formId}-description`,\n }\n const errorId = (field: string) => `${field}-error`\n\n const [url, setUrl] = useState(initial?.url ?? '')\n const [name, setName] = useState(initial?.name ?? prefillName ?? '')\n // The page title fills the name only until the visitor writes their own.\n const [nameTouched, setNameTouched] = useState(mode === 'edit')\n // The same, for the debounced read below, without restarting its timer.\n const nameTouchedRef = useRef(nameTouched)\n const [summary, setSummary] = useState(initial?.summary ?? '')\n const [descriptionMd, setDescriptionMd] = useState(\n initial?.descriptionMd ?? '',\n )\n const [owners, setOwners] = useState<PersonRef[]>(() => {\n if (initial) return initial.owners\n // The person adding it is the first owner, when the directory knows them.\n const email = user?.email?.toLowerCase()\n const me = email\n ? persons.find(\n (p) =>\n p.email?.toLowerCase() === email || p.slug.toLowerCase() === email,\n )\n : undefined\n return me ? [{ slug: me.slug, name: personName(me) }] : []\n })\n const [tags, setTags] = useState<CommunityTag[]>(initial?.tags ?? [])\n const [tab, setTab] = useState<'write' | 'preview'>('write')\n const [errors, setErrors] = useState<Partial<Record<Field, string>>>({})\n const [archiving, setArchiving] = useState(false)\n\n // The address as it was when the visitor stopped typing, and what reading it gave.\n const [checked, setChecked] = useState(initial?.url ?? '')\n const [preview, setPreview] = useState<{\n url: string\n data: ToolPreview | null\n } | null>(null)\n const [addAnywayFor, setAddAnywayFor] = useState<string | null>(null)\n\n const previewMutation = useMutation(\n trpc.communityTools.preview.mutationOptions(),\n )\n const { mutateAsync: readSite } = previewMutation\n useEffect(() => {\n const address = url.trim()\n // Set once the address changes again: a slower answer for this one must\n // not overwrite the newer address's preview or name.\n let stale = false\n const timer = setTimeout(() => {\n setChecked(address)\n if (!needsPreviewFor(address, mode, initial?.url)) return\n readSite({ url: address }).then(\n (data) => {\n if (stale) return\n setPreview({ url: address, data })\n if (data.title && !nameTouchedRef.current) setName(data.title)\n },\n () => {\n if (!stale) setPreview({ url: address, data: null })\n },\n )\n }, PREVIEW_DELAY_MS)\n return () => {\n stale = true\n clearTimeout(timer)\n }\n }, [url, mode, initial?.url, readSite])\n\n const address = url.trim()\n const validAddress = hostOf(address) !== null\n const showBadAddress = checked !== '' && checked === address && !validAddress\n const reading =\n needsPreviewFor(address, mode, initial?.url) &&\n (checked !== address || preview?.url !== address)\n const current = preview?.url === address ? preview.data : null\n const duplicate =\n current?.duplicate && current.duplicate.slug !== initial?.slug\n ? current.duplicate\n : null\n // An official catalog app on the same host outranks a community duplicate.\n const officialApp = current?.officialApp ?? null\n const blockedByDuplicate =\n (officialApp !== null || duplicate !== null) && addAnywayFor !== address\n const showDetails =\n mode === 'edit' ||\n (validAddress && !reading && !blockedByDuplicate) ||\n (!validAddress && name.trim() !== '' && !showBadAddress)\n\n const invalidate = () =>\n queryClient.invalidateQueries({\n queryKey: trpc.communityTools.pathKey(),\n })\n const add = useMutation(\n trpc.communityTools.add.mutationOptions({ onSuccess: invalidate }),\n )\n const edit = useMutation(\n trpc.communityTools.edit.mutationOptions({ onSuccess: invalidate }),\n )\n const archive = useMutation(\n trpc.communityTools.archive.mutationOptions({ onSuccess: invalidate }),\n )\n const save = mode === 'add' ? add : edit\n const busy = save.isPending || archive.isPending\n\n const urlRef = useRef<HTMLInputElement>(null)\n\n const submit = (e: React.FormEvent) => {\n e.preventDefault()\n // Publish stays disabled until the address is one; Enter in a field\n // cannot submit past a disabled button either.\n if (busy || !validAddress) return\n const found: Partial<Record<Field, string>> = {}\n if (!name.trim()) found.name = 'Give it the name colleagues call it.'\n if (owners.length === 0) {\n found.owners = 'Add at least one person to ask about it.'\n }\n setErrors(found)\n const first = (['name', 'owners'] as const).find((f) => found[f])\n if (first) {\n document.getElementById(ids[first])?.focus()\n return\n }\n const input = {\n url: address,\n name: name.trim(),\n summary: summary.trim(),\n descriptionMd,\n ownerSlugs: owners.flatMap((o) => (o.slug ? [o.slug] : [])),\n ownerNames: owners.flatMap((o) => (o.slug ? [] : [o.name])),\n tags,\n }\n if (mode === 'add') {\n add.mutate(input, { onSuccess: (tool) => onDone(tool.slug) })\n } else if (initial) {\n edit.mutate(\n { ...input, slug: initial.slug },\n { onSuccess: (tool) => onDone(tool.slug) },\n )\n }\n }\n\n const contentRef = useRef<HTMLDivElement>(null)\n // On the dismiss stack, so Escape closes this form and not the card under\n // it; while it saves, Escape does nothing at all.\n useDismissable(contentRef, () => {\n if (!busy) onClose()\n })\n\n const officialApps = resources.filter((r) => !r.parentSlug)\n const knownTopics = [\n ...new Set(\n (list.data ?? []).flatMap((t) =>\n t.tags.filter((g) => g.kind === 'topic').map((g) => g.value),\n ),\n ),\n ].sort()\n\n const title = mode === 'add' ? 'Add a tool' : 'Edit tool'\n const serverError = save.error ?? archive.error\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !busy) onClose()\n }}\n >\n <DialogContent\n ref={contentRef}\n data-testid={mode === 'add' ? 'add-tool-dialog' : 'edit-tool-dialog'}\n aria-describedby={undefined}\n showCloseButton={false}\n // Top-anchored: the form grows downward as the site is read, so\n // nothing above the caret moves.\n className=\"top-[6vh] max-h-[88vh] translate-y-0 gap-0 overflow-y-auto p-0 sm:max-w-[680px]\"\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n urlRef.current?.focus()\n }}\n // Typing is lost on a stray click; only Cancel, Close or Esc leave.\n onInteractOutside={(e) => e.preventDefault()}\n onEscapeKeyDown={(e) => {\n // An open suggestion list takes Escape for itself.\n const target = e.target as Element | null\n if (target?.closest('[aria-expanded=\"true\"]')) e.preventDefault()\n }}\n >\n <form onSubmit={submit} noValidate aria-busy={busy || undefined}>\n <div className=\"flex items-center justify-between px-5 pt-4\">\n <DialogTitle className=\"font-serif text-[19px] leading-tight font-semibold\">\n {title}\n </DialogTitle>\n <button\n type=\"button\"\n aria-label=\"Close\"\n disabled={busy}\n onClick={onClose}\n className=\"rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50\"\n >\n <X aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </div>\n\n <div className=\"flex flex-col gap-3.5 px-5 pt-4 pb-1.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.url} className={LABEL}>\n Site address\n </label>\n <div className={cn(FIELD_BOX, showBadAddress && FIELD_BAD)}>\n <input\n ref={urlRef}\n id={ids.url}\n type=\"url\"\n inputMode=\"url\"\n autoComplete=\"off\"\n placeholder=\"Paste the link to the tool\"\n value={url}\n disabled={busy}\n aria-invalid={showBadAddress || undefined}\n aria-describedby={\n showBadAddress ? errorId(ids.url) : `${ids.url}-hint`\n }\n onChange={(e) => setUrl(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent font-mono text-[13px] outline-none placeholder:font-sans placeholder:text-muted-foreground\"\n />\n {validAddress && reading && (\n <span\n data-testid=\"reading-site\"\n className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-muted-foreground\"\n >\n <Loader2\n aria-hidden=\"true\"\n className=\"size-3.5 animate-spin\"\n />\n Reading the site…\n </span>\n )}\n {validAddress &&\n !reading &&\n (current?.title || current?.screenshotDataUrl) && (\n <span className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-green-700 dark:text-green-400\">\n <CheckCircle2 aria-hidden=\"true\" className=\"size-3.5\" />\n Found\n </span>\n )}\n </div>\n {showBadAddress ? (\n <FieldError id={errorId(ids.url)}>\n That is not a web address. Paste the full link, starting with\n https://\n </FieldError>\n ) : (\n !validAddress &&\n !showDetails &&\n !blockedByDuplicate && (\n <p id={`${ids.url}-hint`} className={HINT}>\n Paste it first. The name and screenshot fill in from the\n site.\n </p>\n )\n )}\n </div>\n\n {validAddress && reading && <ReadingSkeleton />}\n\n {blockedByDuplicate && officialApp && (\n <div\n data-testid=\"official-app-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This is already in the catalog as {officialApp.name}.</b>\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <Link\n to=\"/app/$slug\"\n params={{ slug: officialApp.slug }}\n className={GHOST_BUTTON}\n >\n Open {officialApp.name}\n </Link>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {blockedByDuplicate && !officialApp && duplicate && (\n <div\n data-testid=\"duplicate-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This site is already here.</b> “{duplicate.name}” uses the\n same address.\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <button\n type=\"button\"\n className={GHOST_BUTTON}\n onClick={() => onOpenCard?.(duplicate.slug)}\n >\n Open that card\n </button>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {showDetails && (\n <>\n <div className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\">\n <div className=\"flex min-w-0 flex-col gap-3.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.name} className={LABEL}>\n Name\n </label>\n <div\n className={cn(\n FIELD_BOX,\n !nameTouched &&\n current?.title &&\n name === current.title &&\n 'bg-amber-50/70 dark:bg-amber-950/40',\n errors.name && FIELD_BAD,\n )}\n >\n <input\n id={ids.name}\n type=\"text\"\n maxLength={NAME_MAX}\n value={name}\n disabled={busy}\n aria-invalid={!!errors.name || undefined}\n aria-describedby={\n errors.name ? errorId(ids.name) : `${ids.name}-hint`\n }\n onChange={(e) => {\n setName(e.target.value)\n setNameTouched(true)\n nameTouchedRef.current = true\n setErrors((prev) => ({ ...prev, name: undefined }))\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n {errors.name ? (\n <FieldError id={errorId(ids.name)}>\n {errors.name}\n </FieldError>\n ) : (\n current?.title &&\n !nameTouched && (\n <p id={`${ids.name}-hint`} className={HINT}>\n From the page title. Change it if colleagues call it\n something else.\n </p>\n )\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.owners} className={LABEL}>\n Owners\n </label>\n <OwnerPicker\n id={ids.owners}\n persons={persons}\n value={owners}\n disabled={busy}\n invalid={!!errors.owners}\n describedBy={\n errors.owners\n ? errorId(ids.owners)\n : `${ids.owners}-hint`\n }\n onChange={(next) => {\n setOwners(next)\n setErrors((prev) => ({ ...prev, owners: undefined }))\n }}\n />\n {errors.owners ? (\n <FieldError id={errorId(ids.owners)}>\n {errors.owners}\n </FieldError>\n ) : (\n <p id={`${ids.owners}-hint`} className={HINT}>\n Who to ask about it. You are added by default.\n </p>\n )}\n </div>\n </div>\n <ShotPreview\n preview={current}\n initial={address === initial?.url ? initial : undefined}\n validAddress={validAddress}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.summary} className={LABEL}>\n Summary{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <div className={FIELD_BOX}>\n <input\n id={ids.summary}\n type=\"text\"\n maxLength={SUMMARY_MAX}\n value={summary}\n disabled={busy}\n aria-describedby={`${ids.summary}-hint`}\n onChange={(e) => setSummary(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <p id={`${ids.summary}-hint`} className={HINT}>\n One line under the name, in the list and on the card.\n </p>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.tags} className={LABEL}>\n Tags{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <TagPicker\n id={ids.tags}\n apps={officialApps}\n knownTopics={knownTopics}\n value={tags}\n disabled={busy}\n describedBy={\n errors.tags ? errorId(ids.tags) : `${ids.tags}-hint`\n }\n onChange={(next) => {\n setTags(next)\n setErrors((prev) => ({ ...prev, tags: undefined }))\n }}\n onTooLong={() =>\n setErrors((prev) => ({\n ...prev,\n tags: `A topic is at most ${TAG_VALUE_MAX} characters.`,\n }))\n }\n />\n {errors.tags ? (\n <FieldError id={errorId(ids.tags)}>\n {errors.tags}\n </FieldError>\n ) : (\n <p id={`${ids.tags}-hint`} className={HINT}>\n The app it is for, or a topic word. Press Enter to add a\n new topic.\n </p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.description} className={LABEL}>\n How to use\n </label>\n <div className=\"overflow-hidden rounded-[10px] border border-border bg-card\">\n <div\n role=\"tablist\"\n aria-label=\"Write or preview\"\n className=\"flex items-center gap-0.5 border-b border-border bg-muted p-1\"\n >\n {(['write', 'preview'] as const).map((t) => (\n <button\n key={t}\n type=\"button\"\n role=\"tab\"\n aria-selected={tab === t}\n onClick={() => setTab(t)}\n className={cn(\n 'rounded-[7px] px-3 py-1 text-[12.5px] font-bold text-muted-foreground',\n tab === t && 'bg-card text-foreground shadow-sm',\n )}\n >\n {t === 'write' ? 'Write' : 'Preview'}\n </button>\n ))}\n <span className=\"ml-auto pr-2 text-[11.5px] text-muted-foreground\">\n Markdown\n </span>\n </div>\n {/* Kept mounted while previewing, so the label and its draft stay. */}\n <textarea\n id={ids.description}\n rows={6}\n maxLength={DESCRIPTION_MAX}\n value={descriptionMd}\n disabled={busy}\n hidden={tab !== 'write'}\n aria-describedby={`${ids.description}-hint`}\n onChange={(e) => setDescriptionMd(e.target.value)}\n className=\"block w-full resize-y bg-transparent px-3 py-2.5 font-mono text-[12.5px] leading-relaxed outline-none\"\n />\n {tab === 'preview' && (\n <div\n data-testid=\"description-preview\"\n role=\"tabpanel\"\n className=\"prose prose-sm dark:prose-invert min-h-24 max-w-none px-3.5 py-2.5\"\n >\n {descriptionMd.trim() ? (\n <MarkdownText>{descriptionMd}</MarkdownText>\n ) : (\n <p className=\"text-muted-foreground\">\n Nothing written yet.\n </p>\n )}\n </div>\n )}\n </div>\n <p id={`${ids.description}-hint`} className={HINT}>\n Short steps work best. This is the text people read on the\n card.\n </p>\n </div>\n </>\n )}\n </div>\n\n {serverError && (\n <p\n role=\"alert\"\n className=\"mx-5 mt-2 rounded-[10px] bg-destructive/10 px-3 py-2 text-[13px] font-semibold text-destructive\"\n >\n {archive.error ? 'Could not archive it: ' : 'Could not save it: '}\n {serverError.message}\n </p>\n )}\n\n {archiving && initial ? (\n <div className=\"mt-2 border-t border-border px-5 pt-3 pb-4\">\n <ArchiveConfirm\n busy={archive.isPending}\n onCancel={() => setArchiving(false)}\n onArchive={(reason) =>\n archive.mutate(\n { slug: initial.slug, reason },\n { onSuccess: () => onDone(initial.slug) },\n )\n }\n />\n </div>\n ) : (\n <div className=\"mt-2 flex items-center justify-end gap-2.5 border-t border-border px-5 pt-3 pb-4\">\n {/* Already archived: nothing to archive, as on the card. */}\n {mode === 'edit' && initial?.lifecycle.state !== 'archived' && (\n <button\n type=\"button\"\n disabled={busy}\n onClick={() => setArchiving(true)}\n className=\"inline-flex items-center gap-1.5 text-[13px] font-bold text-destructive hover:underline disabled:opacity-50\"\n >\n <Archive aria-hidden=\"true\" className=\"size-3.5\" />\n Archive this tool\n </button>\n )}\n <span\n className={cn(\n 'text-[12.5px] text-muted-foreground',\n mode === 'add' ? 'mr-auto' : 'ml-auto',\n )}\n >\n {mode === 'add'\n ? 'Goes live now and joins the review list.'\n : 'Changes show on the card right away.'}\n </span>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onClose}\n className={GHOST_BUTTON}\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={!validAddress || reading || busy}\n aria-busy={save.isPending || undefined}\n className={PRIMARY_BUTTON}\n >\n {save.isPending && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {mode === 'add'\n ? save.isPending\n ? 'Publishing…'\n : 'Publish'\n : save.isPending\n ? 'Saving…'\n : 'Save changes'}\n </button>\n </div>\n )}\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction needsPreviewFor(\n address: string,\n mode: 'add' | 'edit',\n initialUrl: string | undefined,\n): boolean {\n return hostOf(address) !== null && (mode === 'add' || address !== initialUrl)\n}\n\n/** While the site is read: where the name, owners and picture will be. */\nfunction ReadingSkeleton() {\n return (\n <div\n aria-hidden=\"true\"\n className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\"\n >\n <div className=\"flex flex-col gap-3.5\">\n {['55%', '40%'].map((w, i) => (\n <div key={w} className=\"flex flex-col gap-1.5\">\n <span className={LABEL}>{i === 0 ? 'Name' : 'Owners'}</span>\n <span className={cn(FIELD_BOX, 'pointer-events-none')}>\n <i\n className=\"block h-3 animate-pulse rounded-md bg-muted\"\n style={{ width: w }}\n />\n </span>\n </div>\n ))}\n </div>\n <div className=\"mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 rounded-[10px] border border-border bg-muted text-xs font-semibold text-muted-foreground\">\n <Camera aria-hidden=\"true\" className=\"size-5 animate-pulse\" />\n Taking a screenshot…\n </div>\n </div>\n )\n}\n\n/** The picture the card will lead with, or why there will be none. */\nfunction ShotPreview({\n preview,\n initial,\n validAddress,\n}: {\n preview: ToolPreview | null\n /** The tool being edited, while its address is unchanged. */\n initial?: CommunityTool\n validAddress: boolean\n}) {\n const box =\n 'relative mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 overflow-hidden rounded-[10px] border border-border bg-muted px-3 text-center text-xs font-semibold text-muted-foreground'\n const caption =\n 'absolute bottom-1.5 left-1.5 inline-flex items-center gap-1 rounded-md bg-white/90 px-[7px] py-0.5 text-[11px] font-bold text-muted-foreground dark:bg-black/70'\n\n if (preview?.screenshotDataUrl) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={preview.screenshotDataUrl}\n alt=\"Screenshot preview of the site\"\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured just now\n </span>\n </div>\n )\n }\n if (initial?.screenshotId) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={screenshotUrl(initial.screenshotId, 640)}\n alt={`Screenshot of ${initial.name}`}\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n {initial.capturedAt && (\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured {formatCardDate(initial.capturedAt)}\n </span>\n )}\n </div>\n )\n }\n return (\n <div data-testid=\"shot-preview\" data-state=\"none\" className={box}>\n <ImageOff aria-hidden=\"true\" className=\"size-5\" />\n {preview && !preview.captureAllowed\n ? \"This site's address is outside the hosts we take screenshots of, so it will be listed without a picture.\"\n : validAddress\n ? 'No preview. The site may need a login, or it did not load.'\n : 'The screenshot shows here once the address is in.'}\n </div>\n )\n}\n\n/**\n * Archiving asks why, in one step: the reason is what colleagues read on the\n * card, and what the review list records.\n */\nexport function ArchiveConfirm({\n busy,\n onArchive,\n onCancel,\n}: {\n busy: boolean\n onArchive: (reason: string) => void\n onCancel: () => void\n}) {\n const id = useId()\n const inputRef = useRef<HTMLInputElement>(null)\n const [reason, setReason] = useState('')\n const [missing, setMissing] = useState(false)\n\n useEffect(() => {\n inputRef.current?.focus()\n }, [])\n\n const confirm = () => {\n if (!reason.trim()) {\n setMissing(true)\n inputRef.current?.focus()\n return\n }\n onArchive(reason.trim())\n }\n\n return (\n <div data-testid=\"archive-confirm\" className=\"flex flex-col gap-1.5\">\n <label htmlFor={id} className={LABEL}>\n Why archive it?\n </label>\n <div className=\"flex items-center gap-2.5\">\n <div className={cn(FIELD_BOX, 'flex-1', missing && FIELD_BAD)}>\n <input\n ref={inputRef}\n id={id}\n type=\"text\"\n maxLength={500}\n value={reason}\n disabled={busy}\n aria-invalid={missing || undefined}\n aria-describedby={missing ? `${id}-error` : `${id}-hint`}\n onChange={(e) => {\n setReason(e.target.value)\n setMissing(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onCancel}\n className={GHOST_BUTTON}\n >\n Keep it\n </button>\n <button\n type=\"button\"\n disabled={busy}\n aria-busy={busy || undefined}\n onClick={confirm}\n className={cn(PRIMARY_BUTTON, 'bg-destructive text-white')}\n >\n {busy && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {busy ? 'Archiving…' : 'Archive'}\n </button>\n </div>\n {missing ? (\n <FieldError id={`${id}-error`}>\n Say why, so colleagues know what happened to it.\n </FieldError>\n ) : (\n <p id={`${id}-hint`} className={HINT}>\n Colleagues read this on the card. It stays reachable by its link.\n </p>\n )}\n </div>\n )\n}\n"],"names":["_a","address"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCA,MAAM,mBAAmB;AAEzB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAEjB,MAAM,eACX;AAEK,MAAM,iBACX;AAEF,MAAM,QAAQ;AACd,MAAM,OAAO;AAkBb,SAAS,WAAW,EAAE,IAAI,YAA8C;AACtE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,oBAAC,aAAA,EAAY,eAAY,QAAO,WAAU,qBAAoB;AAAA,QAC7D;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP;AASO,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U,EAAE,OAAO,KAAK;AACxB,uBAAW,KAAK;AAAA,UAClB;AAAA,UACA,WAAW,CAAC,MAAM;AAChB,gBAAI,EAAE,QAAQ,SAAS;AACrB,gBAAE,eAAA;AACF,sBAAA;AAAA,YACF;AAAA,UACF;AAAA,UACA,WAAU;AAAA,QAAA;AAAA,MAAA,GAEd;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS;AAAA,UACT,WAAW;AAAA,UACZ,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAGD;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,UAAU;AAAA,UACV,aAAW,QAAQ;AAAA,UACnB,SAAS;AAAA,UACT,WAAW,GAAG,gBAAgB,2BAA2B;AAAA,UAExD,UAAA;AAAA,YAAA,QACC,oBAAC,SAAA,EAAQ,eAAY,QAAO,WAAU,uBAAsB;AAAA,YAE7D,OAAO,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzB,GACF;AAAA,IACC,UACC,oBAAC,YAAA,EAAW,IAAI,GAAG,EAAE,UAAU,UAAA,mDAAA,CAE/B,IAEA,oBAAC,OAAE,IAAI,GAAG,EAAE,SAAS,WAAW,MAAM,UAAA,oEAAA,CAEtC;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ToolFormDialog.js","sources":["../../../../../src/modules/communityTools/ui/ToolFormDialog.tsx"],"sourcesContent":["import type { ToolPreview } from '@igstack/app-catalog-backend-core'\nimport type {\n CommunityTag,\n CommunityTool,\n PersonRef,\n} from '@igstack/app-catalog-shared-core'\nimport { TAG_VALUE_MAX, hostOf } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { Link } from '@tanstack/react-router'\nimport {\n AlertCircle,\n AlertTriangle,\n Archive,\n Camera,\n CheckCircle2,\n ImageOff,\n Loader2,\n X,\n} from 'lucide-react'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { cn } from '~/lib/utils'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { MarkdownText } from '~/modules/appCatalog/ui/components/MarkdownText'\nimport { useAuth } from '~/modules/auth'\nimport { useDismissable } from '~/modules/dismiss/DismissStack'\nimport { Dialog, DialogContent, DialogTitle } from '~/ui/dialog'\nimport { formatCardDate } from './CardScreenshot'\nimport { screenshotUrl } from './FeedRow'\nimport { FIELD_BAD, FIELD_BOX, OwnerPicker, personName } from './OwnerPicker'\nimport { TagPicker } from './TagPicker'\n\n/** How long the address must sit still before the site is read. */\nconst PREVIEW_DELAY_MS = 400\n\nconst NAME_MAX = 80\nconst SUMMARY_MAX = 160\nconst DESCRIPTION_MAX = 5000\n\nexport const GHOST_BUTTON =\n 'inline-flex h-[34px] items-center gap-[7px] rounded-[10px] border border-border bg-card px-[11px] text-[13px] font-bold whitespace-nowrap hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50'\n\nexport const PRIMARY_BUTTON =\n 'inline-flex h-[34px] items-center gap-2 rounded-[10px] bg-primary px-4 text-[13.5px] font-extrabold whitespace-nowrap text-primary-foreground shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-50'\n\nconst LABEL = 'text-[13px] font-bold'\nconst HINT = 'text-[12.5px] text-muted-foreground'\n\ntype Field = 'name' | 'owners' | 'tags'\n\nexport interface ToolFormDialogProps {\n mode: 'add' | 'edit'\n /** The tool being edited. */\n initial?: CommunityTool\n /** What the visitor searched for: a first guess at the name. */\n prefillName?: string\n /** Published, saved or archived. */\n onDone: (slug: string) => void\n onClose: () => void\n /** The address is already listed, and they chose to look at that card. */\n onOpenCard?: (slug: string) => void\n}\n\n/** A field's error, next to it; the form points at the first one on submit. */\nfunction FieldError({ id, children }: { id: string; children: string }) {\n return (\n <p\n id={id}\n role=\"alert\"\n className=\"flex items-center gap-1.5 text-[12.5px] font-bold text-destructive\"\n >\n <AlertCircle aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n {children}\n </p>\n )\n}\n\n/**\n * Add a tool, or edit one: the same form. The address comes first; once it\n * sits still the backend reads the page, the title fills the name and a\n * screenshot preview shows. A host already listed is caught before anything\n * else is asked. Publish makes the tool live at once and puts it in the\n * review list.\n */\nexport function ToolFormDialog({\n mode,\n initial,\n prefillName,\n onDone,\n onClose,\n onOpenCard,\n}: ToolFormDialogProps) {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { user } = useAuth()\n const { persons, resources } = useAppCatalogContext()\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const formId = useId()\n const ids = {\n url: `${formId}-url`,\n name: `${formId}-name`,\n summary: `${formId}-summary`,\n owners: `${formId}-owners`,\n tags: `${formId}-tags`,\n description: `${formId}-description`,\n }\n const errorId = (field: string) => `${field}-error`\n\n const [url, setUrl] = useState(initial?.url ?? '')\n const [name, setName] = useState(initial?.name ?? prefillName ?? '')\n // The page title fills the name only until the visitor writes their own.\n const [nameTouched, setNameTouched] = useState(mode === 'edit')\n // The same, for the debounced read below, without restarting its timer.\n const nameTouchedRef = useRef(nameTouched)\n const [summary, setSummary] = useState(initial?.summary ?? '')\n const [descriptionMd, setDescriptionMd] = useState(\n initial?.descriptionMd ?? '',\n )\n const [owners, setOwners] = useState<PersonRef[]>(() => {\n if (initial) return initial.owners\n // The person adding it is the first owner, when the directory knows them.\n const email = user?.email?.toLowerCase()\n const me = email\n ? persons.find(\n (p) =>\n p.email?.toLowerCase() === email || p.slug.toLowerCase() === email,\n )\n : undefined\n return me ? [{ slug: me.slug, name: personName(me) }] : []\n })\n const [tags, setTags] = useState<CommunityTag[]>(initial?.tags ?? [])\n const [tab, setTab] = useState<'write' | 'preview'>('write')\n const [errors, setErrors] = useState<Partial<Record<Field, string>>>({})\n const [archiving, setArchiving] = useState(false)\n\n // The address as it was when the visitor stopped typing, and what reading it gave.\n const [checked, setChecked] = useState(initial?.url ?? '')\n const [preview, setPreview] = useState<{\n url: string\n data: ToolPreview | null\n } | null>(null)\n const [addAnywayFor, setAddAnywayFor] = useState<string | null>(null)\n\n const previewMutation = useMutation(\n trpc.communityTools.preview.mutationOptions(),\n )\n const { mutateAsync: readSite } = previewMutation\n useEffect(() => {\n const address = url.trim()\n // Set once the address changes again: a slower answer for this one must\n // not overwrite the newer address's preview or name.\n let stale = false\n const timer = setTimeout(() => {\n setChecked(address)\n if (!needsPreviewFor(address, mode, initial?.url)) return\n readSite({ url: address }).then(\n (data) => {\n if (stale) return\n setPreview({ url: address, data })\n if (data.title && !nameTouchedRef.current) setName(data.title)\n },\n () => {\n if (!stale) setPreview({ url: address, data: null })\n },\n )\n }, PREVIEW_DELAY_MS)\n return () => {\n stale = true\n clearTimeout(timer)\n }\n }, [url, mode, initial?.url, readSite])\n\n const address = url.trim()\n const validAddress = hostOf(address) !== null\n const showBadAddress = checked !== '' && checked === address && !validAddress\n const reading =\n needsPreviewFor(address, mode, initial?.url) &&\n (checked !== address || preview?.url !== address)\n const current = preview?.url === address ? preview.data : null\n const duplicate =\n current?.duplicate && current.duplicate.slug !== initial?.slug\n ? current.duplicate\n : null\n // An official catalog app on the same host outranks a community duplicate.\n const officialApp = current?.officialApp ?? null\n const blockedByDuplicate =\n (officialApp !== null || duplicate !== null) && addAnywayFor !== address\n const showDetails =\n mode === 'edit' ||\n (validAddress && !reading && !blockedByDuplicate) ||\n (!validAddress && name.trim() !== '' && !showBadAddress)\n\n const invalidate = () =>\n queryClient.invalidateQueries({\n queryKey: trpc.communityTools.pathKey(),\n })\n const add = useMutation(\n trpc.communityTools.add.mutationOptions({ onSuccess: invalidate }),\n )\n const edit = useMutation(\n trpc.communityTools.edit.mutationOptions({ onSuccess: invalidate }),\n )\n const archive = useMutation(\n trpc.communityTools.archive.mutationOptions({ onSuccess: invalidate }),\n )\n const save = mode === 'add' ? add : edit\n const busy = save.isPending || archive.isPending\n\n const urlRef = useRef<HTMLInputElement>(null)\n\n const submit = (e: React.FormEvent) => {\n e.preventDefault()\n // Publish stays disabled until the address is one; Enter in a field\n // cannot submit past a disabled button either.\n if (busy || !validAddress) return\n const found: Partial<Record<Field, string>> = {}\n if (!name.trim()) found.name = 'Give it the name colleagues call it.'\n if (owners.length === 0) {\n found.owners = 'Add at least one person to ask about it.'\n }\n setErrors(found)\n const first = (['name', 'owners'] as const).find((f) => found[f])\n if (first) {\n document.getElementById(ids[first])?.focus()\n return\n }\n const input = {\n url: address,\n name: name.trim(),\n summary: summary.trim(),\n descriptionMd,\n ownerSlugs: owners.flatMap((o) => (o.slug ? [o.slug] : [])),\n ownerNames: owners.flatMap((o) => (o.slug ? [] : [o.name])),\n tags,\n }\n if (mode === 'add') {\n add.mutate(input, { onSuccess: (tool) => onDone(tool.slug) })\n } else if (initial) {\n edit.mutate(\n { ...input, slug: initial.slug },\n { onSuccess: (tool) => onDone(tool.slug) },\n )\n }\n }\n\n const contentRef = useRef<HTMLDivElement>(null)\n // On the dismiss stack, so Escape closes this form and not the card under\n // it; while it saves, Escape does nothing at all.\n useDismissable(contentRef, () => {\n if (!busy) onClose()\n })\n\n const officialApps = resources.filter((r) => !r.parentSlug)\n const knownTopics = [\n ...new Set(\n (list.data ?? []).flatMap((t) =>\n t.tags.filter((g) => g.kind === 'topic').map((g) => g.value),\n ),\n ),\n ].sort()\n\n const title = mode === 'add' ? 'Add a tool' : 'Edit tool'\n const serverError = save.error ?? archive.error\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !busy) onClose()\n }}\n >\n <DialogContent\n ref={contentRef}\n data-testid={mode === 'add' ? 'add-tool-dialog' : 'edit-tool-dialog'}\n aria-describedby={undefined}\n showCloseButton={false}\n // Top-anchored: the form grows downward as the site is read, so\n // nothing above the caret moves.\n className=\"top-[6vh] max-h-[88vh] translate-y-0 gap-0 overflow-y-auto p-0 sm:max-w-[680px]\"\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n urlRef.current?.focus()\n }}\n // Typing is lost on a stray click; only Cancel, Close or Esc leave.\n onInteractOutside={(e) => e.preventDefault()}\n onEscapeKeyDown={(e) => {\n // An open suggestion list takes Escape for itself.\n const target = e.target as Element | null\n if (target?.closest('[aria-expanded=\"true\"]')) e.preventDefault()\n }}\n >\n <form onSubmit={submit} noValidate aria-busy={busy || undefined}>\n <div className=\"flex items-center justify-between px-5 pt-4\">\n <DialogTitle className=\"font-serif text-[19px] leading-tight font-semibold\">\n {title}\n </DialogTitle>\n <button\n type=\"button\"\n aria-label=\"Close\"\n disabled={busy}\n onClick={onClose}\n className=\"rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50\"\n >\n <X aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </div>\n\n <div className=\"flex flex-col gap-3.5 px-5 pt-4 pb-1.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.url} className={LABEL}>\n Site address\n </label>\n <div className={cn(FIELD_BOX, showBadAddress && FIELD_BAD)}>\n <input\n ref={urlRef}\n id={ids.url}\n type=\"url\"\n inputMode=\"url\"\n autoComplete=\"off\"\n placeholder=\"Paste the link to the tool\"\n value={url}\n disabled={busy}\n aria-invalid={showBadAddress || undefined}\n aria-describedby={\n showBadAddress ? errorId(ids.url) : `${ids.url}-hint`\n }\n onChange={(e) => setUrl(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent font-mono text-[13px] outline-none placeholder:font-sans placeholder:text-muted-foreground\"\n />\n {validAddress && reading && (\n <span\n data-testid=\"reading-site\"\n className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-muted-foreground\"\n >\n <Loader2\n aria-hidden=\"true\"\n className=\"size-3.5 animate-spin\"\n />\n Reading the site…\n </span>\n )}\n {validAddress &&\n !reading &&\n (current?.title || current?.screenshotDataUrl) && (\n <span className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-green-700 dark:text-green-400\">\n <CheckCircle2 aria-hidden=\"true\" className=\"size-3.5\" />\n Found\n </span>\n )}\n </div>\n {showBadAddress ? (\n <FieldError id={errorId(ids.url)}>\n That is not a web address. Paste the full link, starting with\n https://\n </FieldError>\n ) : (\n !validAddress &&\n !showDetails &&\n !blockedByDuplicate && (\n <p id={`${ids.url}-hint`} className={HINT}>\n Paste it first. The name and screenshot fill in from the\n site.\n </p>\n )\n )}\n </div>\n\n {validAddress && reading && <ReadingSkeleton />}\n\n {blockedByDuplicate && officialApp && (\n <div\n data-testid=\"official-app-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This is already in the catalog as {officialApp.name}.</b>\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <Link\n to=\"/app/$slug\"\n params={{ slug: officialApp.slug }}\n className={GHOST_BUTTON}\n >\n Open {officialApp.name}\n </Link>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {blockedByDuplicate && !officialApp && duplicate && (\n <div\n data-testid=\"duplicate-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This site is already here.</b> “{duplicate.name}” uses the\n same address.\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <button\n type=\"button\"\n className={GHOST_BUTTON}\n onClick={() => onOpenCard?.(duplicate.slug)}\n >\n Open that card\n </button>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {showDetails && (\n <>\n <div className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\">\n <div className=\"flex min-w-0 flex-col gap-3.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.name} className={LABEL}>\n Name\n </label>\n <div\n className={cn(\n FIELD_BOX,\n !nameTouched &&\n current?.title &&\n name === current.title &&\n 'bg-amber-50/70 dark:bg-amber-950/40',\n errors.name && FIELD_BAD,\n )}\n >\n <input\n id={ids.name}\n type=\"text\"\n maxLength={NAME_MAX}\n value={name}\n disabled={busy}\n aria-invalid={!!errors.name || undefined}\n aria-describedby={\n errors.name ? errorId(ids.name) : `${ids.name}-hint`\n }\n onChange={(e) => {\n setName(e.target.value)\n setNameTouched(true)\n nameTouchedRef.current = true\n setErrors((prev) => ({ ...prev, name: undefined }))\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n {errors.name ? (\n <FieldError id={errorId(ids.name)}>\n {errors.name}\n </FieldError>\n ) : (\n current?.title &&\n !nameTouched && (\n <p id={`${ids.name}-hint`} className={HINT}>\n From the page title. Change it if colleagues call it\n something else.\n </p>\n )\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.owners} className={LABEL}>\n Owners\n </label>\n <OwnerPicker\n id={ids.owners}\n persons={persons}\n value={owners}\n disabled={busy}\n invalid={!!errors.owners}\n describedBy={\n errors.owners\n ? errorId(ids.owners)\n : `${ids.owners}-hint`\n }\n onChange={(next) => {\n setOwners(next)\n setErrors((prev) => ({ ...prev, owners: undefined }))\n }}\n />\n {errors.owners ? (\n <FieldError id={errorId(ids.owners)}>\n {errors.owners}\n </FieldError>\n ) : (\n <p id={`${ids.owners}-hint`} className={HINT}>\n Who to ask about it. You are added by default.\n </p>\n )}\n </div>\n </div>\n <ShotPreview\n preview={current}\n initial={address === initial?.url ? initial : undefined}\n validAddress={validAddress}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.summary} className={LABEL}>\n Summary{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <div className={FIELD_BOX}>\n <input\n id={ids.summary}\n type=\"text\"\n maxLength={SUMMARY_MAX}\n value={summary}\n disabled={busy}\n aria-describedby={`${ids.summary}-hint`}\n onChange={(e) => setSummary(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <p id={`${ids.summary}-hint`} className={HINT}>\n One line under the name, in the list and on the card.\n </p>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.tags} className={LABEL}>\n Tags{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <TagPicker\n id={ids.tags}\n apps={officialApps}\n knownTopics={knownTopics}\n value={tags}\n disabled={busy}\n describedBy={\n errors.tags ? errorId(ids.tags) : `${ids.tags}-hint`\n }\n onChange={(next) => {\n setTags(next)\n setErrors((prev) => ({ ...prev, tags: undefined }))\n }}\n onTooLong={() =>\n setErrors((prev) => ({\n ...prev,\n tags: `A topic is at most ${TAG_VALUE_MAX} characters.`,\n }))\n }\n />\n {errors.tags ? (\n <FieldError id={errorId(ids.tags)}>\n {errors.tags}\n </FieldError>\n ) : (\n <p id={`${ids.tags}-hint`} className={HINT}>\n The app it is for, or a topic word. Press Enter to add a\n new topic.\n </p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.description} className={LABEL}>\n How to use\n </label>\n <div className=\"overflow-hidden rounded-[10px] border border-border bg-card\">\n <div\n role=\"tablist\"\n aria-label=\"Write or preview\"\n className=\"flex items-center gap-0.5 border-b border-border bg-muted p-1\"\n >\n {(['write', 'preview'] as const).map((t) => (\n <button\n key={t}\n type=\"button\"\n role=\"tab\"\n aria-selected={tab === t}\n onClick={() => setTab(t)}\n className={cn(\n 'rounded-[7px] px-3 py-1 text-[12.5px] font-bold text-muted-foreground',\n tab === t && 'bg-card text-foreground shadow-sm',\n )}\n >\n {t === 'write' ? 'Write' : 'Preview'}\n </button>\n ))}\n <span className=\"ml-auto pr-2 text-[11.5px] text-muted-foreground\">\n Markdown\n </span>\n </div>\n {/* Kept mounted while previewing, so the label and its draft stay. */}\n <textarea\n id={ids.description}\n rows={6}\n maxLength={DESCRIPTION_MAX}\n value={descriptionMd}\n disabled={busy}\n hidden={tab !== 'write'}\n aria-describedby={`${ids.description}-hint`}\n onChange={(e) => setDescriptionMd(e.target.value)}\n className=\"block w-full resize-y bg-transparent px-3 py-2.5 font-mono text-[12.5px] leading-relaxed outline-none\"\n />\n {tab === 'preview' && (\n <div\n data-testid=\"description-preview\"\n role=\"tabpanel\"\n className=\"prose prose-sm dark:prose-invert min-h-24 max-w-none px-3.5 py-2.5\"\n >\n {descriptionMd.trim() ? (\n <MarkdownText>{descriptionMd}</MarkdownText>\n ) : (\n <p className=\"text-muted-foreground\">\n Nothing written yet.\n </p>\n )}\n </div>\n )}\n </div>\n <p id={`${ids.description}-hint`} className={HINT}>\n Short steps work best. This is the text people read on the\n card.\n </p>\n </div>\n </>\n )}\n </div>\n\n {serverError && (\n <p\n role=\"alert\"\n className=\"mx-5 mt-2 rounded-[10px] bg-destructive/10 px-3 py-2 text-[13px] font-semibold text-destructive\"\n >\n {archive.error ? 'Could not archive it: ' : 'Could not save it: '}\n {serverError.message}\n </p>\n )}\n\n {archiving && initial ? (\n <div className=\"mt-2 border-t border-border px-5 pt-3 pb-4\">\n <ArchiveConfirm\n busy={archive.isPending}\n onCancel={() => setArchiving(false)}\n onArchive={(reason) =>\n archive.mutate(\n { slug: initial.slug, reason },\n { onSuccess: () => onDone(initial.slug) },\n )\n }\n />\n </div>\n ) : (\n <div className=\"mt-2 flex items-center justify-end gap-2.5 border-t border-border px-5 pt-3 pb-4\">\n {/* Already archived: nothing to archive, as on the card. */}\n {mode === 'edit' && initial?.lifecycle.state !== 'archived' && (\n <button\n type=\"button\"\n disabled={busy}\n onClick={() => setArchiving(true)}\n className=\"inline-flex items-center gap-1.5 text-[13px] font-bold text-destructive hover:underline disabled:opacity-50\"\n >\n <Archive aria-hidden=\"true\" className=\"size-3.5\" />\n Archive this tool\n </button>\n )}\n <span\n className={cn(\n 'text-[12.5px] text-muted-foreground',\n mode === 'add' ? 'mr-auto' : 'ml-auto',\n )}\n >\n {mode === 'add'\n ? 'Goes live now and joins the review list.'\n : 'Changes show on the card right away.'}\n </span>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onClose}\n className={GHOST_BUTTON}\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={!validAddress || reading || busy}\n aria-busy={save.isPending || undefined}\n className={PRIMARY_BUTTON}\n >\n {save.isPending && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {mode === 'add'\n ? save.isPending\n ? 'Publishing…'\n : 'Publish'\n : save.isPending\n ? 'Saving…'\n : 'Save changes'}\n </button>\n </div>\n )}\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction needsPreviewFor(\n address: string,\n mode: 'add' | 'edit',\n initialUrl: string | undefined,\n): boolean {\n return hostOf(address) !== null && (mode === 'add' || address !== initialUrl)\n}\n\n/** While the site is read: where the name, owners and picture will be. */\nfunction ReadingSkeleton() {\n return (\n <div\n aria-hidden=\"true\"\n className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\"\n >\n <div className=\"flex flex-col gap-3.5\">\n {['55%', '40%'].map((w, i) => (\n <div key={w} className=\"flex flex-col gap-1.5\">\n <span className={LABEL}>{i === 0 ? 'Name' : 'Owners'}</span>\n <span className={cn(FIELD_BOX, 'pointer-events-none')}>\n <i\n className=\"block h-3 animate-pulse rounded-md bg-muted\"\n style={{ width: w }}\n />\n </span>\n </div>\n ))}\n </div>\n <div className=\"mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 rounded-[10px] border border-border bg-muted text-xs font-semibold text-muted-foreground\">\n <Camera aria-hidden=\"true\" className=\"size-5 animate-pulse\" />\n Taking a screenshot…\n </div>\n </div>\n )\n}\n\n/** The picture the card will lead with, or why there will be none. */\nfunction ShotPreview({\n preview,\n initial,\n validAddress,\n}: {\n preview: ToolPreview | null\n /** The tool being edited, while its address is unchanged. */\n initial?: CommunityTool\n validAddress: boolean\n}) {\n const box =\n 'relative mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 overflow-hidden rounded-[10px] border border-border bg-muted px-3 text-center text-xs font-semibold text-muted-foreground'\n const caption =\n 'absolute bottom-1.5 left-1.5 inline-flex items-center gap-1 rounded-md bg-white/90 px-[7px] py-0.5 text-[11px] font-bold text-muted-foreground dark:bg-black/70'\n\n if (preview?.screenshotDataUrl) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={preview.screenshotDataUrl}\n alt=\"Screenshot preview of the site\"\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured just now\n </span>\n </div>\n )\n }\n if (initial?.screenshotId) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={screenshotUrl(initial.screenshotId, 640)}\n alt={`Screenshot of ${initial.name}`}\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n {initial.capturedAt && (\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured {formatCardDate(initial.capturedAt)}\n </span>\n )}\n </div>\n )\n }\n return (\n <div data-testid=\"shot-preview\" data-state=\"none\" className={box}>\n <ImageOff aria-hidden=\"true\" className=\"size-5\" />\n {preview && !preview.captureAllowed\n ? \"This site's address is outside the hosts we take screenshots of, so it will be listed without a picture.\"\n : validAddress\n ? 'No preview. The site may need a login, or it did not load.'\n : 'The screenshot shows here once the address is in.'}\n </div>\n )\n}\n\n/**\n * Archiving asks why, in one step: the reason is what colleagues read on the\n * card, and what the review list records.\n */\nexport function ArchiveConfirm({\n busy,\n onArchive,\n onCancel,\n}: {\n busy: boolean\n onArchive: (reason: string) => void\n onCancel: () => void\n}) {\n const id = useId()\n const inputRef = useRef<HTMLInputElement>(null)\n const [reason, setReason] = useState('')\n const [missing, setMissing] = useState(false)\n\n useEffect(() => {\n inputRef.current?.focus()\n }, [])\n\n const confirm = () => {\n if (!reason.trim()) {\n setMissing(true)\n inputRef.current?.focus()\n return\n }\n onArchive(reason.trim())\n }\n\n return (\n <div data-testid=\"archive-confirm\" className=\"flex flex-col gap-1.5\">\n <label htmlFor={id} className={LABEL}>\n Why archive it?\n </label>\n <div className=\"flex items-center gap-2.5\">\n <div className={cn(FIELD_BOX, 'flex-1', missing && FIELD_BAD)}>\n <input\n ref={inputRef}\n id={id}\n type=\"text\"\n maxLength={500}\n value={reason}\n disabled={busy}\n aria-invalid={missing || undefined}\n aria-describedby={missing ? `${id}-error` : `${id}-hint`}\n onChange={(e) => {\n setReason(e.target.value)\n setMissing(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onCancel}\n className={GHOST_BUTTON}\n >\n Keep it\n </button>\n <button\n type=\"button\"\n disabled={busy}\n aria-busy={busy || undefined}\n onClick={confirm}\n className={cn(PRIMARY_BUTTON, 'bg-destructive text-white')}\n >\n {busy && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {busy ? 'Archiving…' : 'Archive'}\n </button>\n </div>\n {missing ? (\n <FieldError id={`${id}-error`}>\n Say why, so colleagues know what happened to it.\n </FieldError>\n ) : (\n <p id={`${id}-hint`} className={HINT}>\n Colleagues read this on the card. It stays reachable by its link.\n </p>\n )}\n </div>\n )\n}\n"],"names":["_a","address"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAM,mBAAmB;AAEzB,MAAM,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 -38,6 +38,7 @@ export declare function useCommunityTools(): {
|
|
|
38
38
|
reviewed: boolean;
|
|
39
39
|
screenshotId: string | null;
|
|
40
40
|
faviconId: string | null;
|
|
41
|
+
serverUnreachable: boolean;
|
|
41
42
|
}[], import('@trpc/client').TRPCClientErrorLike<{
|
|
42
43
|
transformer: false;
|
|
43
44
|
errorShape: import('@trpc/server').TRPCDefaultErrorShape;
|
|
@@ -76,6 +77,7 @@ export declare function useCommunityTools(): {
|
|
|
76
77
|
reviewed: boolean;
|
|
77
78
|
screenshotId: string | null;
|
|
78
79
|
faviconId: string | null;
|
|
80
|
+
serverUnreachable: boolean;
|
|
79
81
|
}[], import('@trpc/client').TRPCClientErrorLike<{
|
|
80
82
|
transformer: false;
|
|
81
83
|
errorShape: import('@trpc/server').TRPCDefaultErrorShape;
|
|
@@ -5,7 +5,6 @@ import { useAppCatalogContext } from "../appCatalog/context/AppCatalogContext.js
|
|
|
5
5
|
import { useAuth } from "../auth/AuthContext.js";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
import "../../ui/button.js";
|
|
8
|
-
import "../auth/AuthModalContext.js";
|
|
9
8
|
import { withLike } from "./likedBy.js";
|
|
10
9
|
function useCommunityTools() {
|
|
11
10
|
const trpc = useTRPC();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCommunityTools.js","sources":["../../../../src/modules/communityTools/useCommunityTools.ts"],"sourcesContent":["import type { CommunityTool } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { useAuth } from '~/modules/auth'\nimport { withLike } from './likedBy'\n\n/**\n * Everything the community page reads, and the pin writes. Pins\n * belong to the signed-in user, so they are not asked for until there is one.\n */\nexport function useCommunityTools() {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { isAuthenticated, isLoading: isAuthLoading } = useAuth()\n const { resources } = useAppCatalogContext()\n\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const pins = useQuery(\n trpc.communityTools.pins.queryOptions(undefined, {\n enabled: isAuthenticated,\n }),\n )\n\n /** Display names of official apps by slug, for app tags. */\n const appNames = useMemo(\n () => Object.fromEntries(resources.map((r) => [r.slug, r.displayName])),\n [resources],\n )\n\n const pinsKey = trpc.communityTools.pins.queryKey()\n const refreshPins = () => queryClient.invalidateQueries({ queryKey: pinsKey })\n\n // The star and the shelf change at once; a failed save puts them back.\n const optimisticPins = (\n change: (old: CommunityTool[], slug: string) => CommunityTool[],\n ) => ({\n onMutate: async ({ slug }: { slug: string }) => {\n await queryClient.cancelQueries({ queryKey: pinsKey })\n const previous = queryClient.getQueryData<CommunityTool[]>(pinsKey)\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? change(old, slug) : old,\n )\n return { previous }\n },\n onError: (\n _error: unknown,\n _input: { slug: string },\n context: { previous?: CommunityTool[] } | undefined,\n ) => {\n queryClient.setQueryData(pinsKey, context?.previous)\n },\n // Not awaited: the pin is saved once the server answers; the refetch\n // behind it only confirms what the star already shows.\n onSettled: () => {\n void refreshPins()\n },\n })\n const pin = useMutation(\n trpc.communityTools.pin.mutationOptions(\n optimisticPins((old, slug) => {\n const tool = list.data?.find((t) => t.slug === slug)\n return tool && !old.some((t) => t.slug === slug) ? [...old, tool] : old\n }),\n ),\n )\n const unpin = useMutation(\n trpc.communityTools.unpin.mutationOptions(\n optimisticPins((old, slug) => old.filter((t) => t.slug !== slug)),\n ),\n )\n /** The tool whose pin is being saved, if any. */\n const pinBusySlug = pin.isPending\n ? pin.variables.slug\n : unpin.isPending\n ? unpin.variables.slug\n : undefined\n const reorder = useMutation(\n trpc.communityTools.reorderPins.mutationOptions({\n onMutate: ({ slugs }) => {\n // The tile moves at once; the server catches up behind it.\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? slugs.flatMap((s) => old.find((t) => t.slug === s) ?? []) : old,\n )\n },\n onSettled: refreshPins,\n }),\n )\n\n // My likes show at once, as an overlay on the tools as fetched. The feed\n // ranks from the fetched tools, so a like changes its own count and never\n // moves a row out from under the pointer. Settling marks the list stale\n // without refetching it: it re-ranks on the next refocus or remount.\n const [myLikes, setMyLikes] = useState<ReadonlyMap<string, boolean>>(\n () => new Map(),\n )\n const setMyLike = (slug: string, liked: boolean | undefined) =>\n setMyLikes((prev) => {\n const next = new Map(prev)\n if (liked === undefined) next.delete(slug)\n else next.set(slug, liked)\n return next\n })\n const likeOptions = (liked: boolean) => ({\n onMutate: ({ slug }: { slug: string }) => setMyLike(slug, liked),\n onError: (_error: unknown, { slug }: { slug: string }) =>\n setMyLike(slug, undefined),\n onSettled: () => {\n void queryClient.invalidateQueries({\n queryKey: trpc.communityTools.list.queryKey(),\n refetchType: 'none',\n })\n void refreshPins()\n },\n })\n const like = useMutation(\n trpc.communityTools.like.mutationOptions(likeOptions(true)),\n )\n const unlike = useMutation(\n trpc.communityTools.unlike.mutationOptions(likeOptions(false)),\n )\n /** The tool with my latest like or unlike, saved or still saving. */\n const withMyLike = useCallback(\n (tool: CommunityTool) => {\n const mine = myLikes.get(tool.slug)\n return mine === undefined ? tool : withLike(tool, mine)\n },\n [myLikes],\n )\n\n return {\n list,\n pins,\n appNames,\n isAuthenticated,\n isAuthLoading,\n pin,\n unpin,\n pinBusySlug,\n reorder,\n like,\n unlike,\n withMyLike,\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCommunityTools.js","sources":["../../../../src/modules/communityTools/useCommunityTools.ts"],"sourcesContent":["import type { CommunityTool } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { useAuth } from '~/modules/auth'\nimport { withLike } from './likedBy'\n\n/**\n * Everything the community page reads, and the pin writes. Pins\n * belong to the signed-in user, so they are not asked for until there is one.\n */\nexport function useCommunityTools() {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { isAuthenticated, isLoading: isAuthLoading } = useAuth()\n const { resources } = useAppCatalogContext()\n\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const pins = useQuery(\n trpc.communityTools.pins.queryOptions(undefined, {\n enabled: isAuthenticated,\n }),\n )\n\n /** Display names of official apps by slug, for app tags. */\n const appNames = useMemo(\n () => Object.fromEntries(resources.map((r) => [r.slug, r.displayName])),\n [resources],\n )\n\n const pinsKey = trpc.communityTools.pins.queryKey()\n const refreshPins = () => queryClient.invalidateQueries({ queryKey: pinsKey })\n\n // The star and the shelf change at once; a failed save puts them back.\n const optimisticPins = (\n change: (old: CommunityTool[], slug: string) => CommunityTool[],\n ) => ({\n onMutate: async ({ slug }: { slug: string }) => {\n await queryClient.cancelQueries({ queryKey: pinsKey })\n const previous = queryClient.getQueryData<CommunityTool[]>(pinsKey)\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? change(old, slug) : old,\n )\n return { previous }\n },\n onError: (\n _error: unknown,\n _input: { slug: string },\n context: { previous?: CommunityTool[] } | undefined,\n ) => {\n queryClient.setQueryData(pinsKey, context?.previous)\n },\n // Not awaited: the pin is saved once the server answers; the refetch\n // behind it only confirms what the star already shows.\n onSettled: () => {\n void refreshPins()\n },\n })\n const pin = useMutation(\n trpc.communityTools.pin.mutationOptions(\n optimisticPins((old, slug) => {\n const tool = list.data?.find((t) => t.slug === slug)\n return tool && !old.some((t) => t.slug === slug) ? [...old, tool] : old\n }),\n ),\n )\n const unpin = useMutation(\n trpc.communityTools.unpin.mutationOptions(\n optimisticPins((old, slug) => old.filter((t) => t.slug !== slug)),\n ),\n )\n /** The tool whose pin is being saved, if any. */\n const pinBusySlug = pin.isPending\n ? pin.variables.slug\n : unpin.isPending\n ? unpin.variables.slug\n : undefined\n const reorder = useMutation(\n trpc.communityTools.reorderPins.mutationOptions({\n onMutate: ({ slugs }) => {\n // The tile moves at once; the server catches up behind it.\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? slugs.flatMap((s) => old.find((t) => t.slug === s) ?? []) : old,\n )\n },\n onSettled: refreshPins,\n }),\n )\n\n // My likes show at once, as an overlay on the tools as fetched. The feed\n // ranks from the fetched tools, so a like changes its own count and never\n // moves a row out from under the pointer. Settling marks the list stale\n // without refetching it: it re-ranks on the next refocus or remount.\n const [myLikes, setMyLikes] = useState<ReadonlyMap<string, boolean>>(\n () => new Map(),\n )\n const setMyLike = (slug: string, liked: boolean | undefined) =>\n setMyLikes((prev) => {\n const next = new Map(prev)\n if (liked === undefined) next.delete(slug)\n else next.set(slug, liked)\n return next\n })\n const likeOptions = (liked: boolean) => ({\n onMutate: ({ slug }: { slug: string }) => setMyLike(slug, liked),\n onError: (_error: unknown, { slug }: { slug: string }) =>\n setMyLike(slug, undefined),\n onSettled: () => {\n void queryClient.invalidateQueries({\n queryKey: trpc.communityTools.list.queryKey(),\n refetchType: 'none',\n })\n void refreshPins()\n },\n })\n const like = useMutation(\n trpc.communityTools.like.mutationOptions(likeOptions(true)),\n )\n const unlike = useMutation(\n trpc.communityTools.unlike.mutationOptions(likeOptions(false)),\n )\n /** The tool with my latest like or unlike, saved or still saving. */\n const withMyLike = useCallback(\n (tool: CommunityTool) => {\n const mine = myLikes.get(tool.slug)\n return mine === undefined ? tool : withLike(tool, mine)\n },\n [myLikes],\n )\n\n return {\n list,\n pins,\n appNames,\n isAuthenticated,\n isAuthLoading,\n pin,\n unpin,\n pinBusySlug,\n reorder,\n like,\n unlike,\n withMyLike,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAYO,SAAS,oBAAoB;AAClC,QAAM,OAAO,QAAA;AACb,QAAM,cAAc,eAAA;AACpB,QAAM,EAAE,iBAAiB,WAAW,cAAA,IAAkB,QAAA;AACtD,QAAM,EAAE,UAAA,IAA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A;AAG/D,QAAM,aAAa;AAAA,IACjB,CAAC,SAAwB;AACvB,YAAM,OAAO,QAAQ,IAAI,KAAK,IAAI;AAClC,aAAO,SAAS,SAAY,OAAO,SAAS,MAAM,IAAI;AAAA,IACxD;AAAA,IACA,CAAC,OAAO;AAAA,EAAA;AAGV,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igstack/app-catalog-frontend-core",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.1",
|
|
4
4
|
"description": "Frontend core library for App Catalog",
|
|
5
5
|
"homepage": "https://github.com/lislon/app-catalog",
|
|
6
6
|
"repository": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"tailwindcss": "^4.1.7",
|
|
119
119
|
"tiptap-markdown": "^0.8.0",
|
|
120
120
|
"tslib": "^2.3.0",
|
|
121
|
-
"@igstack/app-catalog-shared-core": "6.12.
|
|
121
|
+
"@igstack/app-catalog-shared-core": "6.12.1"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@tailwindcss/vite": "^4.0.5",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"vite-plugin-static-copy": "^3.1.4",
|
|
147
147
|
"vite-plugin-svgr": "^4.2.0",
|
|
148
148
|
"vitest": "^4.1.2",
|
|
149
|
-
"@igstack/app-catalog-backend-core": "6.12.
|
|
149
|
+
"@igstack/app-catalog-backend-core": "6.12.1"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@tanstack/react-router": "1.170.41",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"vite": "^6.3.5",
|
|
157
157
|
"vite-plugin-svgr": "^4.2.0"
|
|
158
158
|
},
|
|
159
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "36f0e878473c215afa1406185b81bc30583c75db",
|
|
160
160
|
"scripts": {
|
|
161
161
|
"build": "vite build",
|
|
162
162
|
"build:lenient": "vite build --mode lenient",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts a click through to a tool's site. The page leaves in the same tab, which
|
|
3
|
+
* would cancel a tRPC call, so this posts with `keepalive` and never waits for it.
|
|
4
|
+
*/
|
|
5
|
+
export function recordSiteOpen(slug: string): void {
|
|
6
|
+
fetch(`${window.location.origin}/api/trpc/communityTools.recordSiteOpen`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
keepalive: true,
|
|
9
|
+
headers: { 'content-type': 'application/json' },
|
|
10
|
+
body: JSON.stringify({ slug }),
|
|
11
|
+
}).catch(() => {
|
|
12
|
+
// A lost count never stops anyone reaching the site.
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Goes to the tool's site in this tab, counting the click. */
|
|
17
|
+
export function openSite(tool: { slug: string; url: string }): void {
|
|
18
|
+
recordSiteOpen(tool.slug)
|
|
19
|
+
window.location.assign(tool.url)
|
|
20
|
+
}
|
|
@@ -14,3 +14,15 @@ export function timeAgo(iso: string, now: Date = new Date()): string {
|
|
|
14
14
|
const years = Math.floor(days / 365)
|
|
15
15
|
return years === 1 ? '1 year ago' : `${years} years ago`
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
/** The exact moment, for the tooltip of a timeAgo: "22 Oct 2026, 15:04". */
|
|
19
|
+
export function exactDate(iso: string): string {
|
|
20
|
+
return new Date(iso).toLocaleString('en-GB', {
|
|
21
|
+
day: 'numeric',
|
|
22
|
+
month: 'short',
|
|
23
|
+
year: 'numeric',
|
|
24
|
+
hour: '2-digit',
|
|
25
|
+
minute: '2-digit',
|
|
26
|
+
hour12: false,
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CommunityTool } from '@igstack/app-catalog-shared-core'
|
|
2
|
-
import { Camera,
|
|
2
|
+
import { Camera, ImageOff, Maximize2 } from 'lucide-react'
|
|
3
3
|
import { useState } from 'react'
|
|
4
4
|
import { ScreenshotGallery } from '~/modules/appCatalog/ui/components/ScreenshotGallery'
|
|
5
5
|
import { cn } from '~/lib/utils'
|
|
6
|
+
import { recordSiteOpen } from '../siteOpen'
|
|
6
7
|
import { screenshotUrl } from './FeedRow'
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -13,6 +14,10 @@ import { screenshotUrl } from './FeedRow'
|
|
|
13
14
|
const BOX =
|
|
14
15
|
'relative flex aspect-[16/10] max-h-[320px] w-full items-center justify-center overflow-hidden rounded-[14px] border border-border bg-muted shadow-sm'
|
|
15
16
|
|
|
17
|
+
/** The server's checks get no answer, so there is no fresh screenshot to show. */
|
|
18
|
+
const UNREACHABLE =
|
|
19
|
+
"Screenshot unavailable: the catalog's server can't reach this site."
|
|
20
|
+
|
|
16
21
|
export function formatCardDate(iso: string): string {
|
|
17
22
|
return new Date(iso).toLocaleDateString('en-GB', {
|
|
18
23
|
day: 'numeric',
|
|
@@ -58,7 +63,11 @@ export function CardScreenshot({
|
|
|
58
63
|
) : (
|
|
59
64
|
<>
|
|
60
65
|
<ImageOff aria-hidden="true" className="size-7" />
|
|
61
|
-
|
|
66
|
+
{tool.serverUnreachable ? (
|
|
67
|
+
<span data-testid="card-server-unreachable">{UNREACHABLE}</span>
|
|
68
|
+
) : (
|
|
69
|
+
'No screenshot. The site may need a login, or it did not load.'
|
|
70
|
+
)}
|
|
62
71
|
</>
|
|
63
72
|
)}
|
|
64
73
|
</div>
|
|
@@ -78,9 +87,8 @@ export function CardScreenshot({
|
|
|
78
87
|
>
|
|
79
88
|
<a
|
|
80
89
|
href={tool.url}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
aria-label={`Open ${tool.name} in a new tab`}
|
|
90
|
+
onClick={() => recordSiteOpen(tool.slug)}
|
|
91
|
+
aria-label={`Open ${tool.name}`}
|
|
84
92
|
data-testid="card-screenshot-link"
|
|
85
93
|
className="group/shot block size-full rounded-[14px] focus-visible:outline-2 focus-visible:-outline-offset-4 focus-visible:outline-ring"
|
|
86
94
|
>
|
|
@@ -90,9 +98,8 @@ export function CardScreenshot({
|
|
|
90
98
|
className="size-full object-cover object-left-top"
|
|
91
99
|
/>
|
|
92
100
|
<span className="absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-focus-visible/shot:bg-black/20 group-hover/shot:bg-black/20">
|
|
93
|
-
<span className="
|
|
101
|
+
<span className="rounded-lg bg-primary px-3.5 py-2 text-sm font-extrabold text-primary-foreground opacity-0 shadow-sm transition-opacity group-focus-visible/shot:opacity-100 group-hover/shot:opacity-100">
|
|
94
102
|
Open site
|
|
95
|
-
<ExternalLink aria-hidden="true" className="size-4" />
|
|
96
103
|
</span>
|
|
97
104
|
</span>
|
|
98
105
|
</a>
|
|
@@ -107,9 +114,14 @@ export function CardScreenshot({
|
|
|
107
114
|
<Maximize2 aria-hidden="true" className="size-4" />
|
|
108
115
|
</button>
|
|
109
116
|
</div>
|
|
110
|
-
{capturedAt && (
|
|
117
|
+
{(capturedAt || tool.serverUnreachable) && (
|
|
111
118
|
<figcaption className="mt-2 text-[12.5px] font-semibold text-muted-foreground">
|
|
112
|
-
Screenshot captured {formatCardDate(capturedAt)}
|
|
119
|
+
{capturedAt && `Screenshot captured ${formatCardDate(capturedAt)}`}
|
|
120
|
+
{tool.serverUnreachable && (
|
|
121
|
+
<span data-testid="card-server-unreachable" className="block">
|
|
122
|
+
{UNREACHABLE}
|
|
123
|
+
</span>
|
|
124
|
+
)}
|
|
113
125
|
</figcaption>
|
|
114
126
|
)}
|
|
115
127
|
<ScreenshotGallery
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { CommunityTool } from '@igstack/app-catalog-shared-core'
|
|
2
|
-
import {
|
|
2
|
+
import { Globe } from 'lucide-react'
|
|
3
3
|
import { cn } from '~/lib/utils'
|
|
4
|
+
import { recordSiteOpen } from '../siteOpen'
|
|
4
5
|
import { screenshotUrl } from './FeedRow'
|
|
5
6
|
import { LifecycleBadge, UnreviewedBadge } from './LifecycleBadge'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The card's door: favicon (a globe when the site has none), name, badges and
|
|
9
|
-
* address, all one link that opens the site
|
|
10
|
+
* address, all one link that opens the site.
|
|
10
11
|
*/
|
|
11
12
|
export function CardTitleBlock({ tool }: { tool: CommunityTool }) {
|
|
12
13
|
const archived = tool.lifecycle.state === 'archived'
|
|
13
14
|
return (
|
|
14
15
|
<a
|
|
15
16
|
href={tool.url}
|
|
16
|
-
|
|
17
|
-
rel="noopener noreferrer"
|
|
17
|
+
onClick={() => recordSiteOpen(tool.slug)}
|
|
18
18
|
data-testid="card-title-block"
|
|
19
19
|
className={cn(
|
|
20
20
|
'group/door inline-flex min-w-0 items-center gap-[15px] rounded-[14px] border border-border bg-primary/[0.025] px-[17px] py-[11px] transition-colors',
|
|
@@ -47,12 +47,7 @@ export function CardTitleBlock({ tool }: { tool: CommunityTool }) {
|
|
|
47
47
|
<span className="truncate font-mono text-[13px] text-muted-foreground">
|
|
48
48
|
{tool.host}
|
|
49
49
|
</span>
|
|
50
|
-
<span className="sr-only">(opens in a new tab)</span>
|
|
51
50
|
</span>
|
|
52
|
-
<ExternalLink
|
|
53
|
-
aria-hidden="true"
|
|
54
|
-
className="size-[18px] shrink-0 self-start text-muted-foreground group-hover/door:text-primary"
|
|
55
|
-
/>
|
|
56
51
|
</a>
|
|
57
52
|
)
|
|
58
53
|
}
|
|
@@ -29,6 +29,7 @@ import type { ToastMessage } from './Toast'
|
|
|
29
29
|
import { ToolCard } from './ToolCard'
|
|
30
30
|
import { ToolFormDialog } from './ToolFormDialog'
|
|
31
31
|
import { ToolSearch } from './ToolSearch'
|
|
32
|
+
import { openSite } from '../siteOpen'
|
|
32
33
|
|
|
33
34
|
const KBD =
|
|
34
35
|
'rounded-[5px] border border-b-2 border-border bg-card px-1.5 py-px text-[11px] font-semibold text-muted-foreground'
|
|
@@ -56,10 +57,6 @@ function optionIdOf(slug: string): string {
|
|
|
56
57
|
return `community-option-${slug}`
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function openSite(url: string) {
|
|
60
|
-
window.open(url, '_blank', 'noopener,noreferrer')
|
|
61
|
-
}
|
|
62
|
-
|
|
63
60
|
export function CommunityPage({
|
|
64
61
|
tag,
|
|
65
62
|
sort,
|
|
@@ -311,7 +308,7 @@ export function CommunityPage({
|
|
|
311
308
|
)
|
|
312
309
|
} else if (e.key === 'Enter' && current) {
|
|
313
310
|
e.preventDefault()
|
|
314
|
-
openSite(current.tool
|
|
311
|
+
openSite(current.tool)
|
|
315
312
|
} else if (
|
|
316
313
|
e.key === 'ArrowRight' &&
|
|
317
314
|
current &&
|