@igstack/app-catalog-frontend-core 0.3.1-alpha-20260317200702 → 0.3.1-alpha-20260317225951
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/modules/appCatalog/ui/grid/AppCatalogGrid.js +126 -106
- package/dist/esm/modules/appCatalog/ui/grid/AppCatalogGrid.js.map +1 -1
- package/dist/esm/modules/appCatalog/utils/searchApps.d.ts +10 -7
- package/dist/esm/modules/appCatalog/utils/searchApps.js +26 -14
- package/dist/esm/modules/appCatalog/utils/searchApps.js.map +1 -1
- package/package.json +3 -3
- package/src/modules/appCatalog/ui/grid/AppCatalogGrid.tsx +178 -137
- package/src/modules/appCatalog/utils/searchApps.ts +51 -30
|
@@ -32,7 +32,7 @@ function HighlightedText({
|
|
|
32
32
|
(segment, index) => segment.highlight ? /* @__PURE__ */ jsx(
|
|
33
33
|
"mark",
|
|
34
34
|
{
|
|
35
|
-
className: "bg-yellow-
|
|
35
|
+
className: "bg-yellow-300 dark:bg-yellow-600/60 font-semibold text-gray-900 dark:text-gray-100",
|
|
36
36
|
children: segment.text
|
|
37
37
|
},
|
|
38
38
|
index
|
|
@@ -145,19 +145,7 @@ function AppDetails({
|
|
|
145
145
|
/* @__PURE__ */ jsx(AppIcon, { app, className: "size-16" }),
|
|
146
146
|
/* @__PURE__ */ jsxs("div", { className: "-mx-3 flex-1 min-w-0", children: [
|
|
147
147
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3", children: [
|
|
148
|
-
/* @__PURE__ */ jsx(
|
|
149
|
-
InlineEditableField,
|
|
150
|
-
{
|
|
151
|
-
value: app.alias || app.displayName,
|
|
152
|
-
onSave: (alias) => updateApp.mutate({
|
|
153
|
-
id: app.id,
|
|
154
|
-
data: { alias: alias || null }
|
|
155
|
-
}),
|
|
156
|
-
placeholder: app.displayName,
|
|
157
|
-
className: "text-2xl font-semibold",
|
|
158
|
-
viewClassName: "min-w-0 text-2xl font-semibold"
|
|
159
|
-
}
|
|
160
|
-
),
|
|
148
|
+
/* @__PURE__ */ jsx("div", { className: "text-2xl font-semibold min-w-0", children: app.alias ? `${app.displayName} (${app.alias})` : app.displayName }),
|
|
161
149
|
app.deprecated && /* @__PURE__ */ jsx(
|
|
162
150
|
Badge,
|
|
163
151
|
{
|
|
@@ -166,10 +154,6 @@ function AppDetails({
|
|
|
166
154
|
}
|
|
167
155
|
)
|
|
168
156
|
] }),
|
|
169
|
-
app.alias && /* @__PURE__ */ jsx("div", { className: "mt-1 px-3", children: /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
170
|
-
"Full name: ",
|
|
171
|
-
app.displayName
|
|
172
|
-
] }) }),
|
|
173
157
|
isAdmin && /* @__PURE__ */ jsxs("div", { className: "mt-1 px-3", children: [
|
|
174
158
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground mr-2", children: "Slug:" }),
|
|
175
159
|
/* @__PURE__ */ jsx(
|
|
@@ -181,7 +165,7 @@ function AppDetails({
|
|
|
181
165
|
}
|
|
182
166
|
)
|
|
183
167
|
] }),
|
|
184
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 px-3", children: /* @__PURE__ */ jsx(
|
|
168
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1 px-3", children: isAdmin ? /* @__PURE__ */ jsx(
|
|
185
169
|
InlineEditableField,
|
|
186
170
|
{
|
|
187
171
|
value: app.appUrl ?? "",
|
|
@@ -202,7 +186,20 @@ function AppDetails({
|
|
|
202
186
|
}
|
|
203
187
|
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "—" })
|
|
204
188
|
}
|
|
205
|
-
)
|
|
189
|
+
) : app.appUrl ? /* @__PURE__ */ jsxs(
|
|
190
|
+
"a",
|
|
191
|
+
{
|
|
192
|
+
href: app.appUrl,
|
|
193
|
+
target: "_blank",
|
|
194
|
+
rel: "noopener noreferrer",
|
|
195
|
+
onClick: () => recordClick(app.slug),
|
|
196
|
+
className: "inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all",
|
|
197
|
+
children: [
|
|
198
|
+
app.appUrl.replaceAll(/https?:\/\//g, ""),
|
|
199
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3.5 shrink-0 opacity-40 transition-opacity" })
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "—" }) })
|
|
206
203
|
] })
|
|
207
204
|
] }) }),
|
|
208
205
|
app.deprecated && (() => {
|
|
@@ -239,7 +236,7 @@ function AppDetails({
|
|
|
239
236
|
})(),
|
|
240
237
|
/* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
|
|
241
238
|
/* @__PURE__ */ jsx("h3", { className: "mb-2 text-sm font-medium", children: "Description" }),
|
|
242
|
-
/* @__PURE__ */ jsx(
|
|
239
|
+
isAdmin ? /* @__PURE__ */ jsx(
|
|
243
240
|
InlineEditableField,
|
|
244
241
|
{
|
|
245
242
|
value: app.description ?? "",
|
|
@@ -248,7 +245,7 @@ function AppDetails({
|
|
|
248
245
|
placeholder: "Description",
|
|
249
246
|
className: "min-h-[4rem] resize-y text-sm text-muted-foreground"
|
|
250
247
|
}
|
|
251
|
-
)
|
|
248
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: app.description || "—" })
|
|
252
249
|
] }),
|
|
253
250
|
app.screenshotIds && app.screenshotIds.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
|
|
254
251
|
/* @__PURE__ */ jsxs("h3", { className: "mb-2 text-sm font-medium", children: [
|
|
@@ -300,95 +297,117 @@ function AppDetails({
|
|
|
300
297
|
] }),
|
|
301
298
|
/* @__PURE__ */ jsxs("div", { className: "mt-6", children: [
|
|
302
299
|
/* @__PURE__ */ jsx("h3", { className: "mb-2 text-sm font-medium", children: "Sources" }),
|
|
303
|
-
/* @__PURE__ */
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
300
|
+
isAdmin ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
301
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: displaySources.map((url, index) => {
|
|
302
|
+
const isDraft = draftSource !== null && index === sourceUrls.length;
|
|
303
|
+
return /* @__PURE__ */ jsxs(
|
|
304
|
+
"li",
|
|
305
|
+
{
|
|
306
|
+
className: "flex items-center gap-2 text-xs",
|
|
307
|
+
children: [
|
|
308
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground shrink-0", children: [
|
|
309
|
+
index + 1,
|
|
310
|
+
"."
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ jsx(
|
|
313
|
+
InlineEditableField,
|
|
314
|
+
{
|
|
315
|
+
value: url,
|
|
316
|
+
initialEditMode: isDraft,
|
|
317
|
+
onCancel: isDraft ? () => setDraftSource(null) : void 0,
|
|
318
|
+
onSave: (newUrl) => {
|
|
319
|
+
if (isDraft) {
|
|
320
|
+
setDraftSource(null);
|
|
321
|
+
if (newUrl) {
|
|
322
|
+
updateApp.mutate({
|
|
323
|
+
id: app.id,
|
|
324
|
+
data: { sources: [...sourceUrls, newUrl] }
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
const next = [...sourceUrls];
|
|
329
|
+
next[index] = newUrl;
|
|
324
330
|
updateApp.mutate({
|
|
325
331
|
id: app.id,
|
|
326
|
-
data: { sources:
|
|
332
|
+
data: { sources: next.filter(Boolean) }
|
|
327
333
|
});
|
|
328
334
|
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
335
|
+
},
|
|
336
|
+
placeholder: "https://...",
|
|
337
|
+
viewClassName: "flex-1 min-w-0",
|
|
338
|
+
renderView: (val) => val ? /* @__PURE__ */ jsxs(
|
|
339
|
+
"a",
|
|
340
|
+
{
|
|
341
|
+
href: val,
|
|
342
|
+
target: "_blank",
|
|
343
|
+
rel: "noopener noreferrer",
|
|
344
|
+
className: "hover:text-primary inline-flex items-center gap-1 truncate",
|
|
345
|
+
children: [
|
|
346
|
+
val.replaceAll(/https?:\/\//g, ""),
|
|
347
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3 shrink-0" })
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "—" })
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
!isDraft && /* @__PURE__ */ jsx(
|
|
354
|
+
Button,
|
|
355
|
+
{
|
|
356
|
+
type: "button",
|
|
357
|
+
variant: "ghost",
|
|
358
|
+
size: "icon-sm",
|
|
359
|
+
"aria-label": "Remove source",
|
|
360
|
+
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
361
|
+
onClick: () => {
|
|
362
|
+
const next = sourceUrls.filter(
|
|
363
|
+
(_, i) => i !== index
|
|
364
|
+
);
|
|
332
365
|
updateApp.mutate({
|
|
333
366
|
id: app.id,
|
|
334
|
-
data: { sources: next
|
|
367
|
+
data: { sources: next }
|
|
335
368
|
});
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
),
|
|
355
|
-
|
|
356
|
-
Button,
|
|
357
|
-
{
|
|
358
|
-
type: "button",
|
|
359
|
-
variant: "ghost",
|
|
360
|
-
size: "icon-sm",
|
|
361
|
-
"aria-label": "Remove source",
|
|
362
|
-
className: "shrink-0 text-muted-foreground hover:text-destructive",
|
|
363
|
-
onClick: () => {
|
|
364
|
-
const next = sourceUrls.filter((_, i) => i !== index);
|
|
365
|
-
updateApp.mutate({
|
|
366
|
-
id: app.id,
|
|
367
|
-
data: { sources: next }
|
|
368
|
-
});
|
|
369
|
-
},
|
|
370
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
|
|
371
|
-
}
|
|
372
|
-
)
|
|
369
|
+
},
|
|
370
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
]
|
|
374
|
+
},
|
|
375
|
+
isDraft ? "draft" : `${index}-${url}`
|
|
376
|
+
);
|
|
377
|
+
}) }),
|
|
378
|
+
/* @__PURE__ */ jsxs(
|
|
379
|
+
Button,
|
|
380
|
+
{
|
|
381
|
+
type: "button",
|
|
382
|
+
variant: "ghost",
|
|
383
|
+
size: "sm",
|
|
384
|
+
className: "mt-2 gap-1 text-muted-foreground",
|
|
385
|
+
onClick: () => setDraftSource(""),
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
|
|
388
|
+
"Add source"
|
|
373
389
|
]
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
] }) : /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: sourceUrls.map((url, index) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-xs", children: [
|
|
393
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground shrink-0", children: [
|
|
394
|
+
index + 1,
|
|
395
|
+
"."
|
|
396
|
+
] }),
|
|
397
|
+
url ? /* @__PURE__ */ jsxs(
|
|
398
|
+
"a",
|
|
399
|
+
{
|
|
400
|
+
href: url,
|
|
401
|
+
target: "_blank",
|
|
402
|
+
rel: "noopener noreferrer",
|
|
403
|
+
className: "hover:text-primary inline-flex items-center gap-1 truncate",
|
|
404
|
+
children: [
|
|
405
|
+
url.replaceAll(/https?:\/\//g, ""),
|
|
406
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3 shrink-0" })
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "—" })
|
|
410
|
+
] }, index)) })
|
|
392
411
|
] })
|
|
393
412
|
] }),
|
|
394
413
|
/* @__PURE__ */ jsx(
|
|
@@ -406,6 +425,9 @@ function AppDetails({
|
|
|
406
425
|
}
|
|
407
426
|
function groupApps(apps, groupingDef, hasSearch) {
|
|
408
427
|
var _a;
|
|
428
|
+
if (hasSearch) {
|
|
429
|
+
return [{ groupName: "All Apps", apps: [...apps] }];
|
|
430
|
+
}
|
|
409
431
|
if (!groupingDef) {
|
|
410
432
|
const sortedApps = [...apps].sort(
|
|
411
433
|
(a, b) => a.displayName.localeCompare(b.displayName)
|
|
@@ -447,9 +469,7 @@ function groupApps(apps, groupingDef, hasSearch) {
|
|
|
447
469
|
);
|
|
448
470
|
result.push({ groupName: "Other", apps: sortedUngrouped });
|
|
449
471
|
}
|
|
450
|
-
|
|
451
|
-
result.sort((a, b) => b.apps.length - a.apps.length);
|
|
452
|
-
}
|
|
472
|
+
result.sort((a, b) => b.apps.length - a.apps.length);
|
|
453
473
|
return result;
|
|
454
474
|
}
|
|
455
475
|
function AppCatalogGrid({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppCatalogGrid.js","sources":["../../../../../../src/modules/appCatalog/ui/grid/AppCatalogGrid.tsx"],"sourcesContent":["import type {\n AppForCatalog,\n GroupingTagDefinition,\n} from '@igstack/app-catalog-backend-core'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport {\n flexRender,\n getCoreRowModel,\n useReactTable,\n} from '@tanstack/react-table'\nimport { AppWindow, ExternalLink, Plus, Trash2, X } from 'lucide-react'\nimport React, { useEffect, useState } from 'react'\nimport { useHotkeys } from 'react-hotkeys-hook'\nimport { cn } from '~/lib/utils'\nimport type {} from '~/types/table'\nimport { Badge } from '~/ui/badge'\nimport { Button } from '~/ui/button'\nimport {\n ResizableHandle,\n ResizablePanel,\n ResizablePanelGroup,\n} from '~/ui/resizable'\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '~/ui/table'\nimport { AccessRequestSection } from '../components/AccessRequestSection'\nimport { useUser } from '~/modules/auth'\nimport { InlineEditableField } from '../components/InlineEditableField'\nimport { ScreenshotGallery } from '../components/ScreenshotGallery'\nimport { useUpdateApp } from '../../hooks/useUpdateApp'\nimport { useAppCatalogContext } from '../../context/AppCatalogContext'\nimport { useAppClickHistory } from '../../hooks/useAppClickHistory'\nimport { useKeyboardNavigation } from '../hooks/useKeyboardNavigation'\nimport { highlightText } from '../../utils/searchApps'\n\nexport interface AppCatalogGridProps {\n apps: Array<AppForCatalog>\n selectedAppSlug?: string\n groupingDefinition?: GroupingTagDefinition\n onAppClick?: (app: AppForCatalog) => void\n /** Whether search is active (affects group sorting) */\n hasSearch?: boolean\n /** Search query for highlighting matches */\n searchQuery?: string\n /** Total count of apps before filtering */\n totalAppsCount?: number\n /** Callback to clear all filters and search */\n onClearFilters?: () => void\n}\n\nfunction getIconUrl(iconName: string): string {\n return `/api/icons/${iconName}`\n}\n\nfunction HighlightedText({\n text,\n searchQuery,\n}: {\n text: string\n searchQuery?: string\n}) {\n if (!searchQuery) {\n return <>{text}</>\n }\n\n const segments = highlightText(text, searchQuery)\n\n return (\n <>\n {segments.map((segment, index) =>\n segment.highlight ? (\n <mark\n key={index}\n className=\"bg-yellow-200 dark:bg-yellow-900/50 font-semibold\"\n >\n {segment.text}\n </mark>\n ) : (\n <React.Fragment key={index}>{segment.text}</React.Fragment>\n ),\n )}\n </>\n )\n}\n\nfunction AppIcon({\n app,\n className,\n}: {\n app: AppForCatalog\n className?: string\n}) {\n const [imageError, setImageError] = React.useState(false)\n\n // Use iconName from backend if available\n if (app.iconName && !imageError) {\n return (\n <div className={cn('size-12 shrink-0', className)}>\n <img\n src={getIconUrl(app.iconName)}\n alt={`${app.alias || app.displayName} icon`}\n className=\"size-12 rounded-lg object-contain\"\n onError={() => setImageError(true)}\n />\n </div>\n )\n }\n\n // Fallback icon\n return (\n <div\n className={cn(\n 'flex items-center justify-center rounded-lg bg-primary/10 text-primary size-12 shrink-0',\n className,\n )}\n >\n <AppWindow className=\"size-6\" />\n </div>\n )\n}\n\nfunction AppScreenshot({ app }: { app: AppForCatalog }) {\n const [imageError, setImageError] = React.useState(false)\n const [isLoadingImage, setIsLoadingImage] = React.useState(true)\n\n // Check if app has screenshots\n const screenshotId = app.screenshotIds?.[0]\n if (!screenshotId) {\n return (\n <div className=\"w-full bg-muted/50 rounded-lg overflow-hidden flex items-center justify-center min-h-64\">\n <div className=\"w-full h-64 bg-muted/30 flex items-center justify-center text-muted-foreground text-sm\">\n No screenshot available\n </div>\n </div>\n )\n }\n\n const screenshotImageUrl = `/api/screenshots/${screenshotId}?size=512`\n\n return (\n <div className=\"w-full flex justify-center\">\n <div className=\"rounded-lg overflow-hidden inline-flex items-center justify-center min-h-64\">\n {!imageError ? (\n <img\n src={screenshotImageUrl}\n alt={`${app.alias || app.displayName} screenshot`}\n className=\"h-64 object-contain\"\n onError={() => {\n setImageError(true)\n setIsLoadingImage(false)\n }}\n onLoad={() => setIsLoadingImage(false)}\n />\n ) : null}\n {(imageError || isLoadingImage) && (\n <div className=\"w-full h-64 bg-muted/30 flex items-center justify-center text-muted-foreground text-sm\">\n {isLoadingImage\n ? 'Loading screenshot...'\n : 'No screenshot available'}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nfunction AppDetails({\n app,\n onAppClick,\n onClosePanel,\n}: {\n app: AppForCatalog\n onAppClick?: (app: AppForCatalog) => void\n onClosePanel: () => void\n}) {\n const [isGalleryOpen, setIsGalleryOpen] = React.useState(false)\n const [galleryInitialIndex, setGalleryInitialIndex] = React.useState(0)\n const { approvalMethods, apps } = useAppCatalogContext()\n const { recordClick } = useAppClickHistory()\n const updateApp = useUpdateApp()\n const [draftSource, setDraftSource] = React.useState<string | null>(null)\n const user = useUser()\n const isAdmin = user?.isAdmin ?? false\n\n const sourceUrls: Array<string> =\n app.sources?.map((s) => (typeof s === 'string' ? s : s.url)) ?? []\n const displaySources =\n draftSource !== null ? [...sourceUrls, draftSource] : sourceUrls\n\n // Enter: open screenshot gallery\n useHotkeys(\n 'enter',\n () => {\n const tag = document.activeElement?.tagName\n if (\n tag === 'BUTTON' ||\n tag === 'A' ||\n tag === 'INPUT' ||\n tag === 'SELECT' ||\n tag === 'TEXTAREA'\n )\n return\n\n if (app.screenshotIds && app.screenshotIds.length > 0) {\n setGalleryInitialIndex(0)\n setIsGalleryOpen(true)\n }\n },\n { enabled: !isGalleryOpen },\n [app, isGalleryOpen],\n )\n\n // Esc: close the details panel (only when gallery is NOT open)\n useHotkeys(\n 'escape',\n () => {\n onClosePanel()\n },\n { enabled: !isGalleryOpen },\n [isGalleryOpen, onClosePanel],\n )\n\n const handleScreenshotClick = (index: number) => {\n setGalleryInitialIndex(index)\n setIsGalleryOpen(true)\n }\n\n // Find replacement app if deprecated\n const replacementApp = app.deprecated?.replacementSlug\n ? apps.find((a) => a.slug === app.deprecated?.replacementSlug)\n : null\n\n return (\n <>\n <div className=\"flex h-full flex-col p-6\">\n {/* Icon and Title */}\n <div className=\"border-b pb-6\">\n <div className=\"flex items-center gap-3\">\n <AppIcon app={app} className=\"size-16\" />\n <div className=\"-mx-3 flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 px-3\">\n <InlineEditableField\n value={app.alias || app.displayName}\n onSave={(alias) =>\n updateApp.mutate({\n id: app.id,\n data: { alias: alias || null },\n })\n }\n placeholder={app.displayName}\n className=\"text-2xl font-semibold\"\n viewClassName=\"min-w-0 text-2xl font-semibold\"\n />\n {app.deprecated && (\n <Badge\n variant={\n app.deprecated.type === 'discouraged'\n ? 'secondary'\n : 'destructive'\n }\n >\n {app.deprecated.type === 'discouraged'\n ? 'Discouraged'\n : 'Deprecated'}\n </Badge>\n )}\n </div>\n {app.alias && (\n <div className=\"mt-1 px-3\">\n <span className=\"text-xs text-muted-foreground\">\n Full name: {app.displayName}\n </span>\n </div>\n )}\n {isAdmin && (\n <div className=\"mt-1 px-3\">\n <span className=\"text-xs text-muted-foreground mr-2\">\n Slug:\n </span>\n <InlineEditableField\n value={app.slug}\n onSave={(slug) =>\n updateApp.mutate({ id: app.id, data: { slug } })\n }\n className=\"text-sm\"\n />\n </div>\n )}\n <div className=\"mt-1 px-3\">\n <InlineEditableField\n value={app.appUrl ?? ''}\n onSave={(appUrl) =>\n updateApp.mutate({ id: app.id, data: { appUrl } })\n }\n placeholder=\"App URL\"\n renderView={(url) =>\n url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => recordClick(app.slug)}\n className=\"inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all\"\n >\n {url.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3.5 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )\n }\n />\n </div>\n </div>\n </div>\n </div>\n\n {/* Deprecation/Discouraged Warning */}\n {app.deprecated &&\n (() => {\n const deprecationType = app.deprecated.type || 'deprecated'\n const isDiscouraged = deprecationType === 'discouraged'\n return (\n <div\n className={\n isDiscouraged\n ? 'mt-6 p-4 border border-yellow-500/50 rounded-lg bg-yellow-50 dark:bg-yellow-950/20'\n : 'mt-6 p-4 border border-destructive/50 rounded-lg bg-destructive/10'\n }\n >\n <h3\n className={\n isDiscouraged\n ? 'text-sm font-semibold text-yellow-700 dark:text-yellow-500 mb-2'\n : 'text-sm font-semibold text-destructive mb-2'\n }\n >\n {isDiscouraged\n ? 'Usage discouraged'\n : 'This application is deprecated'}\n </h3>\n <p className=\"text-sm text-muted-foreground mb-3\">\n {app.deprecated.comment}\n </p>\n {replacementApp && (\n <button\n onClick={() => onAppClick?.(replacementApp)}\n className=\"text-sm font-medium text-primary hover:underline inline-flex items-center gap-1\"\n >\n View replacement: {replacementApp.displayName}\n <ExternalLink className=\"size-3\" />\n </button>\n )}\n </div>\n )\n })()}\n\n {/* Description */}\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Description</h3>\n <InlineEditableField\n value={app.description ?? ''}\n onSave={(description) =>\n updateApp.mutate({ id: app.id, data: { description } })\n }\n multiline\n placeholder=\"Description\"\n className=\"min-h-[4rem] resize-y text-sm text-muted-foreground\"\n />\n </div>\n\n {/* Screenshots - Clickable preview */}\n {app.screenshotIds && app.screenshotIds.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">\n Screenshots ({app.screenshotIds.length})\n </h3>\n <div\n className=\"cursor-pointer hover:opacity-80 transition-opacity\"\n onClick={() => handleScreenshotClick(0)}\n >\n <AppScreenshot app={app} />\n {app.screenshotIds.length > 1 && (\n <p className=\"text-xs text-muted-foreground mt-2 text-center\">\n Click to view all {app.screenshotIds.length} screenshots\n </p>\n )}\n </div>\n </div>\n )}\n\n {/* Access Request Section */}\n <AccessRequestSection app={app} approvalMethods={approvalMethods} />\n\n {/* Links */}\n {app.links && app.links.length > 0 && (\n <div className=\"mt-4\">\n <h3 className=\"mb-1 text-xs font-medium text-muted-foreground\">\n Links\n </h3>\n <div className=\"space-y-0.5\">\n {app.links.map((link) => (\n <a\n key={link.url}\n href={link.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-1 text-xs text-muted-foreground hover:text-primary truncate\"\n >\n <ExternalLink className=\"size-3 shrink-0\" />\n {link.title || link.url.replaceAll(/https?:\\/\\//g, '')}\n </a>\n ))}\n </div>\n </div>\n )}\n\n {/* Tags */}\n {app.tags && app.tags.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Tags</h3>\n <div className=\"flex flex-wrap gap-2\">\n {app.tags.map((tag) => (\n <Badge key={tag} variant=\"secondary\" className=\"text-xs\">\n {tag}\n </Badge>\n ))}\n </div>\n </div>\n )}\n\n {/* Teams */}\n {app.teams && app.teams.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Teams</h3>\n <div className=\"flex flex-wrap gap-2\">\n {app.teams.map((team) => (\n <Badge key={team} variant=\"outline\" className=\"text-xs\">\n {team}\n </Badge>\n ))}\n </div>\n </div>\n )}\n\n {/* Sources */}\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Sources</h3>\n <ul className=\"space-y-2\">\n {displaySources.map((url, index) => {\n const isDraft =\n draftSource !== null && index === sourceUrls.length\n return (\n <li\n key={isDraft ? 'draft' : `${index}-${url}`}\n className=\"flex items-center gap-2 text-xs\"\n >\n <span className=\"text-muted-foreground shrink-0\">\n {index + 1}.\n </span>\n <InlineEditableField\n value={url}\n initialEditMode={isDraft}\n onCancel={isDraft ? () => setDraftSource(null) : undefined}\n onSave={(newUrl) => {\n if (isDraft) {\n setDraftSource(null)\n if (newUrl) {\n updateApp.mutate({\n id: app.id,\n data: { sources: [...sourceUrls, newUrl] },\n })\n }\n } else {\n const next = [...sourceUrls]\n next[index] = newUrl\n updateApp.mutate({\n id: app.id,\n data: { sources: next.filter(Boolean) },\n })\n }\n }}\n placeholder=\"https://...\"\n viewClassName=\"flex-1 min-w-0\"\n renderView={(val) =>\n val ? (\n <a\n href={val}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-primary inline-flex items-center gap-1 truncate\"\n >\n {val.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3 shrink-0\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )\n }\n />\n {!isDraft && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Remove source\"\n className=\"shrink-0 text-muted-foreground hover:text-destructive\"\n onClick={() => {\n const next = sourceUrls.filter((_, i) => i !== index)\n updateApp.mutate({\n id: app.id,\n data: { sources: next },\n })\n }}\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n </li>\n )\n })}\n </ul>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"mt-2 gap-1 text-muted-foreground\"\n onClick={() => setDraftSource('')}\n >\n <Plus className=\"size-3.5\" />\n Add source\n </Button>\n </div>\n </div>\n\n {/* Screenshot Gallery Dialog */}\n <ScreenshotGallery\n app={app}\n screenshotIds={app.screenshotIds || []}\n open={isGalleryOpen}\n onOpenChange={setIsGalleryOpen}\n initialIndex={galleryInitialIndex}\n title={`${app.alias || app.displayName} - Screenshots`}\n />\n </>\n )\n}\n\ninterface GroupedApps {\n groupName: string\n apps: Array<AppForCatalog>\n}\n\nfunction groupApps(\n apps: Array<AppForCatalog>,\n groupingDef?: GroupingTagDefinition,\n hasSearch?: boolean,\n): Array<GroupedApps> {\n if (!groupingDef) {\n const sortedApps = [...apps].sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n return [{ groupName: 'All Apps', apps: sortedApps }]\n }\n\n const grouped = new Map<string, Array<AppForCatalog>>()\n const ungrouped: Array<AppForCatalog> = []\n\n for (const app of apps) {\n const matchingTag = app.tags?.find((tag) =>\n tag.startsWith(`${groupingDef.prefix}:`),\n )\n\n if (matchingTag) {\n const value = matchingTag.split(':')[1]\n if (value) {\n const tagValue = groupingDef.values.find((v) => v.value === value)\n const displayName = tagValue?.displayName || value\n\n if (!grouped.has(displayName)) {\n grouped.set(displayName, [])\n }\n grouped.get(displayName)!.push(app)\n } else {\n ungrouped.push(app)\n }\n } else {\n ungrouped.push(app)\n }\n }\n\n const result: Array<GroupedApps> = []\n for (const [groupName, appsInGroup] of grouped) {\n // Sort apps alphabetically within each group\n const sortedGroupApps = appsInGroup.sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n result.push({ groupName, apps: sortedGroupApps })\n }\n\n if (ungrouped.length > 0) {\n // Sort ungrouped apps alphabetically\n const sortedUngrouped = ungrouped.sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n result.push({ groupName: 'Other', apps: sortedUngrouped })\n }\n\n // Sort groups: when no search, sort by app count descending\n // When search is active, keep the order based on app relevance\n if (!hasSearch) {\n result.sort((a, b) => b.apps.length - a.apps.length)\n }\n\n return result\n}\n\nexport function AppCatalogGrid({\n apps,\n selectedAppSlug,\n groupingDefinition,\n onAppClick,\n hasSearch = false,\n searchQuery,\n totalAppsCount,\n onClearFilters,\n}: AppCatalogGridProps) {\n const selectedApp = selectedAppSlug\n ? apps.find((a) => a.slug === selectedAppSlug)\n : null\n\n const groupedApps = groupApps(apps, groupingDefinition, hasSearch)\n\n // Flatten grouped apps to get display order for keyboard navigation\n const appsInDisplayOrder = React.useMemo(\n () => groupedApps.flatMap((group) => group.apps),\n [groupedApps],\n )\n\n // Use keyboard navigation hook with apps in display order\n const { rowRefs } = useKeyboardNavigation({\n apps: appsInDisplayOrder,\n selectedAppSlug,\n onAppClick,\n })\n\n // Define columns\n const columns = React.useMemo<Array<ColumnDef<AppForCatalog>>>(\n () => [\n {\n id: 'application',\n header: 'Application',\n cell: ({ row }) => (\n <div className=\"flex items-center gap-3\">\n <AppIcon app={row.original} className=\"size-6\" />\n <div className=\"flex flex-col\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">\n <HighlightedText\n text={\n row.original.alias ||\n row.original.displayName ||\n 'Unnamed App'\n }\n searchQuery={searchQuery}\n />\n </span>\n {row.original.deprecated &&\n (() => {\n const deprecationType =\n row.original.deprecated.type || 'deprecated'\n return (\n <span className=\"text-[0.7rem] text-muted-foreground\">\n (\n {deprecationType === 'discouraged'\n ? 'Discouraged'\n : 'Deprecated'}\n )\n </span>\n )\n })()}\n </div>\n {row.original.alias && (\n <span className=\"text-xs text-muted-foreground\">\n <HighlightedText\n text={row.original.displayName}\n searchQuery={searchQuery}\n />\n </span>\n )}\n </div>\n </div>\n ),\n meta: {\n className: 'w-[300px]',\n },\n },\n {\n id: 'description',\n header: 'Description',\n cell: ({ row }) => (\n <span className=\"text-sm text-muted-foreground line-clamp-2\">\n <HighlightedText\n text={row.original.description || '—'}\n searchQuery={searchQuery}\n />\n </span>\n ),\n },\n ],\n [searchQuery],\n )\n\n // Create a single table instance with all apps\n const table = useReactTable({\n data: apps,\n columns,\n getCoreRowModel: getCoreRowModel(),\n getRowId: (row) => row.id,\n })\n\n // Panel visibility state - default to closed\n const [isPanelOpen, setIsPanelOpen] = useState(false)\n\n // Open panel when app is selected\n useEffect(() => {\n if (selectedApp) {\n setIsPanelOpen(true)\n }\n }, [selectedApp])\n\n // Auto-scroll to selected app (only on initial load)\n const hasScrolledRef = React.useRef(false)\n React.useEffect(() => {\n // Only scroll once on initial load if there's a selection\n if (selectedAppSlug && !hasScrolledRef.current) {\n const rowElement = rowRefs.current.get(selectedAppSlug)\n if (rowElement) {\n rowElement.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n hasScrolledRef.current = true\n }\n }, [selectedAppSlug, rowRefs])\n\n const handleAppClick = (app: AppForCatalog) => {\n onAppClick?.(app)\n }\n\n const handleClosePanel = () => {\n setIsPanelOpen(false)\n }\n\n return (\n <ResizablePanelGroup orientation=\"horizontal\" className=\"h-full w-full\">\n {/* Left Panel - Table */}\n <ResizablePanel\n defaultSize={isPanelOpen ? 60 : 100}\n minSize={30}\n className=\"overflow-hidden\"\n >\n <div className=\"h-full overflow-y-auto pr-2 pb-6 [scrollbar-gutter:stable]\">\n <Table>\n <TableHeader className=\"sticky top-0 border-b bg-background z-10\">\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead\n key={header.id}\n className={cn(\n 'px-4 py-3 text-left font-medium text-sm',\n header.column.columnDef.meta?.className,\n )}\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n\n <TableBody>\n {groupedApps.map((group) => (\n <React.Fragment key={group.groupName}>\n {/* Group Header Row */}\n <TableRow className=\"bg-muted/50 hover:bg-muted/50\">\n <TableCell\n colSpan={columns.length}\n className=\"px-4 py-6 sticky top-[49px] bg-muted/90 backdrop-blur z-10\"\n >\n <div className=\"flex items-center justify-center\">\n <span className=\"font-bold text-lg tracking-widest uppercase leading-loose text-muted-foreground\">\n {group.groupName}\n </span>\n </div>\n </TableCell>\n </TableRow>\n\n {/* Group Apps */}\n {group.apps.map((app) => {\n const row = table\n .getRowModel()\n .rows.find((r) => r.id === app.id)\n if (!row) return null\n\n return (\n <TableRow\n key={row.id}\n ref={(el) => {\n if (el && row.original.slug) {\n rowRefs.current.set(row.original.slug, el)\n } else if (row.original.slug) {\n rowRefs.current.delete(row.original.slug)\n }\n }}\n onClick={() => handleAppClick(row.original)}\n className={cn(\n 'border-b cursor-pointer transition-colors',\n selectedApp?.id === row.original.id\n ? 'bg-blue-100 dark:bg-blue-950 hover:bg-blue-200 dark:hover:bg-blue-900'\n : 'hover:bg-muted/30',\n )}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n className={cn(\n 'px-4 py-4',\n cell.column.columnDef.meta?.className,\n )}\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n )}\n </TableCell>\n ))}\n </TableRow>\n )\n })}\n </React.Fragment>\n ))}\n\n {/* Clear Filters Row */}\n {totalAppsCount &&\n totalAppsCount > apps.length &&\n onClearFilters && (\n <TableRow>\n <TableCell\n colSpan={columns.length}\n className=\"px-4 py-8 text-center\"\n >\n <Button\n variant=\"outline\"\n onClick={onClearFilters}\n className=\"gap-2\"\n >\n <X className=\"h-4 w-4\" />\n Clear filters to show all apps ({totalAppsCount})\n </Button>\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </ResizablePanel>\n\n {/* Right Panel - Details (only render when panel is open) */}\n {isPanelOpen && (\n <>\n {/* Resizable Handle */}\n <ResizableHandle withHandle />\n\n <ResizablePanel\n defaultSize={40}\n minSize={25}\n className=\"overflow-hidden\"\n >\n <div className=\"h-full overflow-y-auto border-l bg-background pl-4\">\n {selectedApp ? (\n <div className=\"relative\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"absolute top-4 right-4 z-10 hover:bg-accent\"\n onClick={handleClosePanel}\n aria-label=\"Close details panel\"\n >\n <X className=\"h-5 w-5\" />\n </Button>\n <AppDetails\n app={selectedApp}\n onAppClick={onAppClick}\n onClosePanel={handleClosePanel}\n />\n </div>\n ) : null}\n </div>\n </ResizablePanel>\n </>\n )}\n </ResizablePanelGroup>\n )\n}\n"],"names":["React","_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,SAAS,WAAW,UAA0B;AAC5C,SAAO,cAAc,QAAQ;AAC/B;AAEA,SAAS,gBAAgB;AAAA,EACvB;AAAA,EACA;AACF,GAGG;AACD,MAAI,CAAC,aAAa;AAChB,2CAAU,UAAA,KAAA,CAAK;AAAA,EACjB;AAEA,QAAM,WAAW,cAAc,MAAM,WAAW;AAEhD,yCAEK,UAAA,SAAS;AAAA,IAAI,CAAC,SAAS,UACtB,QAAQ,YACN;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,WAAU;AAAA,QAET,UAAA,QAAQ;AAAA,MAAA;AAAA,MAHJ;AAAA,IAAA,IAMP,oBAACA,eAAM,UAAN,EAA4B,UAAA,QAAQ,QAAhB,KAAqB;AAAA,EAAA,GAGhD;AAEJ;AAEA,SAAS,QAAQ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A,oBACR,SAAS;AAAA,oBACT,WAAU;AAAA,oBAEV,UAAA;AAAA,sBAAA,oBAAC,GAAA,EAAE,WAAU,UAAA,CAAU;AAAA,sBAAE;AAAA,sBACQ;AAAA,sBAAe;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAClD;AAAA,YAAA,EACF,CACF;AAAA,UAAA,EAAA,CAEN;AAAA,QAAA,EAAA,CACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAID,eACC,qBAAA,UAAA,EAEE,UAAA;AAAA,MAAA,oBAAC,iBAAA,EAAgB,YAAU,KAAA,CAAC;AAAA,MAE5B;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa;AAAA,UACb,SAAS;AAAA,UACT,WAAU;AAAA,UAEV,UAAA,oBAAC,SAAI,WAAU,sDACZ,wBACC,qBAAC,OAAA,EAAI,WAAU,YACb,UAAA;AAAA,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAW;AAAA,gBAEX,UAAA,oBAAC,GAAA,EAAE,WAAU,UAAA,CAAU;AAAA,cAAA;AAAA,YAAA;AAAA,YAEzB;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK;AAAA,gBACL;AAAA,gBACA,cAAc;AAAA,cAAA;AAAA,YAAA;AAAA,UAChB,EAAA,CACF,IACE,KAAA,CACN;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"AppCatalogGrid.js","sources":["../../../../../../src/modules/appCatalog/ui/grid/AppCatalogGrid.tsx"],"sourcesContent":["import type {\n AppForCatalog,\n GroupingTagDefinition,\n} from '@igstack/app-catalog-backend-core'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport {\n flexRender,\n getCoreRowModel,\n useReactTable,\n} from '@tanstack/react-table'\nimport { AppWindow, ExternalLink, Plus, Trash2, X } from 'lucide-react'\nimport React, { useEffect, useState } from 'react'\nimport { useHotkeys } from 'react-hotkeys-hook'\nimport { cn } from '~/lib/utils'\nimport type {} from '~/types/table'\nimport { Badge } from '~/ui/badge'\nimport { Button } from '~/ui/button'\nimport {\n ResizableHandle,\n ResizablePanel,\n ResizablePanelGroup,\n} from '~/ui/resizable'\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from '~/ui/table'\nimport { AccessRequestSection } from '../components/AccessRequestSection'\nimport { useUser } from '~/modules/auth'\nimport { InlineEditableField } from '../components/InlineEditableField'\nimport { ScreenshotGallery } from '../components/ScreenshotGallery'\nimport { useUpdateApp } from '../../hooks/useUpdateApp'\nimport { useAppCatalogContext } from '../../context/AppCatalogContext'\nimport { useAppClickHistory } from '../../hooks/useAppClickHistory'\nimport { useKeyboardNavigation } from '../hooks/useKeyboardNavigation'\nimport { highlightText } from '../../utils/searchApps'\n\nexport interface AppCatalogGridProps {\n apps: Array<AppForCatalog>\n selectedAppSlug?: string\n groupingDefinition?: GroupingTagDefinition\n onAppClick?: (app: AppForCatalog) => void\n /** Whether search is active (affects group sorting) */\n hasSearch?: boolean\n /** Search query for highlighting matches */\n searchQuery?: string\n /** Total count of apps before filtering */\n totalAppsCount?: number\n /** Callback to clear all filters and search */\n onClearFilters?: () => void\n}\n\nfunction getIconUrl(iconName: string): string {\n return `/api/icons/${iconName}`\n}\n\nfunction HighlightedText({\n text,\n searchQuery,\n}: {\n text: string\n searchQuery?: string\n}) {\n if (!searchQuery) {\n return <>{text}</>\n }\n\n const segments = highlightText(text, searchQuery)\n\n return (\n <>\n {segments.map((segment, index) =>\n segment.highlight ? (\n <mark\n key={index}\n className=\"bg-yellow-300 dark:bg-yellow-600/60 font-semibold text-gray-900 dark:text-gray-100\"\n >\n {segment.text}\n </mark>\n ) : (\n <React.Fragment key={index}>{segment.text}</React.Fragment>\n ),\n )}\n </>\n )\n}\n\nfunction AppIcon({\n app,\n className,\n}: {\n app: AppForCatalog\n className?: string\n}) {\n const [imageError, setImageError] = React.useState(false)\n\n // Use iconName from backend if available\n if (app.iconName && !imageError) {\n return (\n <div className={cn('size-12 shrink-0', className)}>\n <img\n src={getIconUrl(app.iconName)}\n alt={`${app.alias || app.displayName} icon`}\n className=\"size-12 rounded-lg object-contain\"\n onError={() => setImageError(true)}\n />\n </div>\n )\n }\n\n // Fallback icon\n return (\n <div\n className={cn(\n 'flex items-center justify-center rounded-lg bg-primary/10 text-primary size-12 shrink-0',\n className,\n )}\n >\n <AppWindow className=\"size-6\" />\n </div>\n )\n}\n\nfunction AppScreenshot({ app }: { app: AppForCatalog }) {\n const [imageError, setImageError] = React.useState(false)\n const [isLoadingImage, setIsLoadingImage] = React.useState(true)\n\n // Check if app has screenshots\n const screenshotId = app.screenshotIds?.[0]\n if (!screenshotId) {\n return (\n <div className=\"w-full bg-muted/50 rounded-lg overflow-hidden flex items-center justify-center min-h-64\">\n <div className=\"w-full h-64 bg-muted/30 flex items-center justify-center text-muted-foreground text-sm\">\n No screenshot available\n </div>\n </div>\n )\n }\n\n const screenshotImageUrl = `/api/screenshots/${screenshotId}?size=512`\n\n return (\n <div className=\"w-full flex justify-center\">\n <div className=\"rounded-lg overflow-hidden inline-flex items-center justify-center min-h-64\">\n {!imageError ? (\n <img\n src={screenshotImageUrl}\n alt={`${app.alias || app.displayName} screenshot`}\n className=\"h-64 object-contain\"\n onError={() => {\n setImageError(true)\n setIsLoadingImage(false)\n }}\n onLoad={() => setIsLoadingImage(false)}\n />\n ) : null}\n {(imageError || isLoadingImage) && (\n <div className=\"w-full h-64 bg-muted/30 flex items-center justify-center text-muted-foreground text-sm\">\n {isLoadingImage\n ? 'Loading screenshot...'\n : 'No screenshot available'}\n </div>\n )}\n </div>\n </div>\n )\n}\n\nfunction AppDetails({\n app,\n onAppClick,\n onClosePanel,\n}: {\n app: AppForCatalog\n onAppClick?: (app: AppForCatalog) => void\n onClosePanel: () => void\n}) {\n const [isGalleryOpen, setIsGalleryOpen] = React.useState(false)\n const [galleryInitialIndex, setGalleryInitialIndex] = React.useState(0)\n const { approvalMethods, apps } = useAppCatalogContext()\n const { recordClick } = useAppClickHistory()\n const updateApp = useUpdateApp()\n const [draftSource, setDraftSource] = React.useState<string | null>(null)\n const user = useUser()\n const isAdmin = user?.isAdmin ?? false\n\n const sourceUrls: Array<string> =\n app.sources?.map((s) => (typeof s === 'string' ? s : s.url)) ?? []\n const displaySources =\n draftSource !== null ? [...sourceUrls, draftSource] : sourceUrls\n\n // Enter: open screenshot gallery\n useHotkeys(\n 'enter',\n () => {\n const tag = document.activeElement?.tagName\n if (\n tag === 'BUTTON' ||\n tag === 'A' ||\n tag === 'INPUT' ||\n tag === 'SELECT' ||\n tag === 'TEXTAREA'\n )\n return\n\n if (app.screenshotIds && app.screenshotIds.length > 0) {\n setGalleryInitialIndex(0)\n setIsGalleryOpen(true)\n }\n },\n { enabled: !isGalleryOpen },\n [app, isGalleryOpen],\n )\n\n // Esc: close the details panel (only when gallery is NOT open)\n useHotkeys(\n 'escape',\n () => {\n onClosePanel()\n },\n { enabled: !isGalleryOpen },\n [isGalleryOpen, onClosePanel],\n )\n\n const handleScreenshotClick = (index: number) => {\n setGalleryInitialIndex(index)\n setIsGalleryOpen(true)\n }\n\n // Find replacement app if deprecated\n const replacementApp = app.deprecated?.replacementSlug\n ? apps.find((a) => a.slug === app.deprecated?.replacementSlug)\n : null\n\n return (\n <>\n <div className=\"flex h-full flex-col p-6\">\n {/* Icon and Title */}\n <div className=\"border-b pb-6\">\n <div className=\"flex items-center gap-3\">\n <AppIcon app={app} className=\"size-16\" />\n <div className=\"-mx-3 flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 px-3\">\n <div className=\"text-2xl font-semibold min-w-0\">\n {app.alias\n ? `${app.displayName} (${app.alias})`\n : app.displayName}\n </div>\n {app.deprecated && (\n <Badge\n variant={\n app.deprecated.type === 'discouraged'\n ? 'secondary'\n : 'destructive'\n }\n >\n {app.deprecated.type === 'discouraged'\n ? 'Discouraged'\n : 'Deprecated'}\n </Badge>\n )}\n </div>\n {isAdmin && (\n <div className=\"mt-1 px-3\">\n <span className=\"text-xs text-muted-foreground mr-2\">\n Slug:\n </span>\n <InlineEditableField\n value={app.slug}\n onSave={(slug) =>\n updateApp.mutate({ id: app.id, data: { slug } })\n }\n className=\"text-sm\"\n />\n </div>\n )}\n <div className=\"mt-1 px-3\">\n {isAdmin ? (\n <InlineEditableField\n value={app.appUrl ?? ''}\n onSave={(appUrl) =>\n updateApp.mutate({ id: app.id, data: { appUrl } })\n }\n placeholder=\"App URL\"\n renderView={(url) =>\n url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => recordClick(app.slug)}\n className=\"inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all\"\n >\n {url.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3.5 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )\n }\n />\n ) : app.appUrl ? (\n <a\n href={app.appUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => recordClick(app.slug)}\n className=\"inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all\"\n >\n {app.appUrl.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3.5 shrink-0 opacity-40 transition-opacity\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )}\n </div>\n </div>\n </div>\n </div>\n\n {/* Deprecation/Discouraged Warning */}\n {app.deprecated &&\n (() => {\n const deprecationType = app.deprecated.type || 'deprecated'\n const isDiscouraged = deprecationType === 'discouraged'\n return (\n <div\n className={\n isDiscouraged\n ? 'mt-6 p-4 border border-yellow-500/50 rounded-lg bg-yellow-50 dark:bg-yellow-950/20'\n : 'mt-6 p-4 border border-destructive/50 rounded-lg bg-destructive/10'\n }\n >\n <h3\n className={\n isDiscouraged\n ? 'text-sm font-semibold text-yellow-700 dark:text-yellow-500 mb-2'\n : 'text-sm font-semibold text-destructive mb-2'\n }\n >\n {isDiscouraged\n ? 'Usage discouraged'\n : 'This application is deprecated'}\n </h3>\n <p className=\"text-sm text-muted-foreground mb-3\">\n {app.deprecated.comment}\n </p>\n {replacementApp && (\n <button\n onClick={() => onAppClick?.(replacementApp)}\n className=\"text-sm font-medium text-primary hover:underline inline-flex items-center gap-1\"\n >\n View replacement: {replacementApp.displayName}\n <ExternalLink className=\"size-3\" />\n </button>\n )}\n </div>\n )\n })()}\n\n {/* Description */}\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Description</h3>\n {isAdmin ? (\n <InlineEditableField\n value={app.description ?? ''}\n onSave={(description) =>\n updateApp.mutate({ id: app.id, data: { description } })\n }\n multiline\n placeholder=\"Description\"\n className=\"min-h-[4rem] resize-y text-sm text-muted-foreground\"\n />\n ) : (\n <p className=\"text-sm text-muted-foreground\">\n {app.description || '—'}\n </p>\n )}\n </div>\n\n {/* Screenshots - Clickable preview */}\n {app.screenshotIds && app.screenshotIds.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">\n Screenshots ({app.screenshotIds.length})\n </h3>\n <div\n className=\"cursor-pointer hover:opacity-80 transition-opacity\"\n onClick={() => handleScreenshotClick(0)}\n >\n <AppScreenshot app={app} />\n {app.screenshotIds.length > 1 && (\n <p className=\"text-xs text-muted-foreground mt-2 text-center\">\n Click to view all {app.screenshotIds.length} screenshots\n </p>\n )}\n </div>\n </div>\n )}\n\n {/* Access Request Section */}\n <AccessRequestSection app={app} approvalMethods={approvalMethods} />\n\n {/* Links */}\n {app.links && app.links.length > 0 && (\n <div className=\"mt-4\">\n <h3 className=\"mb-1 text-xs font-medium text-muted-foreground\">\n Links\n </h3>\n <div className=\"space-y-0.5\">\n {app.links.map((link) => (\n <a\n key={link.url}\n href={link.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-1 text-xs text-muted-foreground hover:text-primary truncate\"\n >\n <ExternalLink className=\"size-3 shrink-0\" />\n {link.title || link.url.replaceAll(/https?:\\/\\//g, '')}\n </a>\n ))}\n </div>\n </div>\n )}\n\n {/* Tags */}\n {app.tags && app.tags.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Tags</h3>\n <div className=\"flex flex-wrap gap-2\">\n {app.tags.map((tag) => (\n <Badge key={tag} variant=\"secondary\" className=\"text-xs\">\n {tag}\n </Badge>\n ))}\n </div>\n </div>\n )}\n\n {/* Teams */}\n {app.teams && app.teams.length > 0 && (\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Teams</h3>\n <div className=\"flex flex-wrap gap-2\">\n {app.teams.map((team) => (\n <Badge key={team} variant=\"outline\" className=\"text-xs\">\n {team}\n </Badge>\n ))}\n </div>\n </div>\n )}\n\n {/* Sources */}\n <div className=\"mt-6\">\n <h3 className=\"mb-2 text-sm font-medium\">Sources</h3>\n {isAdmin ? (\n <>\n <ul className=\"space-y-2\">\n {displaySources.map((url, index) => {\n const isDraft =\n draftSource !== null && index === sourceUrls.length\n return (\n <li\n key={isDraft ? 'draft' : `${index}-${url}`}\n className=\"flex items-center gap-2 text-xs\"\n >\n <span className=\"text-muted-foreground shrink-0\">\n {index + 1}.\n </span>\n <InlineEditableField\n value={url}\n initialEditMode={isDraft}\n onCancel={\n isDraft ? () => setDraftSource(null) : undefined\n }\n onSave={(newUrl) => {\n if (isDraft) {\n setDraftSource(null)\n if (newUrl) {\n updateApp.mutate({\n id: app.id,\n data: { sources: [...sourceUrls, newUrl] },\n })\n }\n } else {\n const next = [...sourceUrls]\n next[index] = newUrl\n updateApp.mutate({\n id: app.id,\n data: { sources: next.filter(Boolean) },\n })\n }\n }}\n placeholder=\"https://...\"\n viewClassName=\"flex-1 min-w-0\"\n renderView={(val) =>\n val ? (\n <a\n href={val}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-primary inline-flex items-center gap-1 truncate\"\n >\n {val.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3 shrink-0\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )\n }\n />\n {!isDraft && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n aria-label=\"Remove source\"\n className=\"shrink-0 text-muted-foreground hover:text-destructive\"\n onClick={() => {\n const next = sourceUrls.filter(\n (_, i) => i !== index,\n )\n updateApp.mutate({\n id: app.id,\n data: { sources: next },\n })\n }}\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n </li>\n )\n })}\n </ul>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"mt-2 gap-1 text-muted-foreground\"\n onClick={() => setDraftSource('')}\n >\n <Plus className=\"size-3.5\" />\n Add source\n </Button>\n </>\n ) : (\n <ul className=\"space-y-2\">\n {sourceUrls.map((url, index) => (\n <li key={index} className=\"flex items-center gap-2 text-xs\">\n <span className=\"text-muted-foreground shrink-0\">\n {index + 1}.\n </span>\n {url ? (\n <a\n href={url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"hover:text-primary inline-flex items-center gap-1 truncate\"\n >\n {url.replaceAll(/https?:\\/\\//g, '')}\n <ExternalLink className=\"size-3 shrink-0\" />\n </a>\n ) : (\n <span className=\"text-muted-foreground\">—</span>\n )}\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n\n {/* Screenshot Gallery Dialog */}\n <ScreenshotGallery\n app={app}\n screenshotIds={app.screenshotIds || []}\n open={isGalleryOpen}\n onOpenChange={setIsGalleryOpen}\n initialIndex={galleryInitialIndex}\n title={`${app.alias || app.displayName} - Screenshots`}\n />\n </>\n )\n}\n\ninterface GroupedApps {\n groupName: string\n apps: Array<AppForCatalog>\n}\n\nfunction groupApps(\n apps: Array<AppForCatalog>,\n groupingDef?: GroupingTagDefinition,\n hasSearch?: boolean,\n): Array<GroupedApps> {\n // When search is active, skip grouping and preserve relevance order\n if (hasSearch) {\n return [{ groupName: 'All Apps', apps: [...apps] }]\n }\n\n if (!groupingDef) {\n // No grouping definition - sort alphabetically\n const sortedApps = [...apps].sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n return [{ groupName: 'All Apps', apps: sortedApps }]\n }\n\n const grouped = new Map<string, Array<AppForCatalog>>()\n const ungrouped: Array<AppForCatalog> = []\n\n for (const app of apps) {\n const matchingTag = app.tags?.find((tag) =>\n tag.startsWith(`${groupingDef.prefix}:`),\n )\n\n if (matchingTag) {\n const value = matchingTag.split(':')[1]\n if (value) {\n const tagValue = groupingDef.values.find((v) => v.value === value)\n const displayName = tagValue?.displayName || value\n\n if (!grouped.has(displayName)) {\n grouped.set(displayName, [])\n }\n grouped.get(displayName)!.push(app)\n } else {\n ungrouped.push(app)\n }\n } else {\n ungrouped.push(app)\n }\n }\n\n const result: Array<GroupedApps> = []\n for (const [groupName, appsInGroup] of grouped) {\n // Sort alphabetically within each group\n const sortedGroupApps = appsInGroup.sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n result.push({ groupName, apps: sortedGroupApps })\n }\n\n if (ungrouped.length > 0) {\n // Sort alphabetically\n const sortedUngrouped = ungrouped.sort((a, b) =>\n a.displayName.localeCompare(b.displayName),\n )\n result.push({ groupName: 'Other', apps: sortedUngrouped })\n }\n\n // Sort groups by app count descending\n result.sort((a, b) => b.apps.length - a.apps.length)\n\n return result\n}\n\nexport function AppCatalogGrid({\n apps,\n selectedAppSlug,\n groupingDefinition,\n onAppClick,\n hasSearch = false,\n searchQuery,\n totalAppsCount,\n onClearFilters,\n}: AppCatalogGridProps) {\n const selectedApp = selectedAppSlug\n ? apps.find((a) => a.slug === selectedAppSlug)\n : null\n\n const groupedApps = groupApps(apps, groupingDefinition, hasSearch)\n\n // Flatten grouped apps to get display order for keyboard navigation\n const appsInDisplayOrder = React.useMemo(\n () => groupedApps.flatMap((group) => group.apps),\n [groupedApps],\n )\n\n // Use keyboard navigation hook with apps in display order\n const { rowRefs } = useKeyboardNavigation({\n apps: appsInDisplayOrder,\n selectedAppSlug,\n onAppClick,\n })\n\n // Define columns\n const columns = React.useMemo<Array<ColumnDef<AppForCatalog>>>(\n () => [\n {\n id: 'application',\n header: 'Application',\n cell: ({ row }) => (\n <div className=\"flex items-center gap-3\">\n <AppIcon app={row.original} className=\"size-6\" />\n <div className=\"flex flex-col\">\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">\n <HighlightedText\n text={\n row.original.alias ||\n row.original.displayName ||\n 'Unnamed App'\n }\n searchQuery={searchQuery}\n />\n </span>\n {row.original.deprecated &&\n (() => {\n const deprecationType =\n row.original.deprecated.type || 'deprecated'\n return (\n <span className=\"text-[0.7rem] text-muted-foreground\">\n (\n {deprecationType === 'discouraged'\n ? 'Discouraged'\n : 'Deprecated'}\n )\n </span>\n )\n })()}\n </div>\n {row.original.alias && (\n <span className=\"text-xs text-muted-foreground\">\n <HighlightedText\n text={row.original.displayName}\n searchQuery={searchQuery}\n />\n </span>\n )}\n </div>\n </div>\n ),\n meta: {\n className: 'w-[300px]',\n },\n },\n {\n id: 'description',\n header: 'Description',\n cell: ({ row }) => (\n <span className=\"text-sm text-muted-foreground line-clamp-2\">\n <HighlightedText\n text={row.original.description || '—'}\n searchQuery={searchQuery}\n />\n </span>\n ),\n },\n ],\n [searchQuery],\n )\n\n // Create a single table instance with all apps\n const table = useReactTable({\n data: apps,\n columns,\n getCoreRowModel: getCoreRowModel(),\n getRowId: (row) => row.id,\n })\n\n // Panel visibility state - default to closed\n const [isPanelOpen, setIsPanelOpen] = useState(false)\n\n // Open panel when app is selected\n useEffect(() => {\n if (selectedApp) {\n setIsPanelOpen(true)\n }\n }, [selectedApp])\n\n // Auto-scroll to selected app (only on initial load)\n const hasScrolledRef = React.useRef(false)\n React.useEffect(() => {\n // Only scroll once on initial load if there's a selection\n if (selectedAppSlug && !hasScrolledRef.current) {\n const rowElement = rowRefs.current.get(selectedAppSlug)\n if (rowElement) {\n rowElement.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }\n hasScrolledRef.current = true\n }\n }, [selectedAppSlug, rowRefs])\n\n const handleAppClick = (app: AppForCatalog) => {\n onAppClick?.(app)\n }\n\n const handleClosePanel = () => {\n setIsPanelOpen(false)\n }\n\n return (\n <ResizablePanelGroup orientation=\"horizontal\" className=\"h-full w-full\">\n {/* Left Panel - Table */}\n <ResizablePanel\n defaultSize={isPanelOpen ? 60 : 100}\n minSize={30}\n className=\"overflow-hidden\"\n >\n <div className=\"h-full overflow-y-auto pr-2 pb-6 [scrollbar-gutter:stable]\">\n <Table>\n <TableHeader className=\"sticky top-0 border-b bg-background z-10\">\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => (\n <TableHead\n key={header.id}\n className={cn(\n 'px-4 py-3 text-left font-medium text-sm',\n header.column.columnDef.meta?.className,\n )}\n >\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext(),\n )}\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n\n <TableBody>\n {groupedApps.map((group) => (\n <React.Fragment key={group.groupName}>\n {/* Group Header Row */}\n <TableRow className=\"bg-muted/50 hover:bg-muted/50\">\n <TableCell\n colSpan={columns.length}\n className=\"px-4 py-6 sticky top-[49px] bg-muted/90 backdrop-blur z-10\"\n >\n <div className=\"flex items-center justify-center\">\n <span className=\"font-bold text-lg tracking-widest uppercase leading-loose text-muted-foreground\">\n {group.groupName}\n </span>\n </div>\n </TableCell>\n </TableRow>\n\n {/* Group Apps */}\n {group.apps.map((app) => {\n const row = table\n .getRowModel()\n .rows.find((r) => r.id === app.id)\n if (!row) return null\n\n return (\n <TableRow\n key={row.id}\n ref={(el) => {\n if (el && row.original.slug) {\n rowRefs.current.set(row.original.slug, el)\n } else if (row.original.slug) {\n rowRefs.current.delete(row.original.slug)\n }\n }}\n onClick={() => handleAppClick(row.original)}\n className={cn(\n 'border-b cursor-pointer transition-colors',\n selectedApp?.id === row.original.id\n ? 'bg-blue-100 dark:bg-blue-950 hover:bg-blue-200 dark:hover:bg-blue-900'\n : 'hover:bg-muted/30',\n )}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n className={cn(\n 'px-4 py-4',\n cell.column.columnDef.meta?.className,\n )}\n >\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext(),\n )}\n </TableCell>\n ))}\n </TableRow>\n )\n })}\n </React.Fragment>\n ))}\n\n {/* Clear Filters Row */}\n {totalAppsCount &&\n totalAppsCount > apps.length &&\n onClearFilters && (\n <TableRow>\n <TableCell\n colSpan={columns.length}\n className=\"px-4 py-8 text-center\"\n >\n <Button\n variant=\"outline\"\n onClick={onClearFilters}\n className=\"gap-2\"\n >\n <X className=\"h-4 w-4\" />\n Clear filters to show all apps ({totalAppsCount})\n </Button>\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n </ResizablePanel>\n\n {/* Right Panel - Details (only render when panel is open) */}\n {isPanelOpen && (\n <>\n {/* Resizable Handle */}\n <ResizableHandle withHandle />\n\n <ResizablePanel\n defaultSize={40}\n minSize={25}\n className=\"overflow-hidden\"\n >\n <div className=\"h-full overflow-y-auto border-l bg-background pl-4\">\n {selectedApp ? (\n <div className=\"relative\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"absolute top-4 right-4 z-10 hover:bg-accent\"\n onClick={handleClosePanel}\n aria-label=\"Close details panel\"\n >\n <X className=\"h-5 w-5\" />\n </Button>\n <AppDetails\n app={selectedApp}\n onAppClick={onAppClick}\n onClosePanel={handleClosePanel}\n />\n </div>\n ) : null}\n </div>\n </ResizablePanel>\n </>\n )}\n </ResizablePanelGroup>\n )\n}\n"],"names":["React","_a"],"mappings":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gBACC,SAAS,QAAQ;AAAA,gBACjB,WAAU;AAAA,gBAEV,UAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,SAAQ;AAAA,oBACR,SAAS;AAAA,oBACT,WAAU;AAAA,oBAEV,UAAA;AAAA,sBAAA,oBAAC,GAAA,EAAE,WAAU,UAAA,CAAU;AAAA,sBAAE;AAAA,sBACQ;AAAA,sBAAe;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cAClD;AAAA,YAAA,EACF,CACF;AAAA,UAAA,EAAA,CAEN;AAAA,QAAA,EAAA,CACF,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,IAID,eACC,qBAAA,UAAA,EAEE,UAAA;AAAA,MAAA,oBAAC,iBAAA,EAAgB,YAAU,KAAA,CAAC;AAAA,MAE5B;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAa;AAAA,UACb,SAAS;AAAA,UACT,WAAU;AAAA,UAEV,UAAA,oBAAC,SAAI,WAAU,sDACZ,wBACC,qBAAC,OAAA,EAAI,WAAU,YACb,UAAA;AAAA,YAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAW;AAAA,gBAEX,UAAA,oBAAC,GAAA,EAAE,WAAU,UAAA,CAAU;AAAA,cAAA;AAAA,YAAA;AAAA,YAEzB;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK;AAAA,gBACL;AAAA,gBACA,cAAc;AAAA,cAAA;AAAA,YAAA;AAAA,UAChB,EAAA,CACF,IACE,KAAA,CACN;AAAA,QAAA;AAAA,MAAA;AAAA,IACF,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -14,13 +14,16 @@ export interface SearchResult {
|
|
|
14
14
|
* Priority order (alias has higher priority than displayName):
|
|
15
15
|
* 1. Exact match in alias
|
|
16
16
|
* 2. Exact match in displayName
|
|
17
|
-
* 3.
|
|
18
|
-
* 4. Prefix match in
|
|
19
|
-
* 5.
|
|
20
|
-
* 6.
|
|
21
|
-
* 7.
|
|
22
|
-
* 8.
|
|
23
|
-
* 9.
|
|
17
|
+
* 3. Exact match in tags
|
|
18
|
+
* 4. Prefix match in alias
|
|
19
|
+
* 5. Prefix match in displayName
|
|
20
|
+
* 6. Prefix match in tags
|
|
21
|
+
* 7. Contains match in alias
|
|
22
|
+
* 8. Contains match in displayName
|
|
23
|
+
* 9. Contains match in tags
|
|
24
|
+
* 10. Teams
|
|
25
|
+
* 11. Description
|
|
26
|
+
*
|
|
24
27
|
*
|
|
25
28
|
* @param apps - Array of apps to search
|
|
26
29
|
* @param searchQuery - Search query string
|
|
@@ -4,30 +4,36 @@ function searchApps(apps, searchQuery) {
|
|
|
4
4
|
return apps;
|
|
5
5
|
}
|
|
6
6
|
const scoredApps = apps.map((app) => {
|
|
7
|
-
var _a, _b, _c, _d;
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
8
|
const name = app.displayName.toLowerCase();
|
|
9
9
|
const alias = ((_a = app.alias) == null ? void 0 : _a.toLowerCase()) || "";
|
|
10
10
|
const description = ((_b = app.description) == null ? void 0 : _b.toLowerCase()) || "";
|
|
11
11
|
const tags = ((_c = app.tags) == null ? void 0 : _c.join(" ").toLowerCase()) || "";
|
|
12
12
|
const teams = ((_d = app.teams) == null ? void 0 : _d.join(" ").toLowerCase()) || "";
|
|
13
|
-
if (name === normalizedQuery) {
|
|
14
|
-
return { app, match: { field: "displayName", type: "exact" } };
|
|
15
|
-
}
|
|
16
13
|
if (alias && alias === normalizedQuery) {
|
|
17
14
|
return { app, match: { field: "alias", type: "exact" } };
|
|
18
15
|
}
|
|
19
|
-
if (name
|
|
20
|
-
return { app, match: { field: "displayName", type: "
|
|
16
|
+
if (name === normalizedQuery) {
|
|
17
|
+
return { app, match: { field: "displayName", type: "exact" } };
|
|
18
|
+
}
|
|
19
|
+
if ((_e = app.tags) == null ? void 0 : _e.some((tag) => tag.toLowerCase() === normalizedQuery)) {
|
|
20
|
+
return { app, match: { field: "tags", type: "exact" } };
|
|
21
21
|
}
|
|
22
22
|
if (alias && alias.startsWith(normalizedQuery)) {
|
|
23
23
|
return { app, match: { field: "alias", type: "prefix" } };
|
|
24
24
|
}
|
|
25
|
-
if (name.
|
|
26
|
-
return { app, match: { field: "displayName", type: "
|
|
25
|
+
if (name.startsWith(normalizedQuery)) {
|
|
26
|
+
return { app, match: { field: "displayName", type: "prefix" } };
|
|
27
|
+
}
|
|
28
|
+
if ((_f = app.tags) == null ? void 0 : _f.some((tag) => tag.toLowerCase().startsWith(normalizedQuery))) {
|
|
29
|
+
return { app, match: { field: "tags", type: "prefix" } };
|
|
27
30
|
}
|
|
28
31
|
if (alias && alias.includes(normalizedQuery)) {
|
|
29
32
|
return { app, match: { field: "alias", type: "contains" } };
|
|
30
33
|
}
|
|
34
|
+
if (name.includes(normalizedQuery)) {
|
|
35
|
+
return { app, match: { field: "displayName", type: "contains" } };
|
|
36
|
+
}
|
|
31
37
|
if (tags.includes(normalizedQuery)) {
|
|
32
38
|
return { app, match: { field: "tags", type: "contains" } };
|
|
33
39
|
}
|
|
@@ -43,17 +49,23 @@ function searchApps(apps, searchQuery) {
|
|
|
43
49
|
scoredApps.forEach(({ app, match }) => {
|
|
44
50
|
let score = 0;
|
|
45
51
|
if (match.type === "exact") {
|
|
46
|
-
|
|
52
|
+
if (match.field === "alias") score = 0;
|
|
53
|
+
else if (match.field === "displayName") score = 1;
|
|
54
|
+
else if (match.field === "tags") score = 2;
|
|
55
|
+
else score = 999;
|
|
47
56
|
} else if (match.type === "prefix") {
|
|
48
|
-
|
|
57
|
+
if (match.field === "alias") score = 3;
|
|
58
|
+
else if (match.field === "displayName") score = 4;
|
|
59
|
+
else if (match.field === "tags") score = 5;
|
|
60
|
+
else score = 999;
|
|
49
61
|
} else if (match.field === "displayName" || match.field === "alias") {
|
|
50
|
-
score = match.field === "alias" ?
|
|
62
|
+
score = match.field === "alias" ? 6 : 7;
|
|
51
63
|
} else if (match.field === "tags") {
|
|
52
|
-
score =
|
|
64
|
+
score = 8;
|
|
53
65
|
} else if (match.field === "teams") {
|
|
54
|
-
score =
|
|
66
|
+
score = 9;
|
|
55
67
|
} else {
|
|
56
|
-
score =
|
|
68
|
+
score = 10;
|
|
57
69
|
}
|
|
58
70
|
scoreMap.set(app.id, score);
|
|
59
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchApps.js","sources":["../../../../../src/modules/appCatalog/utils/searchApps.ts"],"sourcesContent":["import type { AppForCatalog } from '@igstack/app-catalog-backend-core'\n\nexport interface SearchMatch {\n /** Field where the match occurred */\n field: 'displayName' | 'alias' | 'slug' | 'tags' | 'teams' | 'description'\n /** Type of match */\n type: 'exact' | 'prefix' | 'contains'\n}\n\nexport interface SearchResult {\n app: AppForCatalog\n match: SearchMatch\n}\n\n/**\n * Search and sort apps by relevance with highlighting support.\n * Priority order (alias has higher priority than displayName):\n * 1. Exact match in alias\n * 2. Exact match in displayName\n * 3. Prefix match in alias\n *
|
|
1
|
+
{"version":3,"file":"searchApps.js","sources":["../../../../../src/modules/appCatalog/utils/searchApps.ts"],"sourcesContent":["import type { AppForCatalog } from '@igstack/app-catalog-backend-core'\n\nexport interface SearchMatch {\n /** Field where the match occurred */\n field: 'displayName' | 'alias' | 'slug' | 'tags' | 'teams' | 'description'\n /** Type of match */\n type: 'exact' | 'prefix' | 'contains'\n}\n\nexport interface SearchResult {\n app: AppForCatalog\n match: SearchMatch\n}\n\n/**\n * Search and sort apps by relevance with highlighting support.\n * Priority order (alias has higher priority than displayName):\n * 1. Exact match in alias\n * 2. Exact match in displayName\n * 3. Exact match in tags\n * 4. Prefix match in alias\n * 5. Prefix match in displayName\n * 6. Prefix match in tags\n * 7. Contains match in alias\n * 8. Contains match in displayName\n * 9. Contains match in tags\n * 10. Teams\n * 11. Description\n *\n *\n * @param apps - Array of apps to search\n * @param searchQuery - Search query string\n * @returns Filtered and sorted array of apps with search results\n */\nexport function searchApps(\n apps: Array<AppForCatalog>,\n searchQuery: string,\n): Array<AppForCatalog> {\n const normalizedQuery = searchQuery.trim().toLowerCase()\n\n if (normalizedQuery === '') {\n return apps\n }\n\n // Filter and score apps\n const scoredApps = apps\n .map((app): SearchResult | null => {\n const name = app.displayName.toLowerCase()\n const alias = app.alias?.toLowerCase() || ''\n const description = app.description?.toLowerCase() || ''\n const tags = app.tags?.join(' ').toLowerCase() || ''\n const teams = app.teams?.join(' ').toLowerCase() || ''\n\n // Check exact matches first - prioritize alias over displayName\n if (alias && alias === normalizedQuery) {\n return { app, match: { field: 'alias', type: 'exact' } }\n }\n if (name === normalizedQuery) {\n return { app, match: { field: 'displayName', type: 'exact' } }\n }\n\n // Check exact match in tags (any tag exactly matches query)\n if (app.tags?.some((tag) => tag.toLowerCase() === normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'exact' } }\n }\n\n // Check prefix matches - prioritize alias over displayName\n if (alias && alias.startsWith(normalizedQuery)) {\n return { app, match: { field: 'alias', type: 'prefix' } }\n }\n if (name.startsWith(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'prefix' } }\n }\n\n // Check tags - prefix match (any tag starts with query)\n if (\n app.tags?.some((tag) => tag.toLowerCase().startsWith(normalizedQuery))\n ) {\n return { app, match: { field: 'tags', type: 'prefix' } }\n }\n\n // Check contains matches in name/alias - prioritize alias over displayName\n if (alias && alias.includes(normalizedQuery)) {\n return { app, match: { field: 'alias', type: 'contains' } }\n }\n if (name.includes(normalizedQuery)) {\n return { app, match: { field: 'displayName', type: 'contains' } }\n }\n\n // Check tags - contains match\n if (tags.includes(normalizedQuery)) {\n return { app, match: { field: 'tags', type: 'contains' } }\n }\n\n // Check teams\n if (teams.includes(normalizedQuery)) {\n return { app, match: { field: 'teams', type: 'contains' } }\n }\n\n // Check description\n if (description.includes(normalizedQuery)) {\n return { app, match: { field: 'description', type: 'contains' } }\n }\n\n // No match found\n return null\n })\n .filter((item): item is SearchResult => item !== null)\n\n // Calculate numeric scores for sorting\n const scoreMap = new Map<string, number>()\n scoredApps.forEach(({ app, match }) => {\n let score = 0\n\n // Exact matches: 0-2 (alias, displayName, tags)\n if (match.type === 'exact') {\n if (match.field === 'alias') score = 0\n else if (match.field === 'displayName') score = 1\n else if (match.field === 'tags') score = 2\n else score = 999 // Should not happen\n }\n // Prefix matches: 3-5 (alias, displayName, tags)\n else if (match.type === 'prefix') {\n if (match.field === 'alias') score = 3\n else if (match.field === 'displayName') score = 4\n else if (match.field === 'tags') score = 5\n else score = 999 // Should not happen\n }\n // Contains in name/alias: 6-7 (alias before displayName)\n else if (match.field === 'displayName' || match.field === 'alias') {\n score = match.field === 'alias' ? 6 : 7\n }\n // Tags (contains): 8\n else if (match.field === 'tags') {\n score = 8\n }\n // Teams: 9\n else if (match.field === 'teams') {\n score = 9\n }\n // Description: 10\n else {\n score = 10\n }\n\n scoreMap.set(app.id, score)\n })\n\n // Sort by score (ascending - lower score = higher priority)\n scoredApps.sort((a, b) => {\n const scoreA = scoreMap.get(a.app.id) ?? 999\n const scoreB = scoreMap.get(b.app.id) ?? 999\n\n if (scoreA !== scoreB) {\n return scoreA - scoreB\n }\n // If same score, sort alphabetically by display name\n return a.app.displayName.localeCompare(b.app.displayName)\n })\n\n return scoredApps.map((item) => item.app)\n}\n\n/**\n * Highlight matching text in a string\n * @param text - Text to highlight\n * @param query - Search query\n * @returns Array of text segments with highlight flags\n */\nexport function highlightText(\n text: string,\n query: string,\n): Array<{ text: string; highlight: boolean }> {\n if (!query.trim()) {\n return [{ text, highlight: false }]\n }\n\n const normalizedQuery = query.trim().toLowerCase()\n const lowerText = text.toLowerCase()\n const index = lowerText.indexOf(normalizedQuery)\n\n if (index === -1) {\n return [{ text, highlight: false }]\n }\n\n const segments: Array<{ text: string; highlight: boolean }> = []\n\n // Text before match\n if (index > 0) {\n segments.push({ text: text.slice(0, index), highlight: false })\n }\n\n // Matched text\n segments.push({\n text: text.slice(index, index + normalizedQuery.length),\n highlight: true,\n })\n\n // Text after match\n if (index + normalizedQuery.length < text.length) {\n segments.push({\n text: text.slice(index + normalizedQuery.length),\n highlight: false,\n })\n }\n\n return segments\n}\n"],"names":[],"mappings":"AAkCO,SAAS,WACd,MACA,aACsB;AACtB,QAAM,kBAAkB,YAAY,KAAA,EAAO,YAAA;AAE3C,MAAI,oBAAoB,IAAI;AAC1B,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,KAChB,IAAI,CAAC,QAA6B;AAZhC;AAaD,UAAM,OAAO,IAAI,YAAY,YAAA;AAC7B,UAAM,UAAQ,SAAI,UAAJ,mBAAW,kBAAiB;AAC1C,UAAM,gBAAc,SAAI,gBAAJ,mBAAiB,kBAAiB;AACtD,UAAM,SAAO,SAAI,SAAJ,mBAAU,KAAK,KAAK,kBAAiB;AAClD,UAAM,UAAQ,SAAI,UAAJ,mBAAW,KAAK,KAAK,kBAAiB;AAGpD,QAAI,SAAS,UAAU,iBAAiB;AACtC,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,SAAS,MAAM,UAAQ;AAAA,IACvD;AACA,QAAI,SAAS,iBAAiB;AAC5B,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,eAAe,MAAM,UAAQ;AAAA,IAC7D;AAGA,SAAI,SAAI,SAAJ,mBAAU,KAAK,CAAC,QAAQ,IAAI,kBAAkB,kBAAkB;AAClE,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,QAAQ,MAAM,UAAQ;AAAA,IACtD;AAGA,QAAI,SAAS,MAAM,WAAW,eAAe,GAAG;AAC9C,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,SAAS,MAAM,WAAS;AAAA,IACxD;AACA,QAAI,KAAK,WAAW,eAAe,GAAG;AACpC,aAAO,EAAE,KAAK,OAAO,EAAE,OAAO,eAAe,MAAM,WAAS;AAAA,IAC9D;AAGA,SACE,SAAI,SAAJ,mBAAU,KAAK,CAAC,QAAQ,IAAI,cAAc,WAAW,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O;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igstack/app-catalog-frontend-core",
|
|
3
|
-
"version": "0.3.1-alpha-
|
|
3
|
+
"version": "0.3.1-alpha-20260317225951",
|
|
4
4
|
"description": "Frontend core library for App Catalog",
|
|
5
5
|
"homepage": "https://github.com/lislon/app-catalog",
|
|
6
6
|
"repository": {
|
|
@@ -134,8 +134,8 @@
|
|
|
134
134
|
"vite-plugin-static-copy": "^3.1.4",
|
|
135
135
|
"vite-plugin-svgr": "^4.2.0",
|
|
136
136
|
"vitest": "3.2.2",
|
|
137
|
-
"@igstack/app-catalog-backend-core": "0.3.1-alpha-
|
|
138
|
-
"@igstack/app-catalog-shared-core": "0.3.1-alpha-
|
|
137
|
+
"@igstack/app-catalog-backend-core": "0.3.1-alpha-20260317225951",
|
|
138
|
+
"@igstack/app-catalog-shared-core": "0.3.1-alpha-20260317225951"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
141
|
"react": "19.1.2",
|
|
@@ -76,7 +76,7 @@ function HighlightedText({
|
|
|
76
76
|
segment.highlight ? (
|
|
77
77
|
<mark
|
|
78
78
|
key={index}
|
|
79
|
-
className="bg-yellow-
|
|
79
|
+
className="bg-yellow-300 dark:bg-yellow-600/60 font-semibold text-gray-900 dark:text-gray-100"
|
|
80
80
|
>
|
|
81
81
|
{segment.text}
|
|
82
82
|
</mark>
|
|
@@ -244,18 +244,11 @@ function AppDetails({
|
|
|
244
244
|
<AppIcon app={app} className="size-16" />
|
|
245
245
|
<div className="-mx-3 flex-1 min-w-0">
|
|
246
246
|
<div className="flex items-center gap-2 px-3">
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
data: { alias: alias || null },
|
|
253
|
-
})
|
|
254
|
-
}
|
|
255
|
-
placeholder={app.displayName}
|
|
256
|
-
className="text-2xl font-semibold"
|
|
257
|
-
viewClassName="min-w-0 text-2xl font-semibold"
|
|
258
|
-
/>
|
|
247
|
+
<div className="text-2xl font-semibold min-w-0">
|
|
248
|
+
{app.alias
|
|
249
|
+
? `${app.displayName} (${app.alias})`
|
|
250
|
+
: app.displayName}
|
|
251
|
+
</div>
|
|
259
252
|
{app.deprecated && (
|
|
260
253
|
<Badge
|
|
261
254
|
variant={
|
|
@@ -270,13 +263,6 @@ function AppDetails({
|
|
|
270
263
|
</Badge>
|
|
271
264
|
)}
|
|
272
265
|
</div>
|
|
273
|
-
{app.alias && (
|
|
274
|
-
<div className="mt-1 px-3">
|
|
275
|
-
<span className="text-xs text-muted-foreground">
|
|
276
|
-
Full name: {app.displayName}
|
|
277
|
-
</span>
|
|
278
|
-
</div>
|
|
279
|
-
)}
|
|
280
266
|
{isAdmin && (
|
|
281
267
|
<div className="mt-1 px-3">
|
|
282
268
|
<span className="text-xs text-muted-foreground mr-2">
|
|
@@ -292,29 +278,44 @@ function AppDetails({
|
|
|
292
278
|
</div>
|
|
293
279
|
)}
|
|
294
280
|
<div className="mt-1 px-3">
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
url
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
281
|
+
{isAdmin ? (
|
|
282
|
+
<InlineEditableField
|
|
283
|
+
value={app.appUrl ?? ''}
|
|
284
|
+
onSave={(appUrl) =>
|
|
285
|
+
updateApp.mutate({ id: app.id, data: { appUrl } })
|
|
286
|
+
}
|
|
287
|
+
placeholder="App URL"
|
|
288
|
+
renderView={(url) =>
|
|
289
|
+
url ? (
|
|
290
|
+
<a
|
|
291
|
+
href={url}
|
|
292
|
+
target="_blank"
|
|
293
|
+
rel="noopener noreferrer"
|
|
294
|
+
onClick={() => recordClick(app.slug)}
|
|
295
|
+
className="inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all"
|
|
296
|
+
>
|
|
297
|
+
{url.replaceAll(/https?:\/\//g, '')}
|
|
298
|
+
<ExternalLink className="size-3.5 shrink-0 opacity-40 group-hover:opacity-100 transition-opacity" />
|
|
299
|
+
</a>
|
|
300
|
+
) : (
|
|
301
|
+
<span className="text-muted-foreground">—</span>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
/>
|
|
305
|
+
) : app.appUrl ? (
|
|
306
|
+
<a
|
|
307
|
+
href={app.appUrl}
|
|
308
|
+
target="_blank"
|
|
309
|
+
rel="noopener noreferrer"
|
|
310
|
+
onClick={() => recordClick(app.slug)}
|
|
311
|
+
className="inline-flex items-center gap-1 rounded-md py-1 text-sm text-blue-600 hover:bg-accent/30 hover:underline dark:text-blue-400 transition-all"
|
|
312
|
+
>
|
|
313
|
+
{app.appUrl.replaceAll(/https?:\/\//g, '')}
|
|
314
|
+
<ExternalLink className="size-3.5 shrink-0 opacity-40 transition-opacity" />
|
|
315
|
+
</a>
|
|
316
|
+
) : (
|
|
317
|
+
<span className="text-muted-foreground">—</span>
|
|
318
|
+
)}
|
|
318
319
|
</div>
|
|
319
320
|
</div>
|
|
320
321
|
</div>
|
|
@@ -363,15 +364,21 @@ function AppDetails({
|
|
|
363
364
|
{/* Description */}
|
|
364
365
|
<div className="mt-6">
|
|
365
366
|
<h3 className="mb-2 text-sm font-medium">Description</h3>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
367
|
+
{isAdmin ? (
|
|
368
|
+
<InlineEditableField
|
|
369
|
+
value={app.description ?? ''}
|
|
370
|
+
onSave={(description) =>
|
|
371
|
+
updateApp.mutate({ id: app.id, data: { description } })
|
|
372
|
+
}
|
|
373
|
+
multiline
|
|
374
|
+
placeholder="Description"
|
|
375
|
+
className="min-h-[4rem] resize-y text-sm text-muted-foreground"
|
|
376
|
+
/>
|
|
377
|
+
) : (
|
|
378
|
+
<p className="text-sm text-muted-foreground">
|
|
379
|
+
{app.description || '—'}
|
|
380
|
+
</p>
|
|
381
|
+
)}
|
|
375
382
|
</div>
|
|
376
383
|
|
|
377
384
|
{/* Screenshots - Clickable preview */}
|
|
@@ -451,90 +458,121 @@ function AppDetails({
|
|
|
451
458
|
{/* Sources */}
|
|
452
459
|
<div className="mt-6">
|
|
453
460
|
<h3 className="mb-2 text-sm font-medium">Sources</h3>
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
{isAdmin ? (
|
|
462
|
+
<>
|
|
463
|
+
<ul className="space-y-2">
|
|
464
|
+
{displaySources.map((url, index) => {
|
|
465
|
+
const isDraft =
|
|
466
|
+
draftSource !== null && index === sourceUrls.length
|
|
467
|
+
return (
|
|
468
|
+
<li
|
|
469
|
+
key={isDraft ? 'draft' : `${index}-${url}`}
|
|
470
|
+
className="flex items-center gap-2 text-xs"
|
|
471
|
+
>
|
|
472
|
+
<span className="text-muted-foreground shrink-0">
|
|
473
|
+
{index + 1}.
|
|
474
|
+
</span>
|
|
475
|
+
<InlineEditableField
|
|
476
|
+
value={url}
|
|
477
|
+
initialEditMode={isDraft}
|
|
478
|
+
onCancel={
|
|
479
|
+
isDraft ? () => setDraftSource(null) : undefined
|
|
480
|
+
}
|
|
481
|
+
onSave={(newUrl) => {
|
|
482
|
+
if (isDraft) {
|
|
483
|
+
setDraftSource(null)
|
|
484
|
+
if (newUrl) {
|
|
485
|
+
updateApp.mutate({
|
|
486
|
+
id: app.id,
|
|
487
|
+
data: { sources: [...sourceUrls, newUrl] },
|
|
488
|
+
})
|
|
489
|
+
}
|
|
490
|
+
} else {
|
|
491
|
+
const next = [...sourceUrls]
|
|
492
|
+
next[index] = newUrl
|
|
493
|
+
updateApp.mutate({
|
|
494
|
+
id: app.id,
|
|
495
|
+
data: { sources: next.filter(Boolean) },
|
|
496
|
+
})
|
|
497
|
+
}
|
|
498
|
+
}}
|
|
499
|
+
placeholder="https://..."
|
|
500
|
+
viewClassName="flex-1 min-w-0"
|
|
501
|
+
renderView={(val) =>
|
|
502
|
+
val ? (
|
|
503
|
+
<a
|
|
504
|
+
href={val}
|
|
505
|
+
target="_blank"
|
|
506
|
+
rel="noopener noreferrer"
|
|
507
|
+
className="hover:text-primary inline-flex items-center gap-1 truncate"
|
|
508
|
+
>
|
|
509
|
+
{val.replaceAll(/https?:\/\//g, '')}
|
|
510
|
+
<ExternalLink className="size-3 shrink-0" />
|
|
511
|
+
</a>
|
|
512
|
+
) : (
|
|
513
|
+
<span className="text-muted-foreground">—</span>
|
|
514
|
+
)
|
|
515
|
+
}
|
|
516
|
+
/>
|
|
517
|
+
{!isDraft && (
|
|
518
|
+
<Button
|
|
519
|
+
type="button"
|
|
520
|
+
variant="ghost"
|
|
521
|
+
size="icon-sm"
|
|
522
|
+
aria-label="Remove source"
|
|
523
|
+
className="shrink-0 text-muted-foreground hover:text-destructive"
|
|
524
|
+
onClick={() => {
|
|
525
|
+
const next = sourceUrls.filter(
|
|
526
|
+
(_, i) => i !== index,
|
|
527
|
+
)
|
|
528
|
+
updateApp.mutate({
|
|
529
|
+
id: app.id,
|
|
530
|
+
data: { sources: next },
|
|
531
|
+
})
|
|
532
|
+
}}
|
|
533
|
+
>
|
|
534
|
+
<Trash2 className="size-3.5" />
|
|
535
|
+
</Button>
|
|
536
|
+
)}
|
|
537
|
+
</li>
|
|
538
|
+
)
|
|
539
|
+
})}
|
|
540
|
+
</ul>
|
|
541
|
+
<Button
|
|
542
|
+
type="button"
|
|
543
|
+
variant="ghost"
|
|
544
|
+
size="sm"
|
|
545
|
+
className="mt-2 gap-1 text-muted-foreground"
|
|
546
|
+
onClick={() => setDraftSource('')}
|
|
547
|
+
>
|
|
548
|
+
<Plus className="size-3.5" />
|
|
549
|
+
Add source
|
|
550
|
+
</Button>
|
|
551
|
+
</>
|
|
552
|
+
) : (
|
|
553
|
+
<ul className="space-y-2">
|
|
554
|
+
{sourceUrls.map((url, index) => (
|
|
555
|
+
<li key={index} className="flex items-center gap-2 text-xs">
|
|
463
556
|
<span className="text-muted-foreground shrink-0">
|
|
464
557
|
{index + 1}.
|
|
465
558
|
</span>
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
setDraftSource(null)
|
|
473
|
-
if (newUrl) {
|
|
474
|
-
updateApp.mutate({
|
|
475
|
-
id: app.id,
|
|
476
|
-
data: { sources: [...sourceUrls, newUrl] },
|
|
477
|
-
})
|
|
478
|
-
}
|
|
479
|
-
} else {
|
|
480
|
-
const next = [...sourceUrls]
|
|
481
|
-
next[index] = newUrl
|
|
482
|
-
updateApp.mutate({
|
|
483
|
-
id: app.id,
|
|
484
|
-
data: { sources: next.filter(Boolean) },
|
|
485
|
-
})
|
|
486
|
-
}
|
|
487
|
-
}}
|
|
488
|
-
placeholder="https://..."
|
|
489
|
-
viewClassName="flex-1 min-w-0"
|
|
490
|
-
renderView={(val) =>
|
|
491
|
-
val ? (
|
|
492
|
-
<a
|
|
493
|
-
href={val}
|
|
494
|
-
target="_blank"
|
|
495
|
-
rel="noopener noreferrer"
|
|
496
|
-
className="hover:text-primary inline-flex items-center gap-1 truncate"
|
|
497
|
-
>
|
|
498
|
-
{val.replaceAll(/https?:\/\//g, '')}
|
|
499
|
-
<ExternalLink className="size-3 shrink-0" />
|
|
500
|
-
</a>
|
|
501
|
-
) : (
|
|
502
|
-
<span className="text-muted-foreground">—</span>
|
|
503
|
-
)
|
|
504
|
-
}
|
|
505
|
-
/>
|
|
506
|
-
{!isDraft && (
|
|
507
|
-
<Button
|
|
508
|
-
type="button"
|
|
509
|
-
variant="ghost"
|
|
510
|
-
size="icon-sm"
|
|
511
|
-
aria-label="Remove source"
|
|
512
|
-
className="shrink-0 text-muted-foreground hover:text-destructive"
|
|
513
|
-
onClick={() => {
|
|
514
|
-
const next = sourceUrls.filter((_, i) => i !== index)
|
|
515
|
-
updateApp.mutate({
|
|
516
|
-
id: app.id,
|
|
517
|
-
data: { sources: next },
|
|
518
|
-
})
|
|
519
|
-
}}
|
|
559
|
+
{url ? (
|
|
560
|
+
<a
|
|
561
|
+
href={url}
|
|
562
|
+
target="_blank"
|
|
563
|
+
rel="noopener noreferrer"
|
|
564
|
+
className="hover:text-primary inline-flex items-center gap-1 truncate"
|
|
520
565
|
>
|
|
521
|
-
|
|
522
|
-
|
|
566
|
+
{url.replaceAll(/https?:\/\//g, '')}
|
|
567
|
+
<ExternalLink className="size-3 shrink-0" />
|
|
568
|
+
</a>
|
|
569
|
+
) : (
|
|
570
|
+
<span className="text-muted-foreground">—</span>
|
|
523
571
|
)}
|
|
524
572
|
</li>
|
|
525
|
-
)
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
<Button
|
|
529
|
-
type="button"
|
|
530
|
-
variant="ghost"
|
|
531
|
-
size="sm"
|
|
532
|
-
className="mt-2 gap-1 text-muted-foreground"
|
|
533
|
-
onClick={() => setDraftSource('')}
|
|
534
|
-
>
|
|
535
|
-
<Plus className="size-3.5" />
|
|
536
|
-
Add source
|
|
537
|
-
</Button>
|
|
573
|
+
))}
|
|
574
|
+
</ul>
|
|
575
|
+
)}
|
|
538
576
|
</div>
|
|
539
577
|
</div>
|
|
540
578
|
|
|
@@ -561,7 +599,13 @@ function groupApps(
|
|
|
561
599
|
groupingDef?: GroupingTagDefinition,
|
|
562
600
|
hasSearch?: boolean,
|
|
563
601
|
): Array<GroupedApps> {
|
|
602
|
+
// When search is active, skip grouping and preserve relevance order
|
|
603
|
+
if (hasSearch) {
|
|
604
|
+
return [{ groupName: 'All Apps', apps: [...apps] }]
|
|
605
|
+
}
|
|
606
|
+
|
|
564
607
|
if (!groupingDef) {
|
|
608
|
+
// No grouping definition - sort alphabetically
|
|
565
609
|
const sortedApps = [...apps].sort((a, b) =>
|
|
566
610
|
a.displayName.localeCompare(b.displayName),
|
|
567
611
|
)
|
|
@@ -596,7 +640,7 @@ function groupApps(
|
|
|
596
640
|
|
|
597
641
|
const result: Array<GroupedApps> = []
|
|
598
642
|
for (const [groupName, appsInGroup] of grouped) {
|
|
599
|
-
// Sort
|
|
643
|
+
// Sort alphabetically within each group
|
|
600
644
|
const sortedGroupApps = appsInGroup.sort((a, b) =>
|
|
601
645
|
a.displayName.localeCompare(b.displayName),
|
|
602
646
|
)
|
|
@@ -604,18 +648,15 @@ function groupApps(
|
|
|
604
648
|
}
|
|
605
649
|
|
|
606
650
|
if (ungrouped.length > 0) {
|
|
607
|
-
// Sort
|
|
651
|
+
// Sort alphabetically
|
|
608
652
|
const sortedUngrouped = ungrouped.sort((a, b) =>
|
|
609
653
|
a.displayName.localeCompare(b.displayName),
|
|
610
654
|
)
|
|
611
655
|
result.push({ groupName: 'Other', apps: sortedUngrouped })
|
|
612
656
|
}
|
|
613
657
|
|
|
614
|
-
// Sort groups
|
|
615
|
-
|
|
616
|
-
if (!hasSearch) {
|
|
617
|
-
result.sort((a, b) => b.apps.length - a.apps.length)
|
|
618
|
-
}
|
|
658
|
+
// Sort groups by app count descending
|
|
659
|
+
result.sort((a, b) => b.apps.length - a.apps.length)
|
|
619
660
|
|
|
620
661
|
return result
|
|
621
662
|
}
|
|
@@ -17,13 +17,16 @@ export interface SearchResult {
|
|
|
17
17
|
* Priority order (alias has higher priority than displayName):
|
|
18
18
|
* 1. Exact match in alias
|
|
19
19
|
* 2. Exact match in displayName
|
|
20
|
-
* 3.
|
|
21
|
-
* 4. Prefix match in
|
|
22
|
-
* 5.
|
|
23
|
-
* 6.
|
|
24
|
-
* 7.
|
|
25
|
-
* 8.
|
|
26
|
-
* 9.
|
|
20
|
+
* 3. Exact match in tags
|
|
21
|
+
* 4. Prefix match in alias
|
|
22
|
+
* 5. Prefix match in displayName
|
|
23
|
+
* 6. Prefix match in tags
|
|
24
|
+
* 7. Contains match in alias
|
|
25
|
+
* 8. Contains match in displayName
|
|
26
|
+
* 9. Contains match in tags
|
|
27
|
+
* 10. Teams
|
|
28
|
+
* 11. Description
|
|
29
|
+
*
|
|
27
30
|
*
|
|
28
31
|
* @param apps - Array of apps to search
|
|
29
32
|
* @param searchQuery - Search query string
|
|
@@ -48,31 +51,43 @@ export function searchApps(
|
|
|
48
51
|
const tags = app.tags?.join(' ').toLowerCase() || ''
|
|
49
52
|
const teams = app.teams?.join(' ').toLowerCase() || ''
|
|
50
53
|
|
|
51
|
-
// Check exact matches first
|
|
52
|
-
if (name === normalizedQuery) {
|
|
53
|
-
return { app, match: { field: 'displayName', type: 'exact' } }
|
|
54
|
-
}
|
|
54
|
+
// Check exact matches first - prioritize alias over displayName
|
|
55
55
|
if (alias && alias === normalizedQuery) {
|
|
56
56
|
return { app, match: { field: 'alias', type: 'exact' } }
|
|
57
57
|
}
|
|
58
|
+
if (name === normalizedQuery) {
|
|
59
|
+
return { app, match: { field: 'displayName', type: 'exact' } }
|
|
60
|
+
}
|
|
58
61
|
|
|
59
|
-
// Check
|
|
60
|
-
if (
|
|
61
|
-
return { app, match: { field: '
|
|
62
|
+
// Check exact match in tags (any tag exactly matches query)
|
|
63
|
+
if (app.tags?.some((tag) => tag.toLowerCase() === normalizedQuery)) {
|
|
64
|
+
return { app, match: { field: 'tags', type: 'exact' } }
|
|
62
65
|
}
|
|
66
|
+
|
|
67
|
+
// Check prefix matches - prioritize alias over displayName
|
|
63
68
|
if (alias && alias.startsWith(normalizedQuery)) {
|
|
64
69
|
return { app, match: { field: 'alias', type: 'prefix' } }
|
|
65
70
|
}
|
|
71
|
+
if (name.startsWith(normalizedQuery)) {
|
|
72
|
+
return { app, match: { field: 'displayName', type: 'prefix' } }
|
|
73
|
+
}
|
|
66
74
|
|
|
67
|
-
// Check
|
|
68
|
-
if (
|
|
69
|
-
|
|
75
|
+
// Check tags - prefix match (any tag starts with query)
|
|
76
|
+
if (
|
|
77
|
+
app.tags?.some((tag) => tag.toLowerCase().startsWith(normalizedQuery))
|
|
78
|
+
) {
|
|
79
|
+
return { app, match: { field: 'tags', type: 'prefix' } }
|
|
70
80
|
}
|
|
81
|
+
|
|
82
|
+
// Check contains matches in name/alias - prioritize alias over displayName
|
|
71
83
|
if (alias && alias.includes(normalizedQuery)) {
|
|
72
84
|
return { app, match: { field: 'alias', type: 'contains' } }
|
|
73
85
|
}
|
|
86
|
+
if (name.includes(normalizedQuery)) {
|
|
87
|
+
return { app, match: { field: 'displayName', type: 'contains' } }
|
|
88
|
+
}
|
|
74
89
|
|
|
75
|
-
// Check tags
|
|
90
|
+
// Check tags - contains match
|
|
76
91
|
if (tags.includes(normalizedQuery)) {
|
|
77
92
|
return { app, match: { field: 'tags', type: 'contains' } }
|
|
78
93
|
}
|
|
@@ -97,29 +112,35 @@ export function searchApps(
|
|
|
97
112
|
scoredApps.forEach(({ app, match }) => {
|
|
98
113
|
let score = 0
|
|
99
114
|
|
|
100
|
-
// Exact matches: 0-
|
|
115
|
+
// Exact matches: 0-2 (alias, displayName, tags)
|
|
101
116
|
if (match.type === 'exact') {
|
|
102
|
-
|
|
117
|
+
if (match.field === 'alias') score = 0
|
|
118
|
+
else if (match.field === 'displayName') score = 1
|
|
119
|
+
else if (match.field === 'tags') score = 2
|
|
120
|
+
else score = 999 // Should not happen
|
|
103
121
|
}
|
|
104
|
-
// Prefix matches:
|
|
122
|
+
// Prefix matches: 3-5 (alias, displayName, tags)
|
|
105
123
|
else if (match.type === 'prefix') {
|
|
106
|
-
|
|
124
|
+
if (match.field === 'alias') score = 3
|
|
125
|
+
else if (match.field === 'displayName') score = 4
|
|
126
|
+
else if (match.field === 'tags') score = 5
|
|
127
|
+
else score = 999 // Should not happen
|
|
107
128
|
}
|
|
108
|
-
// Contains in name/alias:
|
|
129
|
+
// Contains in name/alias: 6-7 (alias before displayName)
|
|
109
130
|
else if (match.field === 'displayName' || match.field === 'alias') {
|
|
110
|
-
score = match.field === 'alias' ?
|
|
131
|
+
score = match.field === 'alias' ? 6 : 7
|
|
111
132
|
}
|
|
112
|
-
// Tags:
|
|
133
|
+
// Tags (contains): 8
|
|
113
134
|
else if (match.field === 'tags') {
|
|
114
|
-
score =
|
|
135
|
+
score = 8
|
|
115
136
|
}
|
|
116
|
-
// Teams:
|
|
137
|
+
// Teams: 9
|
|
117
138
|
else if (match.field === 'teams') {
|
|
118
|
-
score =
|
|
139
|
+
score = 9
|
|
119
140
|
}
|
|
120
|
-
// Description:
|
|
141
|
+
// Description: 10
|
|
121
142
|
else {
|
|
122
|
-
score =
|
|
143
|
+
score = 10
|
|
123
144
|
}
|
|
124
145
|
|
|
125
146
|
scoreMap.set(app.id, score)
|