@prenta/admin 2.14.1 → 2.14.3
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 +12 -0
- package/design-system/tokens.css +12 -2
- package/design-system/tokens.json +17 -2
- package/design-system/tokens.scss +3 -2
- package/design-system/tokens.tailwind.cjs +1 -0
- package/dist/__tests__/styles/qa-contrast.test.js +16 -9
- package/dist/__tests__/styles/qa-contrast.test.js.map +1 -1
- package/dist/__tests__/views/form-entries.render.test.js +129 -7
- package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
- package/dist/__tests__/views/inbox-format.test.js +1 -1
- package/dist/__tests__/views/inbox-format.test.js.map +1 -1
- package/dist/components/CoauthorResultPopover.js +1 -1
- package/dist/components/CoauthorResultPopover.js.map +1 -1
- package/dist/components/CommentSidePanel.js +3 -3
- package/dist/components/CommentSidePanel.js.map +1 -1
- package/dist/components/forms/BlocklistDialog.d.ts.map +1 -1
- package/dist/components/forms/BlocklistDialog.js +2 -1
- package/dist/components/forms/BlocklistDialog.js.map +1 -1
- package/dist/components/forms/FormsListTable.d.ts.map +1 -1
- package/dist/components/forms/FormsListTable.js +6 -2
- package/dist/components/forms/FormsListTable.js.map +1 -1
- package/dist/components/forms/primitives.js +1 -1
- package/dist/components/seo/primitives.js +1 -1
- package/dist/components/ui/AuthorAvatar.js +1 -1
- package/dist/components/ui/AuthorAvatar.js.map +1 -1
- package/dist/components/ui/EmptyState.js +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/Forms.d.ts.map +1 -1
- package/dist/views/Forms.js +2 -1
- package/dist/views/Forms.js.map +1 -1
- package/dist/views/Login.d.ts.map +1 -1
- package/dist/views/Login.js +3 -3
- package/dist/views/Login.js.map +1 -1
- package/dist/views/MediaBrowser.js +2 -2
- package/dist/views/ResetPassword.js +1 -1
- package/dist/views/ResetPassword.js.map +1 -1
- package/dist/views/SetupWizard.js +1 -1
- package/dist/views/SetupWizard.js.map +1 -1
- package/dist/views/Users.d.ts.map +1 -1
- package/dist/views/Users.js +8 -27
- package/dist/views/Users.js.map +1 -1
- package/dist/views/entries/EntriesInbox.d.ts.map +1 -1
- package/dist/views/entries/EntriesInbox.js +87 -23
- package/dist/views/entries/EntriesInbox.js.map +1 -1
- package/dist/views/entries/inbox-format.d.ts +1 -1
- package/dist/views/entries/inbox-format.d.ts.map +1 -1
- package/dist/views/entries/inbox-format.js +3 -4
- package/dist/views/entries/inbox-format.js.map +1 -1
- package/dist/views/page-editor/sections/SectionRenderer.js +1 -1
- package/dist/views/page-editor/sections/SectionRenderer.js.map +1 -1
- package/dist/views/settings/BrandVoiceCard.d.ts.map +1 -1
- package/dist/views/settings/BrandVoiceCard.js +1 -1
- package/dist/views/settings/BrandVoiceCard.js.map +1 -1
- package/dist/views/settings/UpdatesTab.js +1 -1
- package/dist/views/settings/UpdatesTab.js.map +1 -1
- package/dist/views/settings/brand-voice/BrandVoiceRulesSections.d.ts.map +1 -1
- package/dist/views/settings/brand-voice/BrandVoiceRulesSections.js +5 -4
- package/dist/views/settings/brand-voice/BrandVoiceRulesSections.js.map +1 -1
- package/package.json +7 -7
- package/src/__tests__/styles/qa-contrast.test.ts +30 -8
- package/src/__tests__/views/form-entries.render.test.tsx +160 -7
- package/src/__tests__/views/inbox-format.test.ts +1 -1
- package/src/components/CoauthorResultPopover.tsx +1 -1
- package/src/components/CommentSidePanel.tsx +3 -3
- package/src/components/forms/BlocklistDialog.tsx +3 -2
- package/src/components/forms/FormsListTable.tsx +9 -3
- package/src/components/forms/primitives.tsx +1 -1
- package/src/components/seo/primitives.tsx +1 -1
- package/src/components/ui/AuthorAvatar.tsx +1 -1
- package/src/components/ui/EmptyState.tsx +1 -1
- package/src/styles/prenta-tokens.css +12 -2
- package/src/views/Forms.tsx +3 -3
- package/src/views/Login.tsx +5 -4
- package/src/views/MediaBrowser.tsx +4 -4
- package/src/views/ResetPassword.tsx +2 -2
- package/src/views/SetupWizard.tsx +2 -2
- package/src/views/Users.tsx +21 -38
- package/src/views/entries/EntriesInbox.tsx +126 -59
- package/src/views/entries/inbox-format.ts +3 -6
- package/src/views/page-editor/sections/SectionRenderer.tsx +2 -2
- package/src/views/settings/BrandVoiceCard.tsx +1 -0
- package/src/views/settings/UpdatesTab.tsx +1 -1
- package/src/views/settings/brand-voice/BrandVoiceRulesSections.tsx +26 -4
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { adminPortalContainer } from '../../lib/portal-container.js'
|
|
4
|
+
|
|
3
5
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
4
6
|
import * as Dialog from '@radix-ui/react-dialog'
|
|
5
7
|
import { Download, Plus, Search, Trash2, Upload, X } from 'lucide-react'
|
|
@@ -256,8 +258,7 @@ export function BlocklistDialog({
|
|
|
256
258
|
|
|
257
259
|
return (
|
|
258
260
|
<Dialog.Root open={open} onOpenChange={(next) => !next && onClose()}>
|
|
259
|
-
<Dialog.Portal>
|
|
260
|
-
{/* Portaled outside .prenta-admin (--txt undefined there); bg-black/50 as in Modal. */}
|
|
261
|
+
<Dialog.Portal container={adminPortalContainer()}>
|
|
261
262
|
<Dialog.Overlay className="fixed inset-0 z-[300] bg-black/50" />
|
|
262
263
|
<Dialog.Content
|
|
263
264
|
aria-describedby="bl-desc"
|
|
@@ -14,7 +14,8 @@ import { adminPortalContainer } from '../../lib/portal-container.js'
|
|
|
14
14
|
import type { FormListItem } from '../../lib/forms-service.js'
|
|
15
15
|
import { FieldTypeBadge, FormStatusBadge } from './primitives.js'
|
|
16
16
|
|
|
17
|
-
const TILE_TONES = ['
|
|
17
|
+
const TILE_TONES = ['acc', 'info', 'suc', 'warn', 'tag-orange']
|
|
18
|
+
const TILE_SURFACES = ['acc-l', 'info-l', 'suc-l', 'warn-l', 'tag-orange-soft']
|
|
18
19
|
|
|
19
20
|
const ROW_GRID =
|
|
20
21
|
'grid grid-cols-[minmax(220px,1.5fr)_minmax(170px,1fr)_minmax(170px,1fr)_minmax(150px,.9fr)_92px_44px] [grid-template-areas:"id_fields_ent_notif_st_chev"] items-center gap-4 ' +
|
|
@@ -151,8 +152,13 @@ export function FormsListTable({
|
|
|
151
152
|
className={`flex min-w-0 items-center gap-3 [grid-area:id] ${archived ? 'opacity-60' : ''}`}
|
|
152
153
|
>
|
|
153
154
|
<span
|
|
154
|
-
style={
|
|
155
|
-
|
|
155
|
+
style={
|
|
156
|
+
{
|
|
157
|
+
'--t': `var(--${tone})`,
|
|
158
|
+
'--t-bg': `var(--${TILE_SURFACES[index % TILE_SURFACES.length]})`,
|
|
159
|
+
} as CSSProperties
|
|
160
|
+
}
|
|
161
|
+
className="rounded-10 text-sm2 flex h-[38px] w-[38px] shrink-0 items-center justify-center border border-[color-mix(in_srgb,var(--t)_22%,transparent)] bg-[var(--t-bg)] font-bold tracking-[-0.3px] text-[var(--t)]"
|
|
156
162
|
aria-hidden="true"
|
|
157
163
|
>
|
|
158
164
|
{formInitials(form.name)}
|
|
@@ -118,7 +118,7 @@ export function FormsEmptyState({
|
|
|
118
118
|
{icon}
|
|
119
119
|
</div>
|
|
120
120
|
)}
|
|
121
|
-
<
|
|
121
|
+
<h2 className="text-foreground text-base font-medium">{title}</h2>
|
|
122
122
|
{description && <p className="text-muted-foreground mt-1 max-w-md text-sm">{description}</p>}
|
|
123
123
|
{action && <div className="mt-4">{action}</div>}
|
|
124
124
|
</div>
|
|
@@ -234,7 +234,7 @@ export function SeoEmptyState({
|
|
|
234
234
|
{icon}
|
|
235
235
|
</div>
|
|
236
236
|
)}
|
|
237
|
-
<
|
|
237
|
+
<h2 className="text-foreground text-base font-medium">{title}</h2>
|
|
238
238
|
{description && <p className="text-muted-foreground mt-1 max-w-md text-sm">{description}</p>}
|
|
239
239
|
{action && <div className="mt-4">{action}</div>}
|
|
240
240
|
</div>
|
|
@@ -56,7 +56,7 @@ export function AuthorAvatar({
|
|
|
56
56
|
return (
|
|
57
57
|
<span
|
|
58
58
|
aria-hidden
|
|
59
|
-
className={`inline-flex shrink-0 items-center justify-center rounded-full font-medium text-
|
|
59
|
+
className={`inline-flex shrink-0 items-center justify-center rounded-full font-medium text-[var(--on-avatar)] ${className}`}
|
|
60
60
|
style={{
|
|
61
61
|
width: size,
|
|
62
62
|
height: size,
|
|
@@ -13,7 +13,7 @@ export function EmptyState({ icon, title, description, actionLabel, onAction }:
|
|
|
13
13
|
return (
|
|
14
14
|
<div className="flex flex-col items-center justify-center py-16 text-center">
|
|
15
15
|
{icon && <div className="mb-4 text-[var(--muted-foreground)]">{icon}</div>}
|
|
16
|
-
<
|
|
16
|
+
<h2 className="text-lg font-medium">{title}</h2>
|
|
17
17
|
{description && (
|
|
18
18
|
<p className="mt-1 max-w-sm text-sm text-[var(--muted-foreground)]">{description}</p>
|
|
19
19
|
)}
|
|
@@ -87,6 +87,8 @@
|
|
|
87
87
|
--tag-gray-soft: #f1f5f9;
|
|
88
88
|
|
|
89
89
|
/* Avatars */
|
|
90
|
+
/* Text on fixed avatar fills. Unlike --on-acc, stays light in every theme. */
|
|
91
|
+
--on-avatar: #ffffff;
|
|
90
92
|
--avatar-1: #2f5bea;
|
|
91
93
|
--avatar-2: #0e7490;
|
|
92
94
|
--avatar-3: #047857;
|
|
@@ -135,7 +137,11 @@
|
|
|
135
137
|
--site-bg: #ffffff;
|
|
136
138
|
--site-txt: #16181d;
|
|
137
139
|
--site-sub: #50555f;
|
|
138
|
-
|
|
140
|
+
/*
|
|
141
|
+
* Muted preview text: clears 4.5:1 on site-bg and site-alt. Handoff value:
|
|
142
|
+
* #8a8f99 — deliberately overridden.
|
|
143
|
+
*/
|
|
144
|
+
--site-muted: #676c76;
|
|
139
145
|
--site-bdr: #e3e5ea;
|
|
140
146
|
--site-alt: #f4f5f7;
|
|
141
147
|
--site-alt2: #eef0f3;
|
|
@@ -343,7 +349,11 @@
|
|
|
343
349
|
--tag-orange-soft: #431407;
|
|
344
350
|
--tag-red: #fb7185;
|
|
345
351
|
--tag-red-soft: #4c0519;
|
|
346
|
-
|
|
352
|
+
/*
|
|
353
|
+
* Blue label text: clears 4.5:1 on tag-blue-soft in Graphite. Handoff value:
|
|
354
|
+
* #60a5fa — deliberately overridden.
|
|
355
|
+
*/
|
|
356
|
+
--tag-blue: #93c5fd;
|
|
347
357
|
--tag-blue-soft: #1e3a8a;
|
|
348
358
|
--tag-pink: #f472b6;
|
|
349
359
|
--tag-pink-soft: #500724;
|
package/src/views/Forms.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { adminPortalContainer } from '../lib/portal-container.js'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Forms list (`/forms`, kit `Forms.html`, SPEC §1): summary chips, search,
|
|
5
7
|
* status segments with counts, a sort select, and the `.fl` row list. The
|
|
@@ -414,9 +416,7 @@ function NewFormDialog({
|
|
|
414
416
|
|
|
415
417
|
return (
|
|
416
418
|
<Dialog.Root open={open} onOpenChange={(next) => !next && onClose()}>
|
|
417
|
-
<Dialog.Portal>
|
|
418
|
-
{/* Portals render outside .prenta-admin, where --scrim/--txt are
|
|
419
|
-
undefined; same bg-black/50 as the shared Modal primitive. */}
|
|
419
|
+
<Dialog.Portal container={adminPortalContainer()}>
|
|
420
420
|
<Dialog.Overlay className="fixed inset-0 z-[300] bg-black/50" />
|
|
421
421
|
<Dialog.Content className="border-bdr bg-card text-txt shadow-shd2 fixed top-1/2 left-1/2 z-[301] w-[min(440px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 rounded-[14px] border p-5">
|
|
422
422
|
<div className="mb-4 flex items-start justify-between gap-3">
|
package/src/views/Login.tsx
CHANGED
|
@@ -407,7 +407,7 @@ export function Login({
|
|
|
407
407
|
const showBrandName = !effectiveLogo && isBranded
|
|
408
408
|
|
|
409
409
|
return (
|
|
410
|
-
<
|
|
410
|
+
<main className="bg-muted flex min-h-screen items-center justify-center px-4">
|
|
411
411
|
<div className="w-full max-w-md">
|
|
412
412
|
<div className="mb-8 text-center">
|
|
413
413
|
{showLogo &&
|
|
@@ -423,6 +423,7 @@ export function Login({
|
|
|
423
423
|
) : (
|
|
424
424
|
<PrentaBrandLogo className="mx-auto mb-4 h-14 w-auto" />
|
|
425
425
|
))}
|
|
426
|
+
{!showBrandName && <h1 className="sr-only">Sign in</h1>}
|
|
426
427
|
{showBrandName && <h1 className="text-foreground text-2xl font-medium">{brandName}</h1>}
|
|
427
428
|
<p className="text-muted-foreground mt-2">{brandTagline}</p>
|
|
428
429
|
</div>
|
|
@@ -587,8 +588,8 @@ export function Login({
|
|
|
587
588
|
<button
|
|
588
589
|
type="button"
|
|
589
590
|
onClick={() => setShowPassword(!showPassword)}
|
|
590
|
-
|
|
591
|
-
|
|
591
|
+
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
|
592
|
+
className="text-muted-foreground hover:text-foreground absolute top-1/2 right-2 flex h-6 w-6 -translate-y-1/2 items-center justify-center"
|
|
592
593
|
>
|
|
593
594
|
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
|
594
595
|
</button>
|
|
@@ -642,6 +643,6 @@ export function Login({
|
|
|
642
643
|
</form>
|
|
643
644
|
)}
|
|
644
645
|
</div>
|
|
645
|
-
</
|
|
646
|
+
</main>
|
|
646
647
|
)
|
|
647
648
|
}
|
|
@@ -1072,13 +1072,13 @@ export function MediaBrowser({ onNavigate, currentPath, role, config }: MediaBro
|
|
|
1072
1072
|
<div className="bg-muted mb-4 flex h-12 w-12 items-center justify-center rounded-full">
|
|
1073
1073
|
<ImageIcon className="text-muted-foreground h-6 w-6" />
|
|
1074
1074
|
</div>
|
|
1075
|
-
<
|
|
1075
|
+
<h2 className="text-foreground mb-1 text-sm font-medium">
|
|
1076
1076
|
{folderSel.type === 'smart' && folderSel.smart === 'uncategorized'
|
|
1077
1077
|
? 'No uncategorized media'
|
|
1078
1078
|
: folderSel.type === 'folder'
|
|
1079
1079
|
? 'No media in this folder'
|
|
1080
1080
|
: 'No media yet'}
|
|
1081
|
-
</
|
|
1081
|
+
</h2>
|
|
1082
1082
|
<p className="text-muted-foreground text-sm">
|
|
1083
1083
|
Upload your first file to get started.
|
|
1084
1084
|
</p>
|
|
@@ -1348,9 +1348,9 @@ export function MediaBrowser({ onNavigate, currentPath, role, config }: MediaBro
|
|
|
1348
1348
|
className="border-border bg-card mobile:w-full flex w-80 shrink-0 flex-col overflow-y-auto rounded-lg border lg:w-96"
|
|
1349
1349
|
>
|
|
1350
1350
|
<div className="border-border bg-card sticky top-0 z-10 flex items-center justify-between border-b p-4">
|
|
1351
|
-
<
|
|
1351
|
+
<h2 className="text-foreground truncate text-sm font-medium">
|
|
1352
1352
|
{activeItem.name}
|
|
1353
|
-
</
|
|
1353
|
+
</h2>
|
|
1354
1354
|
<button
|
|
1355
1355
|
type="button"
|
|
1356
1356
|
onClick={closeDetail}
|
|
@@ -148,8 +148,8 @@ export function ResetPassword({ onNavigate, token }: ResetPasswordProps) {
|
|
|
148
148
|
<button
|
|
149
149
|
type="button"
|
|
150
150
|
onClick={() => setShowPassword(!showPassword)}
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
|
152
|
+
className="text-muted-foreground hover:text-foreground absolute top-1/2 right-2 flex h-6 w-6 -translate-y-1/2 items-center justify-center"
|
|
153
153
|
>
|
|
154
154
|
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
|
155
155
|
</button>
|
|
@@ -175,8 +175,8 @@ export function SetupWizard({ onComplete, siteName = 'Prenta CMS' }: SetupWizard
|
|
|
175
175
|
<button
|
|
176
176
|
type="button"
|
|
177
177
|
onClick={() => setShowPassword(!showPassword)}
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
aria-label={showPassword ? 'Hide password' : 'Show password'}
|
|
179
|
+
className="text-muted-foreground hover:text-foreground absolute top-1/2 right-2 flex h-6 w-6 -translate-y-1/2 items-center justify-center"
|
|
180
180
|
>
|
|
181
181
|
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
|
182
182
|
</button>
|
package/src/views/Users.tsx
CHANGED
|
@@ -27,6 +27,7 @@ import { toast } from 'sonner'
|
|
|
27
27
|
import { parseRouteQuery } from '../router/index.js'
|
|
28
28
|
import { useApiData } from '../lib/useApiData.js'
|
|
29
29
|
import { cmsApi } from '../lib/api.js'
|
|
30
|
+
import { authorAvatar } from '../components/ui/AuthorAvatar.js'
|
|
30
31
|
import { Button } from '../components/ui/Button.js'
|
|
31
32
|
import { EmptyState } from '../components/ui/EmptyState.js'
|
|
32
33
|
import { FilterPill } from '../components/ui/FilterPill.js'
|
|
@@ -110,8 +111,8 @@ interface Row {
|
|
|
110
111
|
// ---------------------------------------------------------------------------
|
|
111
112
|
|
|
112
113
|
const ROLE_PILL: Record<string, string> = {
|
|
113
|
-
Owner: 'bg-
|
|
114
|
-
Admin: 'bg-info
|
|
114
|
+
Owner: 'bg-acc-l text-acc',
|
|
115
|
+
Admin: 'bg-info-l text-info',
|
|
115
116
|
Editor: 'bg-accent text-accent-foreground',
|
|
116
117
|
Viewer: 'bg-muted text-muted-foreground',
|
|
117
118
|
}
|
|
@@ -132,8 +133,6 @@ const SEVERITY_DOT: Record<ApiRecommendation['severity'], string> = {
|
|
|
132
133
|
low: 'bg-info',
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
const AVATAR_TINTS = ['bg-chart-1', 'bg-chart-2', 'bg-chart-3', 'bg-chart-4', 'bg-chart-5'] as const
|
|
136
|
-
|
|
137
136
|
interface RoleOption {
|
|
138
137
|
value: string
|
|
139
138
|
label: string
|
|
@@ -164,12 +163,6 @@ const OWNER_ROLE_OPTION: RoleOption = {
|
|
|
164
163
|
// Helpers
|
|
165
164
|
// ---------------------------------------------------------------------------
|
|
166
165
|
|
|
167
|
-
function avatarTint(id: string): string {
|
|
168
|
-
let h = 0
|
|
169
|
-
for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) >>> 0
|
|
170
|
-
return AVATAR_TINTS[h % AVATAR_TINTS.length]!
|
|
171
|
-
}
|
|
172
|
-
|
|
173
166
|
function relativeTime(iso: string | null): string {
|
|
174
167
|
if (!iso) return 'Never'
|
|
175
168
|
const then = new Date(iso).getTime()
|
|
@@ -279,7 +272,7 @@ function AccessReviewBanner({
|
|
|
279
272
|
<div className="min-w-0 flex-1">
|
|
280
273
|
<div className="flex items-center gap-2">
|
|
281
274
|
<span className="text-card-foreground text-sm font-medium">{top.title}</span>
|
|
282
|
-
<span className="bg-
|
|
275
|
+
<span className="bg-acc-l text-acc inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium">
|
|
283
276
|
<Sparkles size={10} aria-hidden />
|
|
284
277
|
AI
|
|
285
278
|
</span>
|
|
@@ -319,7 +312,8 @@ function AccessReviewBanner({
|
|
|
319
312
|
function Avatar({ row }: { row: Row }) {
|
|
320
313
|
return (
|
|
321
314
|
<span
|
|
322
|
-
className=
|
|
315
|
+
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-xs font-medium"
|
|
316
|
+
style={{ background: authorAvatar(row.name).color, color: 'var(--on-avatar)' }}
|
|
323
317
|
aria-hidden
|
|
324
318
|
>
|
|
325
319
|
{row.initials}
|
|
@@ -353,7 +347,7 @@ function RoleDropdown({
|
|
|
353
347
|
<DropdownMenu.Trigger asChild>
|
|
354
348
|
<button
|
|
355
349
|
type="button"
|
|
356
|
-
className={`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium
|
|
350
|
+
className={`inline-flex min-h-6 items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${pill}`}
|
|
357
351
|
aria-label={`Change role for ${row.name}, current role ${row.roleName}`}
|
|
358
352
|
>
|
|
359
353
|
{row.roleName}
|
|
@@ -1054,27 +1048,24 @@ export function Users({ embedded = false, currentPath }: UsersProps = {}) {
|
|
|
1054
1048
|
className={`hover:bg-accent/30 transition-colors ${
|
|
1055
1049
|
isInvite ? '' : 'cursor-pointer'
|
|
1056
1050
|
}`}
|
|
1057
|
-
{
|
|
1058
|
-
? {}
|
|
1059
|
-
: {
|
|
1060
|
-
role: 'button',
|
|
1061
|
-
tabIndex: 0,
|
|
1062
|
-
'aria-label': `Open details for ${row.name}`,
|
|
1063
|
-
onClick: openDetail,
|
|
1064
|
-
onKeyDown: (e: React.KeyboardEvent) => {
|
|
1065
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
1066
|
-
e.preventDefault()
|
|
1067
|
-
openDetail()
|
|
1068
|
-
}
|
|
1069
|
-
},
|
|
1070
|
-
})}
|
|
1051
|
+
onClick={isInvite ? undefined : openDetail}
|
|
1071
1052
|
>
|
|
1072
1053
|
<td className="px-4 py-3">
|
|
1073
1054
|
<div className="flex items-center gap-3">
|
|
1074
1055
|
<Avatar row={row} />
|
|
1075
1056
|
<div className="min-w-0">
|
|
1076
1057
|
<div className="text-card-foreground flex items-center gap-1.5 text-sm font-medium">
|
|
1077
|
-
|
|
1058
|
+
{isInvite ? (
|
|
1059
|
+
<span className="truncate">{row.name}</span>
|
|
1060
|
+
) : (
|
|
1061
|
+
<button
|
|
1062
|
+
type="button"
|
|
1063
|
+
className="min-h-6 truncate text-left"
|
|
1064
|
+
aria-label={`Open details for ${row.name}`}
|
|
1065
|
+
>
|
|
1066
|
+
{row.name}
|
|
1067
|
+
</button>
|
|
1068
|
+
)}
|
|
1078
1069
|
{row.isCurrentUser && (
|
|
1079
1070
|
<span className="bg-muted text-muted-foreground rounded px-1 text-[10px]">
|
|
1080
1071
|
You
|
|
@@ -1092,11 +1083,7 @@ export function Users({ embedded = false, currentPath }: UsersProps = {}) {
|
|
|
1092
1083
|
</div>
|
|
1093
1084
|
</div>
|
|
1094
1085
|
</td>
|
|
1095
|
-
<td
|
|
1096
|
-
className="px-4 py-3"
|
|
1097
|
-
onClick={(e) => e.stopPropagation()}
|
|
1098
|
-
role="presentation"
|
|
1099
|
-
>
|
|
1086
|
+
<td className="px-4 py-3" onClick={(e) => e.stopPropagation()}>
|
|
1100
1087
|
<RoleDropdown
|
|
1101
1088
|
row={row}
|
|
1102
1089
|
options={roleOptions}
|
|
@@ -1112,11 +1099,7 @@ export function Users({ embedded = false, currentPath }: UsersProps = {}) {
|
|
|
1112
1099
|
? `Invited ${relativeTime(row.activityAt)}`
|
|
1113
1100
|
: relativeTime(row.activityAt)}
|
|
1114
1101
|
</td>
|
|
1115
|
-
<td
|
|
1116
|
-
className="px-4 py-3 text-right"
|
|
1117
|
-
onClick={(e) => e.stopPropagation()}
|
|
1118
|
-
role="presentation"
|
|
1119
|
-
>
|
|
1102
|
+
<td className="px-4 py-3 text-right" onClick={(e) => e.stopPropagation()}>
|
|
1120
1103
|
<RowActions
|
|
1121
1104
|
row={row}
|
|
1122
1105
|
isInvite={isInvite}
|
|
@@ -318,6 +318,21 @@ export function EntriesInbox({
|
|
|
318
318
|
const [total, setTotal] = useState(0)
|
|
319
319
|
const [counts, setCounts] = useState<EntryCounts | null>(null)
|
|
320
320
|
const [loading, setLoading] = useState(true)
|
|
321
|
+
const loadRequestRef = useRef(0)
|
|
322
|
+
const loadedQueryRef = useRef<string | null>(null)
|
|
323
|
+
// Track operations separately: overlapping writes to one entry must not
|
|
324
|
+
// remove each other's optimistic state when one request finishes.
|
|
325
|
+
const pendingPatchesRef = useRef(new Map<symbol, { id: string; patch: EntryPatch }>())
|
|
326
|
+
const applyPendingPatches = useCallback((rows: FormSubmission[]) => {
|
|
327
|
+
const patches = new Map<string, EntryPatch>()
|
|
328
|
+
for (const { id, patch } of pendingPatchesRef.current.values()) {
|
|
329
|
+
patches.set(id, { ...patches.get(id), ...patch })
|
|
330
|
+
}
|
|
331
|
+
return rows.map((entry) => {
|
|
332
|
+
const patch = patches.get(entry.id)
|
|
333
|
+
return patch ? { ...entry, ...patch } : entry
|
|
334
|
+
})
|
|
335
|
+
}, [])
|
|
321
336
|
const [error, setError] = useState<string | null>(null)
|
|
322
337
|
const [search, setSearch] = useState('')
|
|
323
338
|
const [filter, setFilter] = useState<InboxFilter>(initial.filter)
|
|
@@ -590,45 +605,61 @@ export function EntriesInbox({
|
|
|
590
605
|
[formId, onNavigate],
|
|
591
606
|
)
|
|
592
607
|
|
|
593
|
-
const load = useCallback(
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
result.
|
|
619
|
-
|
|
620
|
-
|
|
608
|
+
const load = useCallback(
|
|
609
|
+
async (background = false) => {
|
|
610
|
+
const request = ++loadRequestRef.current
|
|
611
|
+
const query = JSON.stringify([filter, scopedFormId, search.trim(), currentUserId])
|
|
612
|
+
// An event may supersede a foreground load. Until this query has a
|
|
613
|
+
// successful dataset, its failures must remain foreground errors.
|
|
614
|
+
const keepRows = background && loadedQueryRef.current === query
|
|
615
|
+
if (!keepRows) setLoading(true)
|
|
616
|
+
setError(null)
|
|
617
|
+
const params = filterParams(filter, currentUserId)
|
|
618
|
+
try {
|
|
619
|
+
const collected: FormSubmission[] = []
|
|
620
|
+
const seen = new Set<string>()
|
|
621
|
+
let reported = 0
|
|
622
|
+
for (let page = 1; page <= 5; page++) {
|
|
623
|
+
const result = await fetchEntries({
|
|
624
|
+
formId: scopedFormId,
|
|
625
|
+
search: search.trim() || undefined,
|
|
626
|
+
page,
|
|
627
|
+
pageSize: PAGE_SIZE,
|
|
628
|
+
sortBy: 'submittedAt',
|
|
629
|
+
sortDirection: 'desc',
|
|
630
|
+
...params,
|
|
631
|
+
})
|
|
632
|
+
if (request !== loadRequestRef.current) return
|
|
633
|
+
reported = result.total
|
|
634
|
+
const fresh = result.entries.filter((entry) => !seen.has(entry.id))
|
|
635
|
+
for (const entry of fresh) seen.add(entry.id)
|
|
636
|
+
collected.push(...fresh)
|
|
637
|
+
if (
|
|
638
|
+
collected.length >= reported ||
|
|
639
|
+
fresh.length === 0 ||
|
|
640
|
+
result.entries.length < PAGE_SIZE
|
|
641
|
+
) {
|
|
642
|
+
break
|
|
643
|
+
}
|
|
621
644
|
}
|
|
645
|
+
if (request !== loadRequestRef.current) return
|
|
646
|
+
setEntries(applyPendingPatches(collected))
|
|
647
|
+
loadedQueryRef.current = query
|
|
648
|
+
setTotal(reported)
|
|
649
|
+
setChecked((current) =>
|
|
650
|
+
keepRows ? new Set([...current].filter((id) => seen.has(id))) : new Set(),
|
|
651
|
+
)
|
|
652
|
+
} catch (err) {
|
|
653
|
+
if (request !== loadRequestRef.current) return
|
|
654
|
+
const message = err instanceof Error ? err.message : 'Failed to load entries'
|
|
655
|
+
if (keepRows) toast.error(message)
|
|
656
|
+
else setError(message)
|
|
657
|
+
} finally {
|
|
658
|
+
if (request === loadRequestRef.current) setLoading(false)
|
|
622
659
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
} catch (err) {
|
|
627
|
-
setError(err instanceof Error ? err.message : 'Failed to load entries')
|
|
628
|
-
} finally {
|
|
629
|
-
setLoading(false)
|
|
630
|
-
}
|
|
631
|
-
}, [filter, scopedFormId, search, currentUserId])
|
|
660
|
+
},
|
|
661
|
+
[filter, scopedFormId, search, currentUserId, applyPendingPatches],
|
|
662
|
+
)
|
|
632
663
|
|
|
633
664
|
const loadCounts = useCallback(() => {
|
|
634
665
|
void fetchEntryCounts({
|
|
@@ -639,9 +670,14 @@ export function EntriesInbox({
|
|
|
639
670
|
.catch(() => {})
|
|
640
671
|
}, [scopedFormId, currentUserId])
|
|
641
672
|
|
|
673
|
+
const cancelLoad = useCallback(() => {
|
|
674
|
+
loadRequestRef.current++
|
|
675
|
+
}, [])
|
|
676
|
+
|
|
642
677
|
useEffect(() => {
|
|
643
678
|
void load()
|
|
644
|
-
|
|
679
|
+
return cancelLoad
|
|
680
|
+
}, [load, cancelLoad])
|
|
645
681
|
|
|
646
682
|
useEffect(() => {
|
|
647
683
|
loadCounts()
|
|
@@ -650,7 +686,8 @@ export function EntriesInbox({
|
|
|
650
686
|
useEffect(
|
|
651
687
|
() =>
|
|
652
688
|
onFormsChanged(() => {
|
|
653
|
-
|
|
689
|
+
// Read/star updates must not unmount rows or reset the inbox scroll position.
|
|
690
|
+
void load(true)
|
|
654
691
|
loadCounts()
|
|
655
692
|
}),
|
|
656
693
|
[load, loadCounts],
|
|
@@ -754,6 +791,47 @@ export function EntriesInbox({
|
|
|
754
791
|
writeQuery(filter, next)
|
|
755
792
|
}
|
|
756
793
|
|
|
794
|
+
const entryWriteQueue = useRef(
|
|
795
|
+
new Map<string, Promise<Awaited<ReturnType<typeof updateEntry>>>>(),
|
|
796
|
+
)
|
|
797
|
+
const persistEntryPatch = useCallback(
|
|
798
|
+
(id: string, patch: EntryPatch) => {
|
|
799
|
+
const operation = Symbol()
|
|
800
|
+
pendingPatchesRef.current.set(operation, { id, patch })
|
|
801
|
+
setEntries((current) => applyPendingPatches(current))
|
|
802
|
+
// Serialize writes to one entry so the server and UI both retain click
|
|
803
|
+
// order. Other entries can still save independently.
|
|
804
|
+
const previous = entryWriteQueue.current.get(id) ?? Promise.resolve()
|
|
805
|
+
const queued = previous
|
|
806
|
+
.catch(() => undefined)
|
|
807
|
+
.then(async () => {
|
|
808
|
+
let result: Awaited<ReturnType<typeof updateEntry>>
|
|
809
|
+
try {
|
|
810
|
+
result = await updateEntry(id, patch)
|
|
811
|
+
} catch (error) {
|
|
812
|
+
result = { error: error instanceof Error ? error.message : 'Failed to update entry' }
|
|
813
|
+
}
|
|
814
|
+
pendingPatchesRef.current.delete(operation)
|
|
815
|
+
if (result.data) {
|
|
816
|
+
setEntries((current) =>
|
|
817
|
+
applyPendingPatches(
|
|
818
|
+
current.map((entry) =>
|
|
819
|
+
entry.id === id ? { ...entry, ...result.data, ...patch } : entry,
|
|
820
|
+
),
|
|
821
|
+
),
|
|
822
|
+
)
|
|
823
|
+
}
|
|
824
|
+
return result
|
|
825
|
+
})
|
|
826
|
+
.finally(() => {
|
|
827
|
+
if (entryWriteQueue.current.get(id) === queued) entryWriteQueue.current.delete(id)
|
|
828
|
+
})
|
|
829
|
+
entryWriteQueue.current.set(id, queued)
|
|
830
|
+
return queued
|
|
831
|
+
},
|
|
832
|
+
[applyPendingPatches],
|
|
833
|
+
)
|
|
834
|
+
|
|
757
835
|
const patchOne = useCallback(
|
|
758
836
|
async (
|
|
759
837
|
id: string,
|
|
@@ -763,34 +841,23 @@ export function EntriesInbox({
|
|
|
763
841
|
clearSelectionOnApply?: boolean,
|
|
764
842
|
) => {
|
|
765
843
|
const prevActive = activeId
|
|
766
|
-
setEntries((current) =>
|
|
767
|
-
current.map((entry) => (entry.id === id ? { ...entry, ...patch } : entry)),
|
|
768
|
-
)
|
|
769
844
|
if (clearSelectionOnApply && activeId === id) setActiveId(null)
|
|
770
|
-
const res = await
|
|
845
|
+
const res = await persistEntryPatch(id, patch)
|
|
771
846
|
if (res.error) {
|
|
772
847
|
toast.error(res.error)
|
|
773
848
|
void load()
|
|
774
849
|
return
|
|
775
850
|
}
|
|
776
|
-
if (res.data) {
|
|
777
|
-
setEntries((current) =>
|
|
778
|
-
current.map((entry) => (entry.id === id ? { ...entry, ...res.data, ...patch } : entry)),
|
|
779
|
-
)
|
|
780
|
-
}
|
|
781
851
|
if (message) {
|
|
782
852
|
if (undoPatch) {
|
|
783
853
|
showUndoToast(message, () => {
|
|
784
854
|
void (async () => {
|
|
785
|
-
const undoRes = await
|
|
855
|
+
const undoRes = await persistEntryPatch(id, undoPatch)
|
|
786
856
|
if (undoRes.error) {
|
|
787
857
|
toast.error(undoRes.error)
|
|
788
858
|
void load()
|
|
789
859
|
return
|
|
790
860
|
}
|
|
791
|
-
setEntries((current) =>
|
|
792
|
-
current.map((entry) => (entry.id === id ? { ...entry, ...undoPatch } : entry)),
|
|
793
|
-
)
|
|
794
861
|
setActiveId(prevActive)
|
|
795
862
|
showUndoToast('Undone')
|
|
796
863
|
emitFormsChanged()
|
|
@@ -802,7 +869,7 @@ export function EntriesInbox({
|
|
|
802
869
|
}
|
|
803
870
|
emitFormsChanged()
|
|
804
871
|
},
|
|
805
|
-
[activeId, load, showUndoToast],
|
|
872
|
+
[activeId, load, showUndoToast, persistEntryPatch],
|
|
806
873
|
)
|
|
807
874
|
|
|
808
875
|
const handleTrashOrDelete = useCallback(
|
|
@@ -1774,7 +1841,7 @@ function EntryRow({
|
|
|
1774
1841
|
{compact ? null : (
|
|
1775
1842
|
<span
|
|
1776
1843
|
className="relative flex size-8 items-center justify-center rounded-full text-[12px] font-bold"
|
|
1777
|
-
style={{ background: avatarColor(name), color: 'var(--on-
|
|
1844
|
+
style={{ background: avatarColor(name), color: 'var(--on-avatar)' }}
|
|
1778
1845
|
>
|
|
1779
1846
|
{initials(name)}
|
|
1780
1847
|
{entry.unread ? (
|
|
@@ -1877,7 +1944,7 @@ function EntryRow({
|
|
|
1877
1944
|
{entry.spamStatus !== 'spam' && !entry.partial && assignee ? (
|
|
1878
1945
|
<span
|
|
1879
1946
|
className="inline-flex size-[18px] shrink-0 items-center justify-center rounded-full text-[8px] font-bold tracking-[-0.2px]"
|
|
1880
|
-
style={{ background: avatarColor(assignee.name), color: 'var(--on-
|
|
1947
|
+
style={{ background: avatarColor(assignee.name), color: 'var(--on-avatar)' }}
|
|
1881
1948
|
title={assignee.name}
|
|
1882
1949
|
>
|
|
1883
1950
|
{initials(assignee.name)}
|
|
@@ -2356,7 +2423,7 @@ function EntryDetail({
|
|
|
2356
2423
|
<div className={`flex items-start gap-4 max-[640px]:flex-wrap ${msgEntry ? 'mb-6' : ''}`}>
|
|
2357
2424
|
<span
|
|
2358
2425
|
className="flex size-[52px] shrink-0 items-center justify-center rounded-full text-[18px] font-bold"
|
|
2359
|
-
style={{ background: avatarColor(name), color: 'var(--on-
|
|
2426
|
+
style={{ background: avatarColor(name), color: 'var(--on-avatar)' }}
|
|
2360
2427
|
>
|
|
2361
2428
|
{initials(name)}
|
|
2362
2429
|
</span>
|
|
@@ -2482,7 +2549,7 @@ function EntryDetail({
|
|
|
2482
2549
|
{assignee ? (
|
|
2483
2550
|
<span
|
|
2484
2551
|
className="inline-flex size-[22px] shrink-0 items-center justify-center rounded-full text-[9.5px] font-bold tracking-[-0.2px]"
|
|
2485
|
-
style={{ background: avatarColor(assignee.name), color: 'var(--on-
|
|
2552
|
+
style={{ background: avatarColor(assignee.name), color: 'var(--on-avatar)' }}
|
|
2486
2553
|
title={assignee.name}
|
|
2487
2554
|
>
|
|
2488
2555
|
{initials(assignee.name)}
|
|
@@ -2705,7 +2772,7 @@ function EntryDetail({
|
|
|
2705
2772
|
<div key={idx} className="flex gap-2.5">
|
|
2706
2773
|
<span
|
|
2707
2774
|
className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
|
|
2708
|
-
style={{ background: avatarColor(author), color: 'var(--on-
|
|
2775
|
+
style={{ background: avatarColor(author), color: 'var(--on-avatar)' }}
|
|
2709
2776
|
>
|
|
2710
2777
|
{initials(author)}
|
|
2711
2778
|
</span>
|
|
@@ -2729,7 +2796,7 @@ function EntryDetail({
|
|
|
2729
2796
|
<div className="border-bdr flex gap-2.5 border-t pt-3">
|
|
2730
2797
|
<span
|
|
2731
2798
|
className="flex size-[26px] shrink-0 items-center justify-center rounded-full text-[11px] font-bold"
|
|
2732
|
-
style={{ background: avatarColor(currentUserName), color: 'var(--on-
|
|
2799
|
+
style={{ background: avatarColor(currentUserName), color: 'var(--on-avatar)' }}
|
|
2733
2800
|
>
|
|
2734
2801
|
{initials(currentUserName)}
|
|
2735
2802
|
</span>
|