@igstack/app-catalog-frontend-core 6.13.1 → 6.15.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.
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.d.ts +4 -3
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js +73 -54
- package/dist/esm/modules/appCatalog/ui/pages/ServiceDesksPage.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.d.ts +9 -10
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js +39 -61
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.d.ts +3 -4
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js +9 -42
- package/dist/esm/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.js.map +1 -1
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.d.ts +13 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js +26 -0
- package/dist/esm/modules/appCatalog/ui/serviceDesks/searchServiceDesks.js.map +1 -1
- package/dist/esm/routeTree.gen.d.ts +34 -8
- package/dist/esm/routeTree.gen.js +13 -3
- package/dist/esm/routeTree.gen.js.map +1 -1
- package/dist/esm/routes/_layout/service-desks.$slug.d.ts +13 -0
- package/dist/esm/routes/_layout/service-desks._slug.js +14 -0
- package/dist/esm/routes/_layout/service-desks._slug.js.map +1 -0
- package/dist/esm/routes/_layout/service-desks.d.ts +0 -1
- package/dist/esm/routes/_layout/service-desks.js +5 -9
- package/dist/esm/routes/_layout/service-desks.js.map +1 -1
- package/dist/esm/types/uiSettings.d.ts +10 -0
- package/package.json +4 -4
- package/src/index.tsx +6 -1
- package/src/modules/appCatalog/ui/pages/ServiceDesksPage.tsx +121 -64
- package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskCard.tsx +40 -59
- package/src/modules/appCatalog/ui/serviceDesks/ServiceDeskDetail.tsx +17 -59
- package/src/modules/appCatalog/ui/serviceDesks/searchServiceDesks.ts +36 -0
- package/src/routeTree.gen.ts +35 -5
- package/src/routes/_layout/service-desks.$slug.tsx +17 -0
- package/src/routes/_layout/service-desks.tsx +3 -7
- package/src/types/uiSettings.ts +11 -0
|
@@ -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
|
|
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;"}
|
|
@@ -20,6 +20,14 @@ export interface AreasSettings {
|
|
|
20
20
|
/** Title of the merged first group. Defaults to "Day-to-day tools". */
|
|
21
21
|
dayToDayLabel?: string;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Presentation of the Service Desks view's area sections. A desk's area comes
|
|
25
|
+
* from its portal data, so the core knows none of them.
|
|
26
|
+
*/
|
|
27
|
+
export interface ServiceDesksSettings {
|
|
28
|
+
/** Icon per area name, as the portals spell it. Areas without one show the accent bar. */
|
|
29
|
+
areaIcons?: Record<string, AreaIcon>;
|
|
30
|
+
}
|
|
23
31
|
/**
|
|
24
32
|
* UI settings passed from the app entry point.
|
|
25
33
|
*/
|
|
@@ -40,6 +48,8 @@ export interface UiSettings {
|
|
|
40
48
|
chatChannelUrlTemplate?: string;
|
|
41
49
|
/** Area sections on the home view: icons and the day-to-day fold. */
|
|
42
50
|
areas?: AreasSettings;
|
|
51
|
+
/** The Service Desks view's area sections. */
|
|
52
|
+
serviceDesks?: ServiceDesksSettings;
|
|
43
53
|
/** PWA auto-update configuration (idle timeout, check interval, debug) */
|
|
44
54
|
pwaAutoUpdate?: PwaAutoUpdateOptions;
|
|
45
55
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igstack/app-catalog-frontend-core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.15.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.
|
|
121
|
+
"@igstack/app-catalog-shared-core": "6.15.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.
|
|
149
|
+
"@igstack/app-catalog-backend-core": "6.15.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": "
|
|
159
|
+
"gitHead": "dd5ee78e7ddfe4b760026bf9135f377adc733f2d",
|
|
160
160
|
"scripts": {
|
|
161
161
|
"build": "vite build",
|
|
162
162
|
"build:lenient": "vite build --mode lenient",
|
package/src/index.tsx
CHANGED
|
@@ -5,7 +5,12 @@ export type { AppPropsFactoryOptions } from './appPropsFactory.js'
|
|
|
5
5
|
export type { AcRouterContext, AcRouterInitParams } from './types/types'
|
|
6
6
|
export { App } from './App'
|
|
7
7
|
export type { AppProps } from './App'
|
|
8
|
-
export type {
|
|
8
|
+
export type {
|
|
9
|
+
AreaIcon,
|
|
10
|
+
AreasSettings,
|
|
11
|
+
ServiceDesksSettings,
|
|
12
|
+
UiSettings,
|
|
13
|
+
} from './types/uiSettings'
|
|
9
14
|
export {
|
|
10
15
|
DAY_TO_DAY_AREA_KEY,
|
|
11
16
|
DAY_TO_DAY_TAG,
|
|
@@ -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,
|
|
@@ -10,28 +10,40 @@ import {
|
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react'
|
|
12
12
|
import { useTRPC } from '~/api/infra/trpc'
|
|
13
|
+
import { useUiSettings } from '~/context/UiSettingsContext'
|
|
13
14
|
import { cn } from '~/lib/utils'
|
|
14
15
|
import { useAppCatalogContext } from '../../context/AppCatalogContext'
|
|
15
16
|
import { DeskCard, ServiceDeskCard } from '../serviceDesks/ServiceDeskCard'
|
|
16
17
|
import { ServiceDeskDetail } from '../serviceDesks/ServiceDeskDetail'
|
|
17
18
|
import {
|
|
19
|
+
allForms,
|
|
18
20
|
effectiveQuery,
|
|
21
|
+
findBySlug,
|
|
22
|
+
formSlug,
|
|
19
23
|
hasPortal,
|
|
20
24
|
searchServiceDesks,
|
|
21
25
|
} from '../serviceDesks/searchServiceDesks'
|
|
22
|
-
import type {
|
|
26
|
+
import type { AreaIcon } from '~/types/uiSettings'
|
|
27
|
+
import type {
|
|
28
|
+
FormResult,
|
|
29
|
+
PortalDesk,
|
|
30
|
+
ServiceDesk,
|
|
31
|
+
} from '../serviceDesks/searchServiceDesks'
|
|
23
32
|
|
|
24
33
|
/** Results rendered before "Show more": a one-letter query matches hundreds. */
|
|
25
34
|
const FIRST_PAGE = 50
|
|
26
35
|
|
|
27
|
-
/**
|
|
28
|
-
const
|
|
36
|
+
/** Forms whose desk has no area yet. */
|
|
37
|
+
const NO_AREA = 'Other forms'
|
|
38
|
+
/** Desks that offer no forms: chat bots, web forms, portals with nothing listed. */
|
|
39
|
+
const NO_FORMS = 'Other ways to ask'
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
42
|
* Service Desks view (#9, #273): one search over every service desk — its key,
|
|
32
|
-
* name, description, request forms and their dropdown options.
|
|
33
|
-
*
|
|
34
|
-
* With no search, every
|
|
43
|
+
* name, description, request forms and their dropdown options. Flat: every entry
|
|
44
|
+
* is a form, and its card is the route `/service-desks/<slug>`; there is no
|
|
45
|
+
* desk-level card. With no search, every form is listed by area, like the
|
|
46
|
+
* catalog home; desks that offer no forms are plain links at the end.
|
|
35
47
|
*
|
|
36
48
|
* The desks' portals come from `getServiceDesks`, kept out of the main catalog
|
|
37
49
|
* payload. Until it answers, the catalog's own (portal-less) desks are listed.
|
|
@@ -42,8 +54,9 @@ export function ServiceDesksPage() {
|
|
|
42
54
|
const fetched = useQuery(trpc.appCatalog.getServiceDesks.queryOptions())
|
|
43
55
|
const [search, setSearch] = useState('')
|
|
44
56
|
const [shown, setShown] = useState(FIRST_PAGE)
|
|
45
|
-
// The open card
|
|
46
|
-
const {
|
|
57
|
+
// The open card is the route, so Back closes it and a link reopens it.
|
|
58
|
+
const { slug: openSlug } = useParams({ strict: false })
|
|
59
|
+
const { desk: legacyDesk, form: legacyForm } = useSearch({ strict: false })
|
|
47
60
|
const navigate = useNavigate()
|
|
48
61
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
49
62
|
const scrollRef = useRef<HTMLDivElement>(null)
|
|
@@ -87,50 +100,48 @@ export function ServiceDesksPage() {
|
|
|
87
100
|
}
|
|
88
101
|
}, [portalDesks, deferredSearch])
|
|
89
102
|
|
|
90
|
-
// Desks found by name or description that
|
|
103
|
+
// Desks found by name or description that offer no forms: links only.
|
|
91
104
|
const plainHits = useMemo(() => {
|
|
92
105
|
if (!isSearching) return []
|
|
93
106
|
const q = query.trim().toLowerCase()
|
|
94
107
|
return desks.filter(
|
|
95
108
|
(d) =>
|
|
96
|
-
|
|
109
|
+
offersNoForms(d) &&
|
|
97
110
|
`${d.displayName} ${d.config.description ?? ''}`
|
|
98
111
|
.toLowerCase()
|
|
99
112
|
.includes(q),
|
|
100
113
|
)
|
|
101
114
|
}, [desks, isSearching, query])
|
|
102
115
|
|
|
103
|
-
const areas = useMemo(
|
|
116
|
+
const areas = useMemo(
|
|
117
|
+
() => groupByArea(desks, portalDesks),
|
|
118
|
+
[desks, portalDesks],
|
|
119
|
+
)
|
|
104
120
|
|
|
105
121
|
const onOpen = useCallback(
|
|
106
|
-
(slug: 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
|
-
}),
|
|
122
|
+
(slug: string) =>
|
|
123
|
+
void navigate({ to: '/service-desks/$slug', params: { slug } }),
|
|
116
124
|
[navigate],
|
|
117
125
|
)
|
|
118
|
-
const onClose = () =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
const onClose = () => void navigate({ to: '/service-desks' })
|
|
127
|
+
const opened = openSlug ? findBySlug(portalDesks, openSlug) : undefined
|
|
128
|
+
|
|
129
|
+
// `?desk=&form=` links from before a card had its own address.
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!legacyDesk || !fetched.data) return
|
|
132
|
+
const desk = portalDesks.find((d) => d.slug === legacyDesk)
|
|
133
|
+
const form = desk?.config.portal.requestTypes.find(
|
|
134
|
+
(f) => f.id === String(legacyForm),
|
|
135
|
+
)
|
|
136
|
+
void (desk && form
|
|
137
|
+
? navigate({
|
|
138
|
+
to: '/service-desks/$slug',
|
|
139
|
+
params: { slug: formSlug(desk, form) },
|
|
140
|
+
replace: true,
|
|
141
|
+
})
|
|
142
|
+
: navigate({ to: '/service-desks', replace: true }))
|
|
143
|
+
}, [legacyDesk, legacyForm, fetched.data, portalDesks, navigate])
|
|
144
|
+
|
|
134
145
|
const deskCount = new Set(results.map((r) => r.desk.slug)).size
|
|
135
146
|
|
|
136
147
|
const updateSearch = (value: string) => {
|
|
@@ -240,9 +251,9 @@ export function ServiceDesksPage() {
|
|
|
240
251
|
<h2 className="m-0 mb-3 px-1 font-serif text-[15px] font-semibold tracking-tight">
|
|
241
252
|
Other desks
|
|
242
253
|
</h2>
|
|
243
|
-
<ul className="
|
|
254
|
+
<ul className="flex flex-col gap-3">
|
|
244
255
|
{plainHits.map((d) => (
|
|
245
|
-
<DeskCard key={d.slug} desk={d}
|
|
256
|
+
<DeskCard key={d.slug} desk={d} />
|
|
246
257
|
))}
|
|
247
258
|
</ul>
|
|
248
259
|
</section>
|
|
@@ -254,8 +265,12 @@ export function ServiceDesksPage() {
|
|
|
254
265
|
</div>
|
|
255
266
|
</div>
|
|
256
267
|
|
|
257
|
-
{
|
|
258
|
-
<ServiceDeskDetail
|
|
268
|
+
{opened && (
|
|
269
|
+
<ServiceDeskDetail
|
|
270
|
+
desk={opened.desk}
|
|
271
|
+
form={opened.form}
|
|
272
|
+
onClose={onClose}
|
|
273
|
+
/>
|
|
259
274
|
)}
|
|
260
275
|
</div>
|
|
261
276
|
)
|
|
@@ -264,8 +279,13 @@ export function ServiceDesksPage() {
|
|
|
264
279
|
const areaId = (area: string) =>
|
|
265
280
|
`area-${area.toLowerCase().replace(/[^a-z0-9]+/g, '-')}`
|
|
266
281
|
|
|
282
|
+
/** One row of the area listing: a form, or a desk that is only a link. */
|
|
283
|
+
type Entry =
|
|
284
|
+
| { kind: 'form'; result: FormResult }
|
|
285
|
+
| { kind: 'link'; desk: ServiceDesk }
|
|
286
|
+
|
|
267
287
|
/**
|
|
268
|
-
* Every
|
|
288
|
+
* Every form by area, with a contents list beside it on wide screens. The list
|
|
269
289
|
* scrolls the page to an area and marks the one being read.
|
|
270
290
|
*/
|
|
271
291
|
function AreaBrowse({
|
|
@@ -273,10 +293,11 @@ function AreaBrowse({
|
|
|
273
293
|
onOpen,
|
|
274
294
|
scrollRef,
|
|
275
295
|
}: {
|
|
276
|
-
areas: [string,
|
|
296
|
+
areas: [string, Entry[]][]
|
|
277
297
|
onOpen: (slug: string) => void
|
|
278
298
|
scrollRef: React.RefObject<HTMLDivElement | null>
|
|
279
299
|
}) {
|
|
300
|
+
const icons = useUiSettings().serviceDesks?.areaIcons
|
|
280
301
|
const [current, setCurrent] = useState(areas[0]?.[0])
|
|
281
302
|
useEffect(() => {
|
|
282
303
|
const root = scrollRef.current
|
|
@@ -319,23 +340,28 @@ function AreaBrowse({
|
|
|
319
340
|
className="mt-11 first:mt-2"
|
|
320
341
|
>
|
|
321
342
|
<div className="mb-4 flex items-center gap-2.5">
|
|
322
|
-
<
|
|
343
|
+
<AreaMark Icon={icons?.[area]} />
|
|
323
344
|
<h2 className="m-0 font-serif text-[27px] font-semibold leading-tight tracking-tight">
|
|
324
345
|
{area}
|
|
325
346
|
</h2>
|
|
326
347
|
<span className="text-[13px] text-muted-foreground">
|
|
327
|
-
{list
|
|
348
|
+
{countLabel(list)}
|
|
328
349
|
</span>
|
|
329
350
|
</div>
|
|
330
|
-
<ul className="
|
|
331
|
-
{list.map((
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
351
|
+
<ul className="flex flex-col gap-3">
|
|
352
|
+
{list.map((e) =>
|
|
353
|
+
e.kind === 'form' ? (
|
|
354
|
+
<ServiceDeskCard
|
|
355
|
+
key={`${e.result.desk.slug}:${e.result.form.id}`}
|
|
356
|
+
result={e.result}
|
|
357
|
+
query=""
|
|
358
|
+
onOpen={onOpen}
|
|
359
|
+
showArea={false}
|
|
360
|
+
/>
|
|
361
|
+
) : (
|
|
362
|
+
<DeskCard key={e.desk.slug} desk={e.desk} />
|
|
363
|
+
),
|
|
364
|
+
)}
|
|
339
365
|
</ul>
|
|
340
366
|
</section>
|
|
341
367
|
))}
|
|
@@ -387,16 +413,47 @@ function AreaBrowse({
|
|
|
387
413
|
}
|
|
388
414
|
|
|
389
415
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
416
|
+
* The deployment's icon for an area, as on the catalog home; the accent bar
|
|
417
|
+
* when it has none. Decorative: the heading beside it carries the name.
|
|
418
|
+
*/
|
|
419
|
+
function AreaMark({ Icon }: { Icon?: AreaIcon }) {
|
|
420
|
+
return Icon ? (
|
|
421
|
+
<Icon size={26} strokeWidth={1.75} className="shrink-0 text-primary" />
|
|
422
|
+
) : (
|
|
423
|
+
<div className="h-[3px] w-11 shrink-0 rounded-full bg-primary" />
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const offersNoForms = (d: ServiceDesk) =>
|
|
428
|
+
!hasPortal(d) || d.config.portal.requestTypes.length === 0
|
|
429
|
+
|
|
430
|
+
const countLabel = (list: Entry[]) => {
|
|
431
|
+
const n = list.length
|
|
432
|
+
return list[0]?.kind === 'link'
|
|
433
|
+
? `${n} ${n === 1 ? 'desk' : 'desks'}`
|
|
434
|
+
: `${n} ${n === 1 ? 'form' : 'forms'}`
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Forms by their desk's area, areas A to Z, then desk and form A to Z inside
|
|
439
|
+
* one. Forms of a desk with no area come next to last; desks that offer no
|
|
440
|
+
* forms come last, as links.
|
|
392
441
|
*/
|
|
393
|
-
function groupByArea(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
442
|
+
function groupByArea(
|
|
443
|
+
desks: ServiceDesk[],
|
|
444
|
+
portalDesks: PortalDesk[],
|
|
445
|
+
): [string, Entry[]][] {
|
|
446
|
+
const byArea = new Map<string, Entry[]>()
|
|
447
|
+
const add = (area: string, e: Entry) =>
|
|
448
|
+
byArea.set(area, [...(byArea.get(area) ?? []), e])
|
|
449
|
+
for (const result of allForms(portalDesks)) {
|
|
450
|
+
add(result.desk.config.portal.area || NO_AREA, { kind: 'form', result })
|
|
451
|
+
}
|
|
452
|
+
for (const desk of desks.filter(offersNoForms)) {
|
|
453
|
+
add(NO_FORMS, { kind: 'link', desk })
|
|
398
454
|
}
|
|
399
|
-
|
|
400
|
-
|
|
455
|
+
const rank = (a: string) => (a === NO_FORMS ? 2 : a === NO_AREA ? 1 : 0)
|
|
456
|
+
return [...byArea.entries()].sort(
|
|
457
|
+
([a], [b]) => rank(a) - rank(b) || a.localeCompare(b),
|
|
401
458
|
)
|
|
402
459
|
}
|
|
@@ -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
|
|
16
|
-
* the portal, so a stray click never leaves the
|
|
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: (
|
|
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
|
|
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
|
-
<
|
|
51
|
+
<h3 className="text-[17px] font-semibold leading-snug">
|
|
48
52
|
<Marked text={form.name} query={query} />
|
|
49
|
-
</
|
|
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
|
|
93
|
-
* the
|
|
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
|
|
109
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
|
|
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
|
-
|
|
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
|
})
|