@igstack/app-catalog-frontend-core 6.13.0 → 6.14.0

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.
Files changed (29) hide show
  1. package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.d.ts +4 -3
  2. package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js +63 -49
  3. package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js.map +1 -1
  4. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.d.ts +9 -10
  5. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js +39 -61
  6. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js.map +1 -1
  7. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.d.ts +3 -4
  8. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js +9 -42
  9. package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js.map +1 -1
  10. package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.d.ts +13 -0
  11. package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js +26 -0
  12. package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js.map +1 -1
  13. package/dist/esm/routeTree.gen.d.ts +34 -8
  14. package/dist/esm/routeTree.gen.js +13 -3
  15. package/dist/esm/routeTree.gen.js.map +1 -1
  16. package/dist/esm/routes/_layout/service-desks.$slug.d.ts +13 -0
  17. package/dist/esm/routes/_layout/service-desks._slug.js +14 -0
  18. package/dist/esm/routes/_layout/service-desks._slug.js.map +1 -0
  19. package/dist/esm/routes/_layout/service-desks.d.ts +0 -1
  20. package/dist/esm/routes/_layout/service-desks.js +5 -9
  21. package/dist/esm/routes/_layout/service-desks.js.map +1 -1
  22. package/package.json +4 -4
  23. package/src/modules/appCatalog/ui/pages/ServiceDesksPage.tsx +103 -61
  24. package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.tsx +40 -59
  25. package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.tsx +17 -59
  26. package/src/modules/appCatalog/ui/serviceDesks/searchServiceDesks.ts +36 -0
  27. package/src/routeTree.gen.ts +35 -5
  28. package/src/routes/_layout/service-desks.$slug.tsx +17 -0
  29. package/src/routes/_layout/service-desks.tsx +3 -7
