@prenta/admin 2.8.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +6 -6
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/batch-ai-actions.test.js +4 -0
- package/dist/__tests__/components/batch-ai-actions.test.js.map +1 -1
- package/dist/__tests__/lib/batch-wizard.test.js +85 -1
- package/dist/__tests__/lib/batch-wizard.test.js.map +1 -1
- package/dist/__tests__/lib/jobs-service.test.js +19 -1
- package/dist/__tests__/lib/jobs-service.test.js.map +1 -1
- package/dist/__tests__/views/run-with-ai.render.test.d.ts +2 -0
- package/dist/__tests__/views/run-with-ai.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/run-with-ai.render.test.js +711 -0
- package/dist/__tests__/views/run-with-ai.render.test.js.map +1 -0
- package/dist/components/BatchAiActions.d.ts +8 -1
- package/dist/components/BatchAiActions.d.ts.map +1 -1
- package/dist/components/BatchAiActions.js +3 -2
- package/dist/components/BatchAiActions.js.map +1 -1
- package/dist/lib/batch-wizard.d.ts +34 -0
- package/dist/lib/batch-wizard.d.ts.map +1 -1
- package/dist/lib/batch-wizard.js +97 -0
- package/dist/lib/batch-wizard.js.map +1 -1
- package/dist/lib/jobs-service.d.ts +28 -0
- package/dist/lib/jobs-service.d.ts.map +1 -1
- package/dist/lib/jobs-service.js +9 -0
- package/dist/lib/jobs-service.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/CollectionList.d.ts +3 -1
- package/dist/views/CollectionList.d.ts.map +1 -1
- package/dist/views/CollectionList.js +5 -2
- package/dist/views/CollectionList.js.map +1 -1
- package/dist/views/Jobs/DrawerOverview.d.ts +6 -2
- package/dist/views/Jobs/DrawerOverview.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerOverview.js +6 -3
- package/dist/views/Jobs/DrawerOverview.js.map +1 -1
- package/dist/views/Jobs/DrawerResults.d.ts +13 -3
- package/dist/views/Jobs/DrawerResults.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerResults.js +37 -3
- package/dist/views/Jobs/DrawerResults.js.map +1 -1
- package/dist/views/Jobs/JobDrawer.d.ts +4 -1
- package/dist/views/Jobs/JobDrawer.d.ts.map +1 -1
- package/dist/views/Jobs/JobDrawer.js +2 -2
- package/dist/views/Jobs/JobDrawer.js.map +1 -1
- package/dist/views/Jobs/RunWithAi.d.ts +25 -0
- package/dist/views/Jobs/RunWithAi.d.ts.map +1 -0
- package/dist/views/Jobs/RunWithAi.js +46 -0
- package/dist/views/Jobs/RunWithAi.js.map +1 -0
- package/dist/views/Jobs.d.ts +3 -1
- package/dist/views/Jobs.d.ts.map +1 -1
- package/dist/views/Jobs.js +42 -8
- package/dist/views/Jobs.js.map +1 -1
- package/dist/views/MediaBrowser.d.ts +5 -1
- package/dist/views/MediaBrowser.d.ts.map +1 -1
- package/dist/views/MediaBrowser.js +6 -2
- package/dist/views/MediaBrowser.js.map +1 -1
- package/dist/views/Pages/PagesListView.d.ts +5 -1
- package/dist/views/Pages/PagesListView.d.ts.map +1 -1
- package/dist/views/Pages/PagesListView.js +7 -4
- package/dist/views/Pages/PagesListView.js.map +1 -1
- package/dist/views/Posts/PostsListView.d.ts +5 -1
- package/dist/views/Posts/PostsListView.d.ts.map +1 -1
- package/dist/views/Posts/PostsListView.js +7 -4
- package/dist/views/Posts/PostsListView.js.map +1 -1
- package/package.json +3 -3
- package/src/AdminRoot.tsx +20 -4
- package/src/__tests__/components/batch-ai-actions.test.tsx +10 -0
- package/src/__tests__/lib/batch-wizard.test.ts +129 -0
- package/src/__tests__/lib/jobs-service.test.ts +20 -0
- package/src/__tests__/views/run-with-ai.render.test.tsx +832 -0
- package/src/components/BatchAiActions.tsx +15 -2
- package/src/lib/batch-wizard.ts +128 -0
- package/src/lib/jobs-service.ts +35 -0
- package/src/views/CollectionList.tsx +20 -1
- package/src/views/Jobs/DrawerOverview.tsx +16 -3
- package/src/views/Jobs/DrawerResults.tsx +71 -2
- package/src/views/Jobs/JobDrawer.tsx +5 -1
- package/src/views/Jobs/RunWithAi.tsx +89 -0
- package/src/views/Jobs.tsx +58 -10
- package/src/views/MediaBrowser.tsx +20 -1
- package/src/views/Pages/PagesListView.tsx +28 -3
- package/src/views/Posts/PostsListView.tsx +26 -3
package/src/views/Jobs.tsx
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
4
4
|
import { toast } from 'sonner'
|
|
5
|
+
import { parseRouteQuery } from '../router/index.js'
|
|
5
6
|
import { Button } from '../components/ui/Button.js'
|
|
6
7
|
import { PageHeader } from '../components/ui/PageHeader.js'
|
|
7
8
|
import { Segmented } from '../components/ui/Segmented.js'
|
|
9
|
+
import { batchSources, type BatchOperation, type BatchSelection } from '../lib/batch-wizard.js'
|
|
8
10
|
import {
|
|
9
11
|
JOB_FILTERS,
|
|
10
12
|
JOB_TYPES,
|
|
@@ -39,6 +41,8 @@ import { WorkerStrip } from './Jobs/WorkerStrip.js'
|
|
|
39
41
|
|
|
40
42
|
export interface JobsProps {
|
|
41
43
|
onNavigate: (path: string) => void
|
|
44
|
+
/** Router path with its query. `?job=<id>` opens that job's drawer once the list has it. */
|
|
45
|
+
currentPath?: string
|
|
42
46
|
/**
|
|
43
47
|
* The signed-in user's role. It decides which job actions show: viewers
|
|
44
48
|
* get none (the server refuses them anyway). Without one, none show.
|
|
@@ -52,6 +56,17 @@ export interface JobsProps {
|
|
|
52
56
|
|
|
53
57
|
const FILTER_OPTIONS = JOB_FILTERS.map(({ id, label }) => ({ id, label }))
|
|
54
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The open wizard: from the header with nothing picked, or from a scan's
|
|
61
|
+
* "Fix with AI" with that issue's documents and operation (P-21).
|
|
62
|
+
*/
|
|
63
|
+
interface WizardState {
|
|
64
|
+
selection: BatchSelection | null
|
|
65
|
+
operation?: BatchOperation
|
|
66
|
+
/** Opened from the drawer, which closes once the job is queued. */
|
|
67
|
+
fromDrawer: boolean
|
|
68
|
+
}
|
|
69
|
+
|
|
55
70
|
/** What a run, retry or cancel came to, for a toast and the drawer's live region. */
|
|
56
71
|
interface Outcome {
|
|
57
72
|
text: string
|
|
@@ -88,7 +103,7 @@ function LiveButton({ live, onToggle }: { live: boolean; onToggle: () => void })
|
|
|
88
103
|
* Opening a job sets `open` and shows its drawer (P-18). New batch AI job
|
|
89
104
|
* opens the wizard (P-20); a queued job is added at the top of the list.
|
|
90
105
|
*/
|
|
91
|
-
export function Jobs({ onNavigate, role = null, userId = null, config }: JobsProps) {
|
|
106
|
+
export function Jobs({ onNavigate, currentPath, role = null, userId = null, config }: JobsProps) {
|
|
92
107
|
const [live, setLive] = useState(true)
|
|
93
108
|
const visible = usePageVisible()
|
|
94
109
|
const feed = useJobsFeed(live && visible)
|
|
@@ -98,7 +113,7 @@ export function Jobs({ onNavigate, role = null, userId = null, config }: JobsPro
|
|
|
98
113
|
const [open, setOpen] = useState<{ id: string; tab: JobDrawerTab } | null>(null)
|
|
99
114
|
const [cancelTarget, setCancelTarget] = useState<JobRow | null>(null)
|
|
100
115
|
const cancelledId = useRef<string | null>(null)
|
|
101
|
-
const [wizard, setWizard] = useState(
|
|
116
|
+
const [wizard, setWizard] = useState<WizardState | null>(null)
|
|
102
117
|
const [retryingId, setRetryingId] = useState<string | null>(null)
|
|
103
118
|
/** Jobs with a retry request out, so a second click can't post another. */
|
|
104
119
|
const retrying = useRef(new Set<string>())
|
|
@@ -113,6 +128,24 @@ export function Jobs({ onNavigate, role = null, userId = null, config }: JobsPro
|
|
|
113
128
|
/** A cancel's outcome, held until its dialog has gone (`onClosed`). */
|
|
114
129
|
const cancelOutcome = useRef<Outcome | null>(null)
|
|
115
130
|
const viewer = useMemo<JobViewer>(() => ({ role, userId }), [role, userId])
|
|
131
|
+
const sources = useMemo(() => batchSources(config), [config])
|
|
132
|
+
|
|
133
|
+
// A link to a job (`/jobs?job=<id>`, the toast after "Run with AI…"): open
|
|
134
|
+
// its drawer once the list has loaded. Each value is handled once, so
|
|
135
|
+
// closing the drawer sticks.
|
|
136
|
+
const linkedJob = useMemo(() => {
|
|
137
|
+
const query = currentPath ?? (typeof window !== 'undefined' ? window.location.search : '')
|
|
138
|
+
return parseRouteQuery(query).get('job')
|
|
139
|
+
}, [currentPath])
|
|
140
|
+
const handledLink = useRef<string | null>(null)
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!linkedJob || handledLink.current === linkedJob || feed.status !== 'ready') return
|
|
143
|
+
handledLink.current = linkedJob
|
|
144
|
+
if (feed.jobs.some((job) => job.id === linkedJob)) {
|
|
145
|
+
setOpen({ id: linkedJob, tab: null })
|
|
146
|
+
setNotice(null)
|
|
147
|
+
}
|
|
148
|
+
}, [linkedJob, feed.status, feed.jobs])
|
|
116
149
|
|
|
117
150
|
useEffect(() => {
|
|
118
151
|
const id = refocus.current
|
|
@@ -252,7 +285,7 @@ export function Jobs({ onNavigate, role = null, userId = null, config }: JobsPro
|
|
|
252
285
|
<Button
|
|
253
286
|
data-jobs-new=""
|
|
254
287
|
leftIcon={<JobIcons.spark size={14} />}
|
|
255
|
-
onClick={() => setWizard(
|
|
288
|
+
onClick={() => setWizard({ selection: null, fromDrawer: false })}
|
|
256
289
|
>
|
|
257
290
|
New batch AI job
|
|
258
291
|
</Button>
|
|
@@ -384,26 +417,41 @@ export function Jobs({ onNavigate, role = null, userId = null, config }: JobsPro
|
|
|
384
417
|
}}
|
|
385
418
|
onReload={() => void reload()}
|
|
386
419
|
onNavigate={onNavigate}
|
|
420
|
+
fixWithAi={
|
|
421
|
+
canActOnJobs(viewer)
|
|
422
|
+
? {
|
|
423
|
+
sources,
|
|
424
|
+
onFix: (selection, operation) =>
|
|
425
|
+
setWizard({ selection, operation, fromDrawer: true }),
|
|
426
|
+
}
|
|
427
|
+
: undefined
|
|
428
|
+
}
|
|
387
429
|
/>
|
|
388
430
|
) : null}
|
|
389
431
|
{wizard ? (
|
|
390
432
|
<NewBatchJob
|
|
391
433
|
role={role}
|
|
392
434
|
config={config}
|
|
393
|
-
|
|
435
|
+
selection={wizard.selection}
|
|
436
|
+
operation={wizard.operation}
|
|
437
|
+
onClose={() => setWizard(null)}
|
|
394
438
|
onQueued={(job) => {
|
|
395
439
|
upsert(job)
|
|
396
|
-
|
|
440
|
+
if (wizard.fromDrawer) {
|
|
441
|
+
setOpen(null)
|
|
442
|
+
setNotice(null)
|
|
443
|
+
}
|
|
444
|
+
setWizard(null)
|
|
397
445
|
setFilter('all')
|
|
398
446
|
setType('all')
|
|
399
447
|
toast(`“${job.title}” queued · ${jobTotal(job)} documents`)
|
|
400
448
|
void reload()
|
|
401
449
|
}}
|
|
402
|
-
onFocusFallback={(job) =>
|
|
403
|
-
job
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
450
|
+
onFocusFallback={(job) => {
|
|
451
|
+
if (job) focusJobRow(job.id)
|
|
452
|
+
else if (open) focusJobDrawer()
|
|
453
|
+
else document.querySelector<HTMLElement>('[data-jobs-new]')?.focus()
|
|
454
|
+
}}
|
|
407
455
|
/>
|
|
408
456
|
) : null}
|
|
409
457
|
<CancelJobDialog
|
|
@@ -38,6 +38,8 @@ import { useSheetFocus } from '../lib/sheet-focus.js'
|
|
|
38
38
|
import { StatusBadge } from '../components/ui/StatusBadge.js'
|
|
39
39
|
import { CountChip } from '../components/ui/CountChip.js'
|
|
40
40
|
import { hasLowQualityAlt, MediaSeoAudit, type MediaSeoAuditItem } from './MediaSeoAudit.js'
|
|
41
|
+
import { pickedImages } from '../lib/batch-wizard.js'
|
|
42
|
+
import { RunWithAi } from './Jobs/RunWithAi.js'
|
|
41
43
|
|
|
42
44
|
interface MediaItem {
|
|
43
45
|
id: number | string
|
|
@@ -111,6 +113,10 @@ type MediaSortKey = 'name' | 'type' | 'size' | 'date'
|
|
|
111
113
|
|
|
112
114
|
export interface MediaBrowserProps {
|
|
113
115
|
onNavigate?: (path: string) => void
|
|
116
|
+
/** The signed-in user's role: "Run with AI…" shows to the roles that may queue jobs. */
|
|
117
|
+
role?: string | null
|
|
118
|
+
/** The CMS config, for the batch wizard. */
|
|
119
|
+
config?: unknown
|
|
114
120
|
/** Router path including the query string. `?selected=<mediaId>` (written by
|
|
115
121
|
* the command palette) opens that item's detail panel once the list loads. */
|
|
116
122
|
currentPath?: string
|
|
@@ -152,7 +158,7 @@ function buildMediaApiUrl(folderSel: FolderSelection): string {
|
|
|
152
158
|
return `${base}&folderId=${folderSel.folderId}`
|
|
153
159
|
}
|
|
154
160
|
|
|
155
|
-
export function MediaBrowser({ onNavigate, currentPath }: MediaBrowserProps) {
|
|
161
|
+
export function MediaBrowser({ onNavigate, currentPath, role, config }: MediaBrowserProps) {
|
|
156
162
|
const [folderSel, setFolderSel] = useState<FolderSelection>({ type: 'smart', smart: 'all' })
|
|
157
163
|
const [sidebarOpen, setSidebarOpen] = useState(true)
|
|
158
164
|
// Below 769px the folder tree stacks above the grid, so it starts closed
|
|
@@ -786,6 +792,19 @@ export function MediaBrowser({ onNavigate, currentPath }: MediaBrowserProps) {
|
|
|
786
792
|
{selectedMedia.length} file{selectedMedia.length !== 1 ? 's' : ''} selected
|
|
787
793
|
</span>
|
|
788
794
|
<div className="flex items-center gap-2">
|
|
795
|
+
{onNavigate ? (
|
|
796
|
+
<RunWithAi
|
|
797
|
+
pick={pickedImages(
|
|
798
|
+
mediaItems
|
|
799
|
+
.filter((item) => selectedMedia.includes(item.id) && isImageMedia(item))
|
|
800
|
+
.map((item) => String(item.id)),
|
|
801
|
+
)}
|
|
802
|
+
role={role}
|
|
803
|
+
config={config}
|
|
804
|
+
onNavigate={onNavigate}
|
|
805
|
+
className="border-input bg-card hover:bg-muted rounded-lg border px-3 py-1.5 text-sm transition-colors"
|
|
806
|
+
/>
|
|
807
|
+
) : null}
|
|
789
808
|
<button
|
|
790
809
|
onClick={async () => {
|
|
791
810
|
for (const id of selectedMedia) await deleteMedia(id)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
4
4
|
import {
|
|
5
5
|
Check,
|
|
6
6
|
ChevronDown,
|
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
} from 'lucide-react'
|
|
21
21
|
import { toast } from 'sonner'
|
|
22
22
|
import { BatchAiActions } from '../../components/BatchAiActions.js'
|
|
23
|
+
import { pickedDocuments } from '../../lib/batch-wizard.js'
|
|
24
|
+
import { RunWithAi } from '../Jobs/RunWithAi.js'
|
|
23
25
|
import { useVirtualWindow, VirtualTablePadding } from '../../components/virtual-window.js'
|
|
24
26
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
25
27
|
import { adminPortalContainer } from '../../lib/portal-container.js'
|
|
@@ -77,6 +79,10 @@ import { PagesTreeTable } from './PagesTreeTable.js'
|
|
|
77
79
|
|
|
78
80
|
interface PagesListViewProps {
|
|
79
81
|
onNavigate: (path: string) => void
|
|
82
|
+
/** The signed-in user's role: "Run with AI…" shows to the roles that may queue jobs. */
|
|
83
|
+
role?: string | null
|
|
84
|
+
/** The CMS config, for the batch wizard's content labels. */
|
|
85
|
+
config?: unknown
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
type SortBy = 'title' | 'author' | 'status' | 'modified' | 'seo'
|
|
@@ -127,7 +133,7 @@ function readStoredHiddenColumns(): Set<ToggleableColumn> {
|
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
|
|
130
|
-
export function PagesListView({ onNavigate }: PagesListViewProps) {
|
|
136
|
+
export function PagesListView({ onNavigate, role, config }: PagesListViewProps) {
|
|
131
137
|
const [search, setSearch] = useState('')
|
|
132
138
|
const [debouncedSearch, setDebouncedSearch] = useState('')
|
|
133
139
|
const [status, setStatus] = useState<PageStatus | 'all'>('all')
|
|
@@ -696,6 +702,17 @@ export function PagesListView({ onNavigate }: PagesListViewProps) {
|
|
|
696
702
|
onAddTag={(slug) => runBulkTag(slug, 'add')}
|
|
697
703
|
documents={selectedPages.map((page) => ({ collection: 'pages', id: page.id }))}
|
|
698
704
|
onQueued={() => setSelected(new Set())}
|
|
705
|
+
runWithAi={
|
|
706
|
+
<RunWithAi
|
|
707
|
+
pick={pickedDocuments(
|
|
708
|
+
selectedPages.map((page) => ({ collection: 'pages', id: page.id })),
|
|
709
|
+
)}
|
|
710
|
+
role={role}
|
|
711
|
+
config={config}
|
|
712
|
+
onNavigate={onNavigate}
|
|
713
|
+
className={BULK_BUTTON}
|
|
714
|
+
/>
|
|
715
|
+
}
|
|
699
716
|
onRemoveTag={(slug) => runBulkTag(slug, 'remove')}
|
|
700
717
|
onDelete={() => setPendingDelete(true)}
|
|
701
718
|
deletableCount={deletablePages.length}
|
|
@@ -1210,6 +1227,9 @@ function dotFor(color: string): string {
|
|
|
1210
1227
|
return map[color] ?? 'bg-muted-foreground'
|
|
1211
1228
|
}
|
|
1212
1229
|
|
|
1230
|
+
const BULK_BUTTON =
|
|
1231
|
+
'rounded-md px-2 py-1 text-sm text-[var(--txt)] transition-colors hover:bg-[var(--acc-l)]'
|
|
1232
|
+
|
|
1213
1233
|
function BulkActionBar({
|
|
1214
1234
|
count,
|
|
1215
1235
|
tags,
|
|
@@ -1223,6 +1243,7 @@ function BulkActionBar({
|
|
|
1223
1243
|
onDelete,
|
|
1224
1244
|
documents,
|
|
1225
1245
|
onQueued,
|
|
1246
|
+
runWithAi,
|
|
1226
1247
|
}: {
|
|
1227
1248
|
count: number
|
|
1228
1249
|
tags: PageTag[]
|
|
@@ -1236,6 +1257,8 @@ function BulkActionBar({
|
|
|
1236
1257
|
onDelete: () => void
|
|
1237
1258
|
documents: Array<{ collection: string; id: string }>
|
|
1238
1259
|
onQueued: () => void
|
|
1260
|
+
/** "Run with AI…" (P-21), which replaces the Meta descriptions and Summaries buttons. */
|
|
1261
|
+
runWithAi: ReactNode
|
|
1239
1262
|
}) {
|
|
1240
1263
|
return (
|
|
1241
1264
|
<div className="border-primary/30 bg-primary/5 flex flex-wrap items-center gap-2 rounded-lg border px-4 py-2">
|
|
@@ -1257,10 +1280,12 @@ function BulkActionBar({
|
|
|
1257
1280
|
</button>
|
|
1258
1281
|
<TagMenu label="Add tag" tags={tags} onPick={onAddTag} />
|
|
1259
1282
|
<TagMenu label="Remove tag" tags={tags} onPick={onRemoveTag} />
|
|
1283
|
+
{runWithAi}
|
|
1260
1284
|
<BatchAiActions
|
|
1261
1285
|
documents={documents}
|
|
1262
1286
|
onQueued={onQueued}
|
|
1263
|
-
|
|
1287
|
+
operations={['alt-text']}
|
|
1288
|
+
buttonClassName={BULK_BUTTON}
|
|
1264
1289
|
/>
|
|
1265
1290
|
<button
|
|
1266
1291
|
type="button"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
4
4
|
import {
|
|
5
5
|
ChevronDown,
|
|
6
6
|
ChevronLeft,
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
} from 'lucide-react'
|
|
18
18
|
import { toast } from 'sonner'
|
|
19
19
|
import { BatchAiActions } from '../../components/BatchAiActions.js'
|
|
20
|
+
import { pickedDocuments } from '../../lib/batch-wizard.js'
|
|
21
|
+
import { RunWithAi } from '../Jobs/RunWithAi.js'
|
|
20
22
|
import { useVirtualWindow, VirtualTablePadding } from '../../components/virtual-window.js'
|
|
21
23
|
import {
|
|
22
24
|
bulkDeletePosts,
|
|
@@ -63,6 +65,10 @@ import { CardListControls, type CardSortOption } from '../../components/ui/CardL
|
|
|
63
65
|
|
|
64
66
|
interface PostsListViewProps {
|
|
65
67
|
onNavigate: (path: string) => void
|
|
68
|
+
/** The signed-in user's role: "Run with AI…" shows to the roles that may queue jobs. */
|
|
69
|
+
role?: string | null
|
|
70
|
+
/** The CMS config, for the batch wizard's content labels. */
|
|
71
|
+
config?: unknown
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
type SortBy = 'title' | 'type' | 'author' | 'status' | 'date' | 'seo'
|
|
@@ -91,7 +97,7 @@ const POST_SORT_OPTIONS: CardSortOption<SortBy>[] = [
|
|
|
91
97
|
*/
|
|
92
98
|
const TABLE_MIN_WIDTH = 810 + 240
|
|
93
99
|
|
|
94
|
-
export function PostsListView({ onNavigate }: PostsListViewProps) {
|
|
100
|
+
export function PostsListView({ onNavigate, role, config }: PostsListViewProps) {
|
|
95
101
|
const [activeType, setActiveType] = useState<string>('all')
|
|
96
102
|
const [search, setSearch] = useState('')
|
|
97
103
|
const [debouncedSearch, setDebouncedSearch] = useState('')
|
|
@@ -375,6 +381,17 @@ export function PostsListView({ onNavigate }: PostsListViewProps) {
|
|
|
375
381
|
onDelete={() => setPendingBulk('delete')}
|
|
376
382
|
documents={selectedPosts.map((post) => ({ collection: post.postTypeId, id: post.id }))}
|
|
377
383
|
onQueued={() => setSelected(new Set())}
|
|
384
|
+
runWithAi={
|
|
385
|
+
<RunWithAi
|
|
386
|
+
pick={pickedDocuments(
|
|
387
|
+
selectedPosts.map((post) => ({ collection: post.postTypeId, id: post.id })),
|
|
388
|
+
)}
|
|
389
|
+
role={role}
|
|
390
|
+
config={config}
|
|
391
|
+
onNavigate={onNavigate}
|
|
392
|
+
className={BULK_BUTTON}
|
|
393
|
+
/>
|
|
394
|
+
}
|
|
378
395
|
/>
|
|
379
396
|
)}
|
|
380
397
|
|
|
@@ -821,6 +838,8 @@ function FilterSelect({
|
|
|
821
838
|
)
|
|
822
839
|
}
|
|
823
840
|
|
|
841
|
+
const BULK_BUTTON = 'text-foreground hover:bg-accent rounded-md px-2 py-1 text-sm transition-colors'
|
|
842
|
+
|
|
824
843
|
function BulkActionBar({
|
|
825
844
|
count,
|
|
826
845
|
onClear,
|
|
@@ -829,6 +848,7 @@ function BulkActionBar({
|
|
|
829
848
|
onDelete,
|
|
830
849
|
documents,
|
|
831
850
|
onQueued,
|
|
851
|
+
runWithAi,
|
|
832
852
|
}: {
|
|
833
853
|
count: number
|
|
834
854
|
onClear: () => void
|
|
@@ -837,6 +857,8 @@ function BulkActionBar({
|
|
|
837
857
|
onDelete: () => void
|
|
838
858
|
documents: Array<{ collection: string; id: string }>
|
|
839
859
|
onQueued: () => void
|
|
860
|
+
/** "Run with AI…" (P-21), which replaces the Meta descriptions and Summaries buttons. */
|
|
861
|
+
runWithAi: ReactNode
|
|
840
862
|
}) {
|
|
841
863
|
return (
|
|
842
864
|
<div className="border-primary/30 bg-primary/5 flex items-center gap-2 rounded-lg border px-4 py-2">
|
|
@@ -856,7 +878,8 @@ function BulkActionBar({
|
|
|
856
878
|
>
|
|
857
879
|
Move to draft
|
|
858
880
|
</button>
|
|
859
|
-
|
|
881
|
+
{runWithAi}
|
|
882
|
+
<BatchAiActions documents={documents} onQueued={onQueued} operations={['alt-text']} />
|
|
860
883
|
<button
|
|
861
884
|
type="button"
|
|
862
885
|
onClick={onDelete}
|