@@ -1 +1 @@
1
- {"version":3,"file":"service-desks.js","sources":["../../../../src/routes/_layout/service-desks.tsx"],"sourcesContent":["import { createFileRoute, stripSearchParams } from '@tanstack/react-router'\nimport { z } from 'zod'\nimport { AppCatalogLayout } from '~/modules/appCatalog/ui/layout/AppCatalogLayout'\nimport { ServiceDesksPage } from '~/modules/appCatalog/ui/pages/ServiceDesksPage'\n\n// #27: `q` kept declared for legacy links but stripped from the URL (search\n// text lives in sessionStorage now).\nconst searchSchema = z.object({\n q: z.string().optional(),\n /** The desk whose card is open (its approval-method slug). */\n desk: z.string().optional(),\n /**\n * The form the card was opened on, when it came from a search result. A\n * number when the id is all digits: the router writes a digit-only string\n * as `\"69\"`, quotes and all, and a hand-typed `form=69` reads back as one.\n */\n form: z.union([z.number(), z.string()]).optional(),\n /** The card's tab, owned by DetailTabs. */\n tab: z.string().optional(),\n})\n\nexport const Route = createFileRoute('/_layout/service-desks')({\n component: RouteComponent,\n validateSearch: searchSchema,\n search: { middlewares: [stripSearchParams(['q'])] },\n})\n\nfunction RouteComponent() {\n const { queryClient, trpcClient } = Route.useRouteContext()\n\n return (\n <AppCatalogLayout queryClient={queryClient} trpcClient={trpcClient}>\n <ServiceDesksPage />\n </AppCatalogLayout>\n )\n}\n"],"names":["z.object","z.string","z.union","z.number"],"mappings":";;;;;AAOA,MAAM,eAAeA,OAAS;AAAA,EAC5B,GAAGC,OAAE,EAAS,SAAA;AAAA;AAAA,EAEd,MAAMA,OAAE,EAAS,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjB,MAAMC,MAAQ,CAACC,OAAE,GAAUF,OAAE,CAAQ,CAAC,EAAE,SAAA;AAAA;AAAA,EAExC,KAAKA,OAAE,EAAS,SAAA;AAClB,CAAC;AAEM,MAAM,QAAQ,gBAAgB,wBAAwB,EAAE;AAAA,EAC7D,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAA;AAClD,CAAC;AAED,SAAS,iBAAiB;AACxB,QAAM,EAAE,aAAa,eAAe,MAAM,gBAAA;AAE1C,6BACG,kBAAA,EAAiB,aAA0B,YAC1C,UAAA,oBAAC,oBAAiB,GACpB;AAEJ;"}
1
+ {"version":3,"file":"service-desks.js","sources":["../../../../src/routes/_layout/service-desks.tsx"],"sourcesContent":["import { createFileRoute, stripSearchParams } from '@tanstack/react-router'\nimport { z } from 'zod'\nimport { AppCatalogLayout } from '~/modules/appCatalog/ui/layout/AppCatalogLayout'\nimport { ServiceDesksPage } from '~/modules/appCatalog/ui/pages/ServiceDesksPage'\n\n// #27: `q` kept declared for legacy links but stripped from the URL (search\n// text lives in sessionStorage now).\nconst searchSchema = z.object({\n q: z.string().optional(),\n /**\n * Legacy card address, `?desk=<method slug>&form=<id>`, shipped briefly before\n * cards moved to `/service-desks/<slug>`. Read once and redirected.\n */\n desk: z.string().optional(),\n form: z.union([z.number(), z.string()]).optional(),\n})\n\nexport const Route = createFileRoute('/_layout/service-desks')({\n component: RouteComponent,\n validateSearch: searchSchema,\n search: { middlewares: [stripSearchParams(['q'])] },\n})\n\nfunction RouteComponent() {\n const { queryClient, trpcClient } = Route.useRouteContext()\n\n return (\n <AppCatalogLayout queryClient={queryClient} trpcClient={trpcClient}>\n <ServiceDesksPage />\n </AppCatalogLayout>\n )\n}\n"],"names":["z.object","z.string","z.union","z.number"],"mappings":";;;;;AAOA,MAAM,eAAeA,OAAS;AAAA,EAC5B,GAAGC,OAAE,EAAS,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKd,MAAMA,OAAE,EAAS,SAAA;AAAA,EACjB,MAAMC,MAAQ,CAACC,OAAE,GAAUF,OAAE,CAAQ,CAAC,EAAE,SAAA;AAC1C,CAAC;AAEM,MAAM,QAAQ,gBAAgB,wBAAwB,EAAE;AAAA,EAC7D,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB,QAAQ,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAA;AAClD,CAAC;AAED,SAAS,iBAAiB;AACxB,QAAM,EAAE,aAAa,eAAe,MAAM,gBAAA;AAE1C,6BACG,kBAAA,EAAiB,aAA0B,YAC1C,UAAA,oBAAC,oBAAiB,GACpB;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igstack/app-catalog-frontend-core",
3
- "version": "6.13.0",
3
+ "version": "6.14.0",
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.13.0"
121
+ "@igstack/app-catalog-shared-core": "6.14.0"
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.13.0"
149
+ "@igstack/app-catalog-backend-core": "6.14.0"
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": "41778e087976cc63f03b3e341a4433e16c69433b",
159
+ "gitHead": "809bf7a7b47973a5584f6c2b8d4eafeb7c8f4187",
160
160
  "scripts": {
161
161
  "build": "vite build",
162
162
  "build:lenient": "vite build --mode lenient",
@@ -1,5 +1,5 @@
1
1
  import { useQuery } from '@tanstack/react-query'
2
- import { useNavigate, useSearch } from '@tanstack/react-router'
2
+ import { useNavigate, useParams, useSearch } from '@tanstack/react-router'
3
3
  import { Search, X } from 'lucide-react'
4
4
  import {
5
5
  useCallback,
@@ -15,23 +15,33 @@ import { useAppCatalogContext } from '../../context/AppCatalogContext'
15
15
  import { DeskCard, ServiceDeskCard } from '../serviceDesks/ServiceDeskCard'
16
16
  import { ServiceDeskDetail } from '../serviceDesks/ServiceDeskDetail'
17
17
  import {
18
+ allForms,
18
19
  effectiveQuery,
20
+ findBySlug,
21
+ formSlug,
19
22
  hasPortal,
20
23
  searchServiceDesks,
21
24
  } from '../serviceDesks/searchServiceDesks'
22
- import type { ServiceDesk } from '../serviceDesks/searchServiceDesks'
25
+ import type {
26
+ FormResult,
27
+ PortalDesk,
28
+ ServiceDesk,
29
+ } from '../serviceDesks/searchServiceDesks'
23
30
 
24
31
  /** Results rendered before "Show more": a one-letter query matches hundreds. */
25
32
  const FIRST_PAGE = 50
26
33
 
27
- /** Where desks with no area, or no portal at all, are listed. */
28
- const OTHER_AREA = 'Other ways to ask'
34
+ /** Forms whose desk has no area yet. */
35
+ const NO_AREA = 'Other forms'
36
+ /** Desks that offer no forms: chat bots, web forms, portals with nothing listed. */
37
+ const NO_FORMS = 'Other ways to ask'
29
38
 
30
39
  /**
31
40
  * Service Desks view (#9, #273): one search over every service desk — its key,
32
- * name, description, request forms and their dropdown options. A result is a
33
- * form; the card opens the desk's details, the form's address opens the portal.
34
- * With no search, every desk is listed by area, like the catalog's own home.
41
+ * name, description, request forms and their dropdown options. Flat: every entry
42
+ * is a form, and its card is the route `/service-desks/<slug>`; there is no
43
+ * desk-level card. With no search, every form is listed by area, like the
44
+ * catalog home; desks that offer no forms are plain links at the end.
35
45
  *
36
46
  * The desks' portals come from `getServiceDesks`, kept out of the main catalog
37
47
  * payload. Until it answers, the catalog's own (portal-less) desks are listed.
@@ -42,8 +52,9 @@ export function ServiceDesksPage() {
42
52
  const fetched = useQuery(trpc.appCatalog.getServiceDesks.queryOptions())
43
53
  const [search, setSearch] = useState('')
44
54
  const [shown, setShown] = useState(FIRST_PAGE)
45
- // The open card lives in the URL, so Back closes it and a link reopens it.
46
- const { desk: openSlug, form: openFormId } = useSearch({ strict: false })
55
+ // The open card is the route, so Back closes it and a link reopens it.
56
+ const { slug: openSlug } = useParams({ strict: false })
57
+ const { desk: legacyDesk, form: legacyForm } = useSearch({ strict: false })
47
58
  const navigate = useNavigate()
48
59
  const inputRef = useRef<HTMLInputElement>(null)
49
60
  const scrollRef = useRef<HTMLDivElement>(null)
@@ -87,50 +98,48 @@ export function ServiceDesksPage() {
87
98
  }
88
99
  }, [portalDesks, deferredSearch])
89
100
 
90
- // Desks found by name or description that publish no forms: links only.
101
+ // Desks found by name or description that offer no forms: links only.
91
102
  const plainHits = useMemo(() => {
92
103
  if (!isSearching) return []
93
104
  const q = query.trim().toLowerCase()
94
105
  return desks.filter(
95
106
  (d) =>
96
- !hasPortal(d) &&
107
+ offersNoForms(d) &&
97
108
  `${d.displayName} ${d.config.description ?? ''}`
98
109
  .toLowerCase()
99
110
  .includes(q),
100
111
  )
101
112
  }, [desks, isSearching, query])
102
113
 
103
- const areas = useMemo(() => groupByArea(desks), [desks])
114
+ const areas = useMemo(
115
+ () => groupByArea(desks, portalDesks),
116
+ [desks, portalDesks],
117
+ )
104
118
 
105
119
  const onOpen = useCallback(
106
- (slug: string, formId?: string) =>
107
- void navigate({
108
- to: '/service-desks',
109
- search: (prev) => ({
110
- ...prev,
111
- desk: slug,
112
- form: formId && /^\d+$/.test(formId) ? Number(formId) : formId,
113
- tab: undefined,
114
- }),
115
- }),
120
+ (slug: string) =>
121
+ void navigate({ to: '/service-desks/$slug', params: { slug } }),
116
122
  [navigate],
117
123
  )
118
- const onClose = () =>
119
- void navigate({
120
- to: '/service-desks',
121
- search: (prev) => ({
122
- ...prev,
123
- desk: undefined,
124
- form: undefined,
125
- tab: undefined,
126
- }),
127
- })
128
- const openDesk = openSlug
129
- ? portalDesks.find((d) => d.slug === openSlug)
130
- : undefined
131
- const openForm = openDesk?.config.portal.requestTypes.find(
132
- (f) => openFormId !== undefined && f.id === String(openFormId),
133
- )
124
+ const onClose = () => void navigate({ to: '/service-desks' })
125
+ const opened = openSlug ? findBySlug(portalDesks, openSlug) : undefined
126
+
127
+ // `?desk=&form=` links from before a card had its own address.
128
+ useEffect(() => {
129
+ if (!legacyDesk || !fetched.data) return
130
+ const desk = portalDesks.find((d) => d.slug === legacyDesk)
131
+ const form = desk?.config.portal.requestTypes.find(
132
+ (f) => f.id === String(legacyForm),
133
+ )
134
+ void (desk && form
135
+ ? navigate({
136
+ to: '/service-desks/$slug',
137
+ params: { slug: formSlug(desk, form) },
138
+ replace: true,
139
+ })
140
+ : navigate({ to: '/service-desks', replace: true }))
141
+ }, [legacyDesk, legacyForm, fetched.data, portalDesks, navigate])
142
+
134
143
  const deskCount = new Set(results.map((r) => r.desk.slug)).size
135
144
 
136
145
  const updateSearch = (value: string) => {
@@ -242,7 +251,7 @@ export function ServiceDesksPage() {
242
251
  </h2>
243
252
  <ul className="grid grid-cols-1 gap-3 md:grid-cols-2">
244
253
  {plainHits.map((d) => (
245
- <DeskCard key={d.slug} desk={d} onOpen={onOpen} />
254
+ <DeskCard key={d.slug} desk={d} />
246
255
  ))}
247
256
  </ul>
248
257
  </section>
@@ -254,8 +263,12 @@ export function ServiceDesksPage() {
254
263
  </div>
255
264
  </div>
256
265
 
257
- {openDesk && (
258
- <ServiceDeskDetail desk={openDesk} form={openForm} onClose={onClose} />
266
+ {opened && (
267
+ <ServiceDeskDetail
268
+ desk={opened.desk}
269
+ form={opened.form}
270
+ onClose={onClose}
271
+ />
259
272
  )}
260
273
  </div>
261
274
  )
@@ -264,8 +277,13 @@ export function ServiceDesksPage() {
264
277
  const areaId = (area: string) =>
265
278
  `area-${area.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`
266
279
 
280
+ /** One row of the area listing: a form, or a desk that is only a link. */
281
+ type Entry =
282
+ | { kind: 'form'; result: FormResult }
283
+ | { kind: 'link'; desk: ServiceDesk }
284
+
267
285
  /**
268
- * Every desk by area, with a contents list beside it on wide screens. The list
286
+ * Every form by area, with a contents list beside it on wide screens. The list
269
287
  * scrolls the page to an area and marks the one being read.
270
288
  */
271
289
  function AreaBrowse({
@@ -273,7 +291,7 @@ function AreaBrowse({
273
291
  onOpen,
274
292
  scrollRef,
275
293
  }: {
276
- areas: [string, ServiceDesk[]][]
294
+ areas: [string, Entry[]][]
277
295
  onOpen: (slug: string) => void
278
296
  scrollRef: React.RefObject<HTMLDivElement | null>
279
297
  }) {
@@ -324,18 +342,23 @@ function AreaBrowse({
324
342
  {area}
325
343
  </h2>
326
344
  <span className="text-[13px] text-muted-foreground">
327
- {list.length} {list.length === 1 ? 'desk' : 'desks'}
345
+ {countLabel(list)}
328
346
  </span>
329
347
  </div>
330
348
  <ul className="grid grid-cols-1 gap-3 md:grid-cols-2">
331
- {list.map((d) => (
332
- <DeskCard
333
- key={d.slug}
334
- desk={d}
335
- onOpen={onOpen}
336
- showArea={false}
337
- />
338
- ))}
349
+ {list.map((e) =>
350
+ e.kind === 'form' ? (
351
+ <ServiceDeskCard
352
+ key={`${e.result.desk.slug}:${e.result.form.id}`}
353
+ result={e.result}
354
+ query=""
355
+ onOpen={onOpen}
356
+ showArea={false}
357
+ />
358
+ ) : (
359
+ <DeskCard key={e.desk.slug} desk={e.desk} />
360
+ ),
361
+ )}
339
362
  </ul>
340
363
  </section>
341
364
  ))}
@@ -386,17 +409,36 @@ function AreaBrowse({
386
409
  )
387
410
  }
388
411
 
412
+ const offersNoForms = (d: ServiceDesk) =>
413
+ !hasPortal(d) || d.config.portal.requestTypes.length === 0
414
+
415
+ const countLabel = (list: Entry[]) => {
416
+ const n = list.length
417
+ return list[0]?.kind === 'link'
418
+ ? `${n} ${n === 1 ? 'desk' : 'desks'}`
419
+ : `${n} ${n === 1 ? 'form' : 'forms'}`
420
+ }
421
+
389
422
  /**
390
- * Desks by their portal's area, areas A to Z, desks A to Z inside one. Desks
391
- * with no area — chat bots, web forms, portals nobody has placed yet — go last.
423
+ * Forms by their desk's area, areas A to Z, then desk and form A to Z inside
424
+ * one. Forms of a desk with no area come next to last; desks that offer no
425
+ * forms come last, as links.
392
426
  */
393
- function groupByArea(desks: ServiceDesk[]): [string, ServiceDesk[]][] {
394
- const byArea = new Map<string, ServiceDesk[]>()
395
- for (const d of desks) {
396
- const area = (hasPortal(d) && d.config.portal.area) || OTHER_AREA
397
- byArea.set(area, [...(byArea.get(area) ?? []), d])
427
+ function groupByArea(
428
+ desks: ServiceDesk[],
429
+ portalDesks: PortalDesk[],
430
+ ): [string, Entry[]][] {
431
+ const byArea = new Map<string, Entry[]>()
432
+ const add = (area: string, e: Entry) =>
433
+ byArea.set(area, [...(byArea.get(area) ?? []), e])
434
+ for (const result of allForms(portalDesks)) {
435
+ add(result.desk.config.portal.area || NO_AREA, { kind: 'form', result })
436
+ }
437
+ for (const desk of desks.filter(offersNoForms)) {
438
+ add(NO_FORMS, { kind: 'link', desk })
398
439
  }
399
- return [...byArea.entries()].sort(([a], [b]) =>
400
- a === OTHER_AREA ? 1 : b === OTHER_AREA ? -1 : a.localeCompare(b),
440
+ const rank = (a: string) => (a === NO_FORMS ? 2 : a === NO_AREA ? 1 : 0)
441
+ return [...byArea.entries()].sort(
442
+ ([a], [b]) => rank(a) - rank(b) || a.localeCompare(b),
401
443
  )
402
444
  }
@@ -2,7 +2,7 @@ import { ExternalLink } from 'lucide-react'
2
2
  import { memo, useState } from 'react'
3
3
  import { displayUrl } from '~/modules/appCatalog/utils/displayUrl'
4
4
  import { Marked } from './Marked'
5
- import { hasPortal, liveOptions } from './searchServiceDesks'
5
+ import { formSlug, hasPortal, liveOptions } from './searchServiceDesks'
6
6
  import type { FieldMatch, FormResult, ServiceDesk } from './searchServiceDesks'
7
7
 
8
8
  /** Options shown per matched dropdown before "Show all". */
@@ -12,21 +12,25 @@ const OPTIONS_SHOWN = 8
12
12
  * One form in the results. Three styles only: the title in ink, everything
13
13
  * else muted, and the search marker as the single accent.
14
14
  *
15
- * The card opens the desk's details; the form's address is the only way out to
16
- * the portal, so a stray click never leaves the catalog.
15
+ * The card opens the form's own card (`/service-desks/<slug>`); the form's
16
+ * address is the only way out to the portal, so a stray click never leaves the
17
+ * catalog.
17
18
  */
18
19
  export const ServiceDeskCard = memo(function ResultCardView({
19
20
  result,
20
21
  query,
21
22
  onOpen,
23
+ showArea = true,
22
24
  }: {
23
25
  result: FormResult
24
26
  query: string
25
- /** Stable across renders, so an unchanged card skips re-rendering. */
26
- onOpen: (deskSlug: string, formId?: string) => void
27
+ /** Takes the form's slug. Stable across renders, so an unchanged card skips re-rendering. */
28
+ onOpen: (slug: string) => void
29
+ /** Off inside an area's own section, where the tag would repeat its heading. */
30
+ showArea?: boolean
27
31
  }) {
28
32
  const { desk, form, fieldMatches } = result
29
- const onOpenDetails = () => onOpen(desk.slug, form.id)
33
+ const onOpenDetails = () => onOpen(formSlug(desk, form))
30
34
  const portal = desk.config.portal
31
35
  return (
32
36
  <li
@@ -44,9 +48,9 @@ export const ServiceDeskCard = memo(function ResultCardView({
44
48
  }}
45
49
  className="cursor-pointer rounded-[var(--radius)] border border-border bg-card p-5 transition-colors hover:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
46
50
  >
47
- <h2 className="text-[17px] font-semibold leading-snug">
51
+ <h3 className="text-[17px] font-semibold leading-snug">
48
52
  <Marked text={form.name} query={query} />
49
- </h2>
53
+ </h3>
50
54
  <p className="mt-0.5 text-[13px] text-muted-foreground">
51
55
  <span className="font-semibold tracking-wide" title="Portal key">
52
56
  <Marked text={portal.key} query={query} />
@@ -78,53 +82,25 @@ export const ServiceDeskCard = memo(function ResultCardView({
78
82
  {displayUrl(form.url)}
79
83
  <ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
80
84
  </a>
81
- {portal.area && (
82
- <span className="whitespace-nowrap rounded-full bg-muted px-2 py-1 text-[11.5px] leading-none text-muted-foreground">
83
- {portal.area}
84
- </span>
85
- )}
85
+ {showArea && portal.area && <Tag>{portal.area}</Tag>}
86
86
  </div>
87
87
  </li>
88
88
  )
89
89
  })
90
90
 
91
91
  /**
92
- * A desk on the Service Desks home: the same anatomy as a result card, minus
93
- * the form and its fields. A desk with a portal opens its details; one without
94
- * (a chat bot, a web form) is only its link.
92
+ * A desk that offers no forms (a chat bot, a web form, a portal with nothing
93
+ * listed): the same anatomy as a form card, and only a link to the desk.
95
94
  */
96
95
  export const DeskCard = memo(function DeskCardView({
97
96
  desk,
98
- onOpen,
99
- showArea = true,
100
97
  }: {
101
98
  desk: ServiceDesk
102
- onOpen: (deskSlug: string) => void
103
- /** Off inside an area's own section, where the tag would repeat its heading. */
104
- showArea?: boolean
105
99
  }) {
106
100
  const portal = hasPortal(desk) ? desk.config.portal : undefined
107
101
  const url = desk.config.url
108
- const forms = portal?.requestTypes.length ?? 0
109
- const open = () =>
110
- portal
111
- ? onOpen(desk.slug)
112
- : url && window.open(url, '_blank', 'noopener,noreferrer')
113
- return (
114
- <li
115
- role="button"
116
- tabIndex={0}
117
- aria-label={
118
- portal ? `Details for ${desk.displayName}` : `Open ${desk.displayName}`
119
- }
120
- onClick={(e) => {
121
- if (!(e.target as HTMLElement).closest('a,button')) open()
122
- }}
123
- onKeyDown={(e) => {
124
- if (e.key === 'Enter' && e.target === e.currentTarget) open()
125
- }}
126
- className="flex cursor-pointer flex-col rounded-[var(--radius)] border border-border bg-card p-5 transition-colors hover:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
127
- >
102
+ const body = (
103
+ <>
128
104
  <h3
129
105
  className="text-[17px] font-semibold leading-snug"
130
106
  data-testid="service-desk-name"
@@ -144,25 +120,30 @@ export const DeskCard = memo(function DeskCardView({
144
120
  {desk.config.description}
145
121
  </p>
146
122
  )}
147
- <div className="mt-auto flex flex-wrap items-end justify-between gap-x-4 gap-y-2 pt-1">
148
- {url ? (
149
- <a
150
- href={url}
151
- target="_blank"
152
- rel="noopener noreferrer"
153
- className="inline-flex min-w-0 items-center gap-1 text-[13.5px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground hover:decoration-foreground"
154
- >
155
- <span className="truncate">{displayUrl(url)}</span>
156
- <ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
157
- </a>
158
- ) : (
159
- <span />
160
- )}
161
- <span className="flex flex-wrap justify-end gap-1">
162
- {forms > 0 && <Tag>{forms === 1 ? '1 form' : `${forms} forms`}</Tag>}
163
- {showArea && portal?.area && <Tag>{portal.area}</Tag>}
123
+ {url && (
124
+ <span className="mt-auto inline-flex min-w-0 items-center gap-1 pt-1 text-[13.5px] text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2">
125
+ <span className="truncate">{displayUrl(url)}</span>
126
+ <ExternalLink className="size-3.5 shrink-0" aria-hidden="true" />
164
127
  </span>
165
- </div>
128
+ )}
129
+ </>
130
+ )
131
+ const cls =
132
+ 'flex h-full flex-col rounded-[var(--radius)] border border-border bg-card p-5 transition-colors'
133
+ return (
134
+ <li>
135
+ {url ? (
136
+ <a
137
+ href={url}
138
+ target="_blank"
139
+ rel="noopener noreferrer"
140
+ className={`${cls} hover:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`}
141
+ >
142
+ {body}
143
+ </a>
144
+ ) : (
145
+ <div className={cls}>{body}</div>
146
+ )}
166
147
  </li>
167
148
  )
168
149
  })
@@ -16,9 +16,8 @@ import { liveOptions } from './searchServiceDesks'
16
16
  import type { PortalDesk } from './searchServiceDesks'
17
17
 
18
18
  /**
19
- * A desk's card, opened from a result (then `form` is the form clicked) or from
20
- * the desk list (then it covers every form). Overview reads top to bottom like a
21
- * short page: what the request is for, the one way into it, what it asks, and
19
+ * One form's card, at `/service-desks/<slug>`. Overview reads top to bottom like
20
+ * a short page: what the request is for, the one way into it, what it asks, and
22
21
  * what happens after. Behind this card says where the card comes from.
23
22
  *
24
23
  * One link only: the button. The header is the subject, not a second door.
@@ -29,7 +28,7 @@ export function ServiceDeskDetail({
29
28
  onClose,
30
29
  }: {
31
30
  desk: PortalDesk
32
- form?: ServiceRequestType
31
+ form: ServiceRequestType
33
32
  onClose: () => void
34
33
  }) {
35
34
  const portal = desk.config.portal
@@ -37,21 +36,21 @@ export function ServiceDeskDetail({
37
36
  const band = (
38
37
  <div className="pr-20">
39
38
  <h2 className="m-0 font-serif text-[28px] font-semibold leading-tight tracking-tight">
40
- {form?.name ?? desk.displayName}
39
+ {form.name}
41
40
  </h2>
42
41
  <p className="mt-1 text-[14px] text-muted-foreground">
43
42
  <span className="font-semibold tracking-wide" title="Portal key">
44
43
  {portal.key}
45
44
  </span>
46
- {form && <> · {desk.displayName}</>}
45
+ · {desk.displayName}
47
46
  </p>
48
47
  </div>
49
48
  )
50
49
 
51
50
  return (
52
51
  <DetailDialogShell
53
- label={`${form?.name ?? desk.displayName} details`}
54
- shownKey={`${desk.slug}:${form?.id ?? ''}`}
52
+ label={`${form.name} details`}
53
+ shownKey={`${desk.slug}:${form.id}`}
55
54
  maxWidthClass="max-w-[min(1000px,94vw)]"
56
55
  focusSelector="[data-primary-action]"
57
56
  onClose={onClose}
@@ -102,20 +101,19 @@ function Overview({
102
101
  form,
103
102
  }: {
104
103
  desk: PortalDesk
105
- form?: ServiceRequestType
104
+ form: ServiceRequestType
106
105
  }) {
107
106
  const portal = desk.config.portal
108
- const url = form?.url ?? desk.config.url
109
107
  return (
110
108
  <div className="flex max-w-[760px] flex-col gap-8 pt-1">
111
109
  <div>
112
- {form?.description && (
110
+ {form.description && (
113
111
  <p className="text-[17px] leading-[1.6]">{form.description}</p>
114
112
  )}
115
113
  {desk.config.description && (
116
114
  <p
117
115
  className={
118
- form?.description
116
+ form.description
119
117
  ? 'mt-2 text-[14px] text-muted-foreground'
120
118
  : 'text-[17px] leading-[1.6]'
121
119
  }
@@ -123,55 +121,15 @@ function Overview({
123
121
  {desk.config.description}
124
122
  </p>
125
123
  )}
126
- {url && (
127
- <div className="mt-5">
128
- <OpenButton
129
- url={url}
130
- label={form ? 'Open the form' : 'Open the portal'}
131
- />
132
- </div>
133
- )}
124
+ <div className="mt-5">
125
+ <OpenButton url={form.url} label="Open the form" />
126
+ </div>
134
127
  </div>
135
128
 
136
- {form ? (
137
- <div>
138
- <Heading>You will be asked for</Heading>
139
- <FieldList fields={form.fields} />
140
- </div>
141
- ) : (
142
- <div>
143
- <Heading>Forms on this portal</Heading>
144
- {portal.requestTypes.length ? (
145
- <ul className="flex flex-col gap-4">
146
- {portal.requestTypes.map((rt) => (
147
- <li key={rt.id}>
148
- <a
149
- href={rt.url}
150
- target="_blank"
151
- rel="noopener noreferrer"
152
- className="inline-flex items-center gap-1 text-[15px] font-medium underline decoration-muted-foreground/40 underline-offset-2 hover:decoration-foreground"
153
- >
154
- {rt.name}
155
- <ExternalLink
156
- className="size-3.5 text-muted-foreground"
157
- aria-hidden="true"
158
- />
159
- </a>
160
- {rt.description && (
161
- <p className="text-[14px] text-muted-foreground">
162
- {rt.description}
163
- </p>
164
- )}
165
- </li>
166
- ))}
167
- </ul>
168
- ) : (
169
- <p className="text-[14px] text-muted-foreground">
170
- This desk publishes no forms.
171
- </p>
172
- )}
173
- </div>
174
- )}
129
+ <div>
130
+ <Heading>You will be asked for</Heading>
131
+ <FieldList fields={form.fields} />
132
+ </div>
175
133
 
176
134
  <div>
177
135
  <Heading>After you file</Heading>
@@ -171,3 +171,39 @@ export function searchServiceDesks(
171
171
  .sort((a, b) => b.tier - a.tier || a.order - b.order)
172
172
  .map((r) => r.result)
173
173
  }
174
+
175
+ /**
176
+ * A form's address in the Service Desks view: the desk's key and the form's id,
177
+ * `/service-desks/help-42`. The id, not the name, so a renamed form keeps its
178
+ * links; the key, so the address still says which desk it belongs to.
179
+ */
180
+ export function formSlug(desk: PortalDesk, form: ServiceRequestType): string {
181
+ return `${desk.config.portal.key.toLowerCase()}-${form.id}`
182
+ }
183
+
184
+ /** The desk and form behind a `formSlug`, or undefined. */
185
+ export function findBySlug(
186
+ desks: PortalDesk[],
187
+ slug: string,
188
+ ): { desk: PortalDesk; form: ServiceRequestType } | undefined {
189
+ for (const desk of desks) {
190
+ const key = `${desk.config.portal.key.toLowerCase()}-`
191
+ if (!slug.startsWith(key)) continue
192
+ const form = desk.config.portal.requestTypes.find(
193
+ (f) => f.id === slug.slice(key.length),
194
+ )
195
+ if (form) return { desk, form }
196
+ }
197
+ return undefined
198
+ }
199
+
200
+ /** Every form of every desk, unmatched: the Service Desks view with no search. */
201
+ export function allForms(desks: PortalDesk[]): FormResult[] {
202
+ return desks.flatMap((desk) =>
203
+ desk.config.portal.requestTypes.map((form) => ({
204
+ desk,
205
+ form,
206
+ fieldMatches: [],
207
+ })),
208
+ )
209
+ }