@prenta/admin 2.16.7 → 2.17.2
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 +90 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +31 -3
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/attribution-rows.test.js +12 -3
- package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
- package/dist/__tests__/components/command-palette-links.render.test.d.ts +2 -0
- package/dist/__tests__/components/command-palette-links.render.test.d.ts.map +1 -0
- package/dist/__tests__/components/command-palette-links.render.test.js +73 -0
- package/dist/__tests__/components/command-palette-links.render.test.js.map +1 -0
- package/dist/__tests__/components/live-preview-pane.render.test.d.ts +2 -0
- package/dist/__tests__/components/live-preview-pane.render.test.d.ts.map +1 -0
- package/dist/__tests__/components/live-preview-pane.render.test.js +45 -0
- package/dist/__tests__/components/live-preview-pane.render.test.js.map +1 -0
- package/dist/__tests__/components/schedule-publish-dialog.render.test.d.ts +2 -0
- package/dist/__tests__/components/schedule-publish-dialog.render.test.d.ts.map +1 -0
- package/dist/__tests__/components/schedule-publish-dialog.render.test.js +78 -0
- package/dist/__tests__/components/schedule-publish-dialog.render.test.js.map +1 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.js +7 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.js.map +1 -1
- package/dist/__tests__/layout/layout-command-palette.render.test.d.ts +2 -0
- package/dist/__tests__/layout/layout-command-palette.render.test.d.ts.map +1 -0
- package/dist/__tests__/layout/layout-command-palette.render.test.js +54 -0
- package/dist/__tests__/layout/layout-command-palette.render.test.js.map +1 -0
- package/dist/__tests__/layout/shell-nav.render.test.js +106 -27
- package/dist/__tests__/layout/shell-nav.render.test.js.map +1 -1
- package/dist/__tests__/lib/api-error.test.d.ts +2 -0
- package/dist/__tests__/lib/api-error.test.d.ts.map +1 -0
- package/dist/__tests__/lib/api-error.test.js +32 -0
- package/dist/__tests__/lib/api-error.test.js.map +1 -0
- package/dist/__tests__/lib/api.test.js +29 -0
- package/dist/__tests__/lib/api.test.js.map +1 -1
- package/dist/__tests__/lib/collection-routes.test.js +19 -1
- package/dist/__tests__/lib/collection-routes.test.js.map +1 -1
- package/dist/__tests__/lib/document-editor-path.test.d.ts +2 -0
- package/dist/__tests__/lib/document-editor-path.test.d.ts.map +1 -0
- package/dist/__tests__/lib/document-editor-path.test.js +42 -0
- package/dist/__tests__/lib/document-editor-path.test.js.map +1 -0
- package/dist/__tests__/lib/fetch-all-pages.test.js +11 -1
- package/dist/__tests__/lib/fetch-all-pages.test.js.map +1 -1
- package/dist/__tests__/lib/forms-service-rate-limit.test.d.ts +2 -0
- package/dist/__tests__/lib/forms-service-rate-limit.test.d.ts.map +1 -0
- package/dist/__tests__/lib/forms-service-rate-limit.test.js +19 -0
- package/dist/__tests__/lib/forms-service-rate-limit.test.js.map +1 -0
- package/dist/__tests__/lib/useApiData.test.js +20 -0
- package/dist/__tests__/lib/useApiData.test.js.map +1 -1
- package/dist/__tests__/test-env-storage.test.d.ts +2 -0
- package/dist/__tests__/test-env-storage.test.d.ts.map +1 -0
- package/dist/__tests__/test-env-storage.test.js +28 -0
- package/dist/__tests__/test-env-storage.test.js.map +1 -0
- package/dist/__tests__/views/account-setup-gate.render.test.d.ts +2 -0
- package/dist/__tests__/views/account-setup-gate.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/account-setup-gate.render.test.js +103 -0
- package/dist/__tests__/views/account-setup-gate.render.test.js.map +1 -0
- package/dist/__tests__/views/collection-editor-redirect.render.test.d.ts +2 -0
- package/dist/__tests__/views/collection-editor-redirect.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/collection-editor-redirect.render.test.js +168 -0
- package/dist/__tests__/views/collection-editor-redirect.render.test.js.map +1 -0
- package/dist/__tests__/views/collection-list-nav.render.test.js +33 -0
- package/dist/__tests__/views/collection-list-nav.render.test.js.map +1 -1
- package/dist/__tests__/views/dashboard.test.js +50 -0
- package/dist/__tests__/views/dashboard.test.js.map +1 -1
- package/dist/__tests__/views/form-entries.render.test.js +7 -0
- package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
- package/dist/__tests__/views/forms-list.render.test.js +12 -0
- package/dist/__tests__/views/forms-list.render.test.js.map +1 -1
- package/dist/__tests__/views/login-mfa.render.test.js +33 -0
- package/dist/__tests__/views/login-mfa.render.test.js.map +1 -1
- package/dist/__tests__/views/posts-list-view.render.test.js +31 -0
- package/dist/__tests__/views/posts-list-view.render.test.js.map +1 -1
- package/dist/__tests__/views/rate-limited-views.render.test.d.ts +2 -0
- package/dist/__tests__/views/rate-limited-views.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/rate-limited-views.render.test.js +148 -0
- package/dist/__tests__/views/rate-limited-views.render.test.js.map +1 -0
- package/dist/__tests__/views/script-tags.render.test.js +42 -0
- package/dist/__tests__/views/script-tags.render.test.js.map +1 -1
- package/dist/__tests__/views/trash.render.test.js +40 -1
- package/dist/__tests__/views/trash.render.test.js.map +1 -1
- package/dist/components/CommandPalette.d.ts +9 -1
- package/dist/components/CommandPalette.d.ts.map +1 -1
- package/dist/components/CommandPalette.js +21 -7
- package/dist/components/CommandPalette.js.map +1 -1
- package/dist/components/LivePreview.d.ts.map +1 -1
- package/dist/components/LivePreview.js +10 -2
- package/dist/components/LivePreview.js.map +1 -1
- package/dist/components/MediaPickerModal.d.ts.map +1 -1
- package/dist/components/MediaPickerModal.js +2 -2
- package/dist/components/MediaPickerModal.js.map +1 -1
- package/dist/components/SchedulePublishDialog.d.ts +7 -1
- package/dist/components/SchedulePublishDialog.d.ts.map +1 -1
- package/dist/components/SchedulePublishDialog.js +6 -5
- package/dist/components/SchedulePublishDialog.js.map +1 -1
- package/dist/fields/FieldRenderer.d.ts.map +1 -1
- package/dist/fields/FieldRenderer.js +2 -0
- package/dist/fields/FieldRenderer.js.map +1 -1
- package/dist/fields/JsonField.d.ts +12 -0
- package/dist/fields/JsonField.d.ts.map +1 -0
- package/dist/fields/JsonField.js +11 -0
- package/dist/fields/JsonField.js.map +1 -0
- package/dist/layout/Header.d.ts +7 -1
- package/dist/layout/Header.d.ts.map +1 -1
- package/dist/layout/Header.js +2 -2
- package/dist/layout/Header.js.map +1 -1
- package/dist/layout/Layout.d.ts.map +1 -1
- package/dist/layout/Layout.js +1 -1
- package/dist/layout/Layout.js.map +1 -1
- package/dist/layout/MobileTabBar.d.ts +7 -4
- package/dist/layout/MobileTabBar.d.ts.map +1 -1
- package/dist/layout/MobileTabBar.js +41 -17
- package/dist/layout/MobileTabBar.js.map +1 -1
- package/dist/lib/api-error.d.ts +23 -0
- package/dist/lib/api-error.d.ts.map +1 -0
- package/dist/lib/api-error.js +42 -0
- package/dist/lib/api-error.js.map +1 -0
- package/dist/lib/api.d.ts +6 -0
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +10 -0
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/collection-routes.d.ts +8 -0
- package/dist/lib/collection-routes.d.ts.map +1 -1
- package/dist/lib/collection-routes.js +12 -0
- package/dist/lib/collection-routes.js.map +1 -1
- package/dist/lib/document-editor-path.d.ts +32 -0
- package/dist/lib/document-editor-path.d.ts.map +1 -0
- package/dist/lib/document-editor-path.js +75 -0
- package/dist/lib/document-editor-path.js.map +1 -0
- package/dist/lib/entry-attribution.d.ts.map +1 -1
- package/dist/lib/entry-attribution.js +6 -4
- package/dist/lib/entry-attribution.js.map +1 -1
- package/dist/lib/fetch-all-pages.d.ts.map +1 -1
- package/dist/lib/fetch-all-pages.js +4 -2
- package/dist/lib/fetch-all-pages.js.map +1 -1
- package/dist/lib/forms-service.d.ts.map +1 -1
- package/dist/lib/forms-service.js +3 -1
- package/dist/lib/forms-service.js.map +1 -1
- package/dist/lib/jobs-service.d.ts.map +1 -1
- package/dist/lib/jobs-service.js +4 -11
- package/dist/lib/jobs-service.js.map +1 -1
- package/dist/lib/posts-service.d.ts.map +1 -1
- package/dist/lib/posts-service.js +3 -1
- package/dist/lib/posts-service.js.map +1 -1
- package/dist/lib/useApiData.d.ts.map +1 -1
- package/dist/lib/useApiData.js +8 -4
- package/dist/lib/useApiData.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/router/index.d.ts +5 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +13 -3
- package/dist/router/index.js.map +1 -1
- package/dist/views/AccountSetupGate.d.ts +17 -0
- package/dist/views/AccountSetupGate.d.ts.map +1 -0
- package/dist/views/AccountSetupGate.js +69 -0
- package/dist/views/AccountSetupGate.js.map +1 -0
- package/dist/views/ApiKeys.js +1 -1
- package/dist/views/ApiKeys.js.map +1 -1
- package/dist/views/CollectionList.d.ts.map +1 -1
- package/dist/views/CollectionList.js +2 -2
- package/dist/views/CollectionList.js.map +1 -1
- package/dist/views/Dashboard.d.ts.map +1 -1
- package/dist/views/Dashboard.js +5 -3
- package/dist/views/Dashboard.js.map +1 -1
- package/dist/views/DocumentEdit.d.ts.map +1 -1
- package/dist/views/DocumentEdit.js +1 -1
- package/dist/views/DocumentEdit.js.map +1 -1
- package/dist/views/Forms.d.ts.map +1 -1
- package/dist/views/Forms.js +4 -1
- package/dist/views/Forms.js.map +1 -1
- package/dist/views/Login.d.ts.map +1 -1
- package/dist/views/Login.js +50 -2
- package/dist/views/Login.js.map +1 -1
- package/dist/views/MediaBrowser.d.ts.map +1 -1
- package/dist/views/MediaBrowser.js +2 -2
- package/dist/views/MediaBrowser.js.map +1 -1
- package/dist/views/Pages/PagesListView.d.ts.map +1 -1
- package/dist/views/Pages/PagesListView.js +10 -8
- package/dist/views/Pages/PagesListView.js.map +1 -1
- package/dist/views/Pages.d.ts.map +1 -1
- package/dist/views/Pages.js +1 -1
- package/dist/views/Pages.js.map +1 -1
- package/dist/views/Posts/PostsListView.d.ts.map +1 -1
- package/dist/views/Posts/PostsListView.js +7 -6
- package/dist/views/Posts/PostsListView.js.map +1 -1
- package/dist/views/Redirects.d.ts.map +1 -1
- package/dist/views/Redirects.js +1 -1
- package/dist/views/Redirects.js.map +1 -1
- package/dist/views/ScriptTags.d.ts.map +1 -1
- package/dist/views/ScriptTags.js +3 -1
- package/dist/views/ScriptTags.js.map +1 -1
- package/dist/views/Trash.d.ts +10 -11
- package/dist/views/Trash.d.ts.map +1 -1
- package/dist/views/Trash.js +17 -16
- package/dist/views/Trash.js.map +1 -1
- package/dist/views/Users.d.ts.map +1 -1
- package/dist/views/Users.js +1 -1
- package/dist/views/Users.js.map +1 -1
- package/dist/views/entries/EntriesInbox.d.ts.map +1 -1
- package/dist/views/entries/EntriesInbox.js +1 -1
- package/dist/views/entries/EntriesInbox.js.map +1 -1
- package/dist/views/page-editor/PageSectionEditor.d.ts.map +1 -1
- package/dist/views/page-editor/PageSectionEditor.js +1 -1
- package/dist/views/page-editor/PageSectionEditor.js.map +1 -1
- package/dist/views/post-editor/PostSectionEditor.d.ts.map +1 -1
- package/dist/views/post-editor/PostSectionEditor.js +1 -1
- package/dist/views/post-editor/PostSectionEditor.js.map +1 -1
- package/dist/views/profile/AccountSecurity.d.ts +5 -1
- package/dist/views/profile/AccountSecurity.d.ts.map +1 -1
- package/dist/views/profile/AccountSecurity.js +2 -1
- package/dist/views/profile/AccountSecurity.js.map +1 -1
- package/package.json +6 -6
- package/src/AdminRoot.tsx +53 -6
- package/src/__tests__/components/attribution-rows.test.ts +13 -3
- package/src/__tests__/components/command-palette-links.render.test.tsx +89 -0
- package/src/__tests__/components/live-preview-pane.render.test.tsx +62 -0
- package/src/__tests__/components/schedule-publish-dialog.render.test.tsx +100 -0
- package/src/__tests__/fields/field-renderer-null.render.test.tsx +16 -0
- package/src/__tests__/layout/layout-command-palette.render.test.tsx +69 -0
- package/src/__tests__/layout/shell-nav.render.test.tsx +181 -29
- package/src/__tests__/lib/api-error.test.ts +45 -0
- package/src/__tests__/lib/api.test.ts +47 -0
- package/src/__tests__/lib/collection-routes.test.ts +22 -0
- package/src/__tests__/lib/document-editor-path.test.ts +67 -0
- package/src/__tests__/lib/fetch-all-pages.test.ts +14 -1
- package/src/__tests__/lib/forms-service-rate-limit.test.ts +25 -0
- package/src/__tests__/lib/useApiData.test.ts +24 -0
- package/src/__tests__/test-env-storage.test.ts +28 -0
- package/src/__tests__/views/account-setup-gate.render.test.tsx +122 -0
- package/src/__tests__/views/collection-editor-redirect.render.test.tsx +197 -0
- package/src/__tests__/views/collection-list-nav.render.test.tsx +36 -0
- package/src/__tests__/views/dashboard.test.tsx +67 -0
- package/src/__tests__/views/form-entries.render.test.tsx +10 -0
- package/src/__tests__/views/forms-list.render.test.tsx +15 -0
- package/src/__tests__/views/login-mfa.render.test.tsx +42 -0
- package/src/__tests__/views/posts-list-view.render.test.tsx +33 -0
- package/src/__tests__/views/rate-limited-views.render.test.tsx +163 -0
- package/src/__tests__/views/script-tags.render.test.tsx +43 -0
- package/src/__tests__/views/trash.render.test.tsx +42 -1
- package/src/components/CommandPalette.tsx +32 -5
- package/src/components/LivePreview.tsx +13 -2
- package/src/components/MediaPickerModal.tsx +18 -1
- package/src/components/SchedulePublishDialog.tsx +15 -4
- package/src/fields/FieldRenderer.tsx +2 -0
- package/src/fields/JsonField.tsx +34 -0
- package/src/layout/Header.tsx +8 -1
- package/src/layout/Layout.tsx +6 -1
- package/src/layout/MobileTabBar.tsx +57 -28
- package/src/lib/api-error.ts +47 -0
- package/src/lib/api.ts +17 -0
- package/src/lib/collection-routes.ts +15 -0
- package/src/lib/document-editor-path.ts +97 -0
- package/src/lib/entry-attribution.ts +6 -4
- package/src/lib/fetch-all-pages.ts +4 -1
- package/src/lib/forms-service.ts +4 -2
- package/src/lib/jobs-service.ts +4 -10
- package/src/lib/posts-service.ts +3 -1
- package/src/lib/useApiData.ts +10 -4
- package/src/router/index.ts +25 -7
- package/src/views/AccountSetupGate.tsx +198 -0
- package/src/views/ApiKeys.tsx +1 -1
- package/src/views/CollectionList.tsx +7 -4
- package/src/views/Dashboard.tsx +5 -3
- package/src/views/DocumentEdit.tsx +1 -0
- package/src/views/Forms.tsx +27 -22
- package/src/views/Login.tsx +54 -2
- package/src/views/MediaBrowser.tsx +12 -8
- package/src/views/Pages/PagesListView.tsx +16 -11
- package/src/views/Pages.tsx +6 -3
- package/src/views/Posts/PostsListView.tsx +28 -19
- package/src/views/Redirects.tsx +7 -4
- package/src/views/ScriptTags.tsx +7 -3
- package/src/views/Trash.tsx +29 -16
- package/src/views/Users.tsx +7 -4
- package/src/views/entries/EntriesInbox.tsx +10 -7
- package/src/views/page-editor/PageSectionEditor.tsx +1 -0
- package/src/views/post-editor/PostSectionEditor.tsx +1 -0
- package/src/views/profile/AccountSecurity.tsx +7 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useId, useState, type FormEvent } from 'react'
|
|
4
|
+
import { AlertTriangle, Loader2 } from 'lucide-react'
|
|
5
|
+
import {
|
|
6
|
+
AuthBrandHero,
|
|
7
|
+
AuthPrentaFooter,
|
|
8
|
+
useAuthBrand,
|
|
9
|
+
type AuthBrandingConfig,
|
|
10
|
+
} from '../components/AuthBranding.js'
|
|
11
|
+
import { cmsApi } from '../lib/api.js'
|
|
12
|
+
import { AccountSecurity } from './profile/AccountSecurity.js'
|
|
13
|
+
|
|
14
|
+
export type AccountRestriction = 'password_reset' | 'mfa_setup'
|
|
15
|
+
|
|
16
|
+
export interface AccountSetupGateProps {
|
|
17
|
+
restriction: AccountRestriction
|
|
18
|
+
/** Called once the step is done. Defaults to a full reload so the host re-reads /auth/me. */
|
|
19
|
+
onComplete?: () => void
|
|
20
|
+
onLogout: () => void
|
|
21
|
+
branding?: AuthBrandingConfig
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function reload() {
|
|
25
|
+
if (typeof window !== 'undefined') window.location.reload()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Full-screen step a restricted session must finish before the admin opens
|
|
30
|
+
* (#1254): an administrator asked this user to change their password or to set
|
|
31
|
+
* up two-factor authentication, or the organization requires MFA. Every other
|
|
32
|
+
* admin request answers 403 SETUP_REQUIRED until it is done.
|
|
33
|
+
*/
|
|
34
|
+
export function AccountSetupGate({
|
|
35
|
+
restriction,
|
|
36
|
+
onComplete = reload,
|
|
37
|
+
onLogout,
|
|
38
|
+
branding,
|
|
39
|
+
}: AccountSetupGateProps) {
|
|
40
|
+
const brand = useAuthBrand(branding)
|
|
41
|
+
const headingId = useId()
|
|
42
|
+
const title =
|
|
43
|
+
restriction === 'password_reset' ? 'Change your password' : 'Set up two-factor authentication'
|
|
44
|
+
const intro =
|
|
45
|
+
restriction === 'password_reset'
|
|
46
|
+
? 'Your administrator asked you to choose a new password before you continue.'
|
|
47
|
+
: 'Two-factor authentication is required for your account. Set it up to continue.'
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="bg-background flex min-h-screen items-center justify-center px-4 py-10">
|
|
51
|
+
<main aria-labelledby={headingId} className="w-full max-w-lg">
|
|
52
|
+
<div className="mb-8 text-center">
|
|
53
|
+
<AuthBrandHero brand={brand} />
|
|
54
|
+
<h1 id={headingId} className="text-foreground text-2xl font-medium">
|
|
55
|
+
{title}
|
|
56
|
+
</h1>
|
|
57
|
+
<p className="text-muted-foreground mt-2">{intro}</p>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{restriction === 'password_reset' ? (
|
|
61
|
+
<ChangePasswordForm onDone={onComplete} />
|
|
62
|
+
) : (
|
|
63
|
+
<AccountSecurity onEnabled={onComplete} />
|
|
64
|
+
)}
|
|
65
|
+
|
|
66
|
+
<div className="mt-6 text-center">
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
onClick={onLogout}
|
|
70
|
+
className="text-muted-foreground hover:text-foreground text-sm font-medium"
|
|
71
|
+
>
|
|
72
|
+
Sign out
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
<AuthPrentaFooter />
|
|
76
|
+
</main>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function ChangePasswordForm({ onDone }: { onDone: () => void }) {
|
|
82
|
+
const currentId = useId()
|
|
83
|
+
const nextId = useId()
|
|
84
|
+
const confirmId = useId()
|
|
85
|
+
const errorId = useId()
|
|
86
|
+
const [current, setCurrent] = useState('')
|
|
87
|
+
const [next, setNext] = useState('')
|
|
88
|
+
const [confirm, setConfirm] = useState('')
|
|
89
|
+
const [error, setError] = useState('')
|
|
90
|
+
const [saving, setSaving] = useState(false)
|
|
91
|
+
|
|
92
|
+
const canSubmit = Boolean(current && next && confirm) && !saving
|
|
93
|
+
|
|
94
|
+
async function handleSubmit(e: FormEvent) {
|
|
95
|
+
e.preventDefault()
|
|
96
|
+
if (!canSubmit) return
|
|
97
|
+
if (next !== confirm) {
|
|
98
|
+
setError('The new passwords do not match.')
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
setError('')
|
|
102
|
+
setSaving(true)
|
|
103
|
+
try {
|
|
104
|
+
const res = await cmsApi<{ success?: boolean }>('/auth/password', {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
body: JSON.stringify({ currentPassword: current, newPassword: next }),
|
|
107
|
+
})
|
|
108
|
+
if (res.error) {
|
|
109
|
+
setError(res.error)
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
onDone()
|
|
113
|
+
} catch (err) {
|
|
114
|
+
setError(err instanceof Error ? err.message : 'Could not change your password.')
|
|
115
|
+
} finally {
|
|
116
|
+
setSaving(false)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const inputClass =
|
|
121
|
+
'border-border bg-input-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full rounded-lg border px-3 py-2.5 focus-visible:ring-2 focus-visible:outline-none'
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<form
|
|
125
|
+
onSubmit={handleSubmit}
|
|
126
|
+
className="border-border bg-card space-y-5 rounded-xl border p-6 shadow-sm"
|
|
127
|
+
aria-describedby={error ? errorId : undefined}
|
|
128
|
+
>
|
|
129
|
+
{error && (
|
|
130
|
+
<div
|
|
131
|
+
id={errorId}
|
|
132
|
+
role="alert"
|
|
133
|
+
className="border-destructive/30 bg-destructive/10 flex items-start gap-3 rounded-lg border p-3"
|
|
134
|
+
>
|
|
135
|
+
<AlertTriangle className="text-destructive mt-0.5 h-5 w-5 shrink-0" aria-hidden="true" />
|
|
136
|
+
<p className="text-destructive text-sm">{error}</p>
|
|
137
|
+
</div>
|
|
138
|
+
)}
|
|
139
|
+
<div>
|
|
140
|
+
<label htmlFor={currentId} className="text-foreground mb-1.5 block text-sm font-medium">
|
|
141
|
+
Current password
|
|
142
|
+
</label>
|
|
143
|
+
<input
|
|
144
|
+
id={currentId}
|
|
145
|
+
type="password"
|
|
146
|
+
autoComplete="current-password"
|
|
147
|
+
value={current}
|
|
148
|
+
onChange={(e) => setCurrent(e.target.value)}
|
|
149
|
+
className={inputClass}
|
|
150
|
+
required
|
|
151
|
+
autoFocus
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
<div>
|
|
155
|
+
<label htmlFor={nextId} className="text-foreground mb-1.5 block text-sm font-medium">
|
|
156
|
+
New password
|
|
157
|
+
</label>
|
|
158
|
+
<input
|
|
159
|
+
id={nextId}
|
|
160
|
+
type="password"
|
|
161
|
+
autoComplete="new-password"
|
|
162
|
+
value={next}
|
|
163
|
+
onChange={(e) => setNext(e.target.value)}
|
|
164
|
+
className={inputClass}
|
|
165
|
+
required
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
<div>
|
|
169
|
+
<label htmlFor={confirmId} className="text-foreground mb-1.5 block text-sm font-medium">
|
|
170
|
+
Confirm new password
|
|
171
|
+
</label>
|
|
172
|
+
<input
|
|
173
|
+
id={confirmId}
|
|
174
|
+
type="password"
|
|
175
|
+
autoComplete="new-password"
|
|
176
|
+
value={confirm}
|
|
177
|
+
onChange={(e) => setConfirm(e.target.value)}
|
|
178
|
+
className={inputClass}
|
|
179
|
+
required
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
<button
|
|
183
|
+
type="submit"
|
|
184
|
+
disabled={!canSubmit}
|
|
185
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90 flex w-full items-center justify-center gap-2 rounded-lg py-2.5 font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
|
186
|
+
>
|
|
187
|
+
{saving ? (
|
|
188
|
+
<>
|
|
189
|
+
<Loader2 className="h-4 w-4 animate-spin" aria-hidden="true" />
|
|
190
|
+
Saving...
|
|
191
|
+
</>
|
|
192
|
+
) : (
|
|
193
|
+
'Change password'
|
|
194
|
+
)}
|
|
195
|
+
</button>
|
|
196
|
+
</form>
|
|
197
|
+
)
|
|
198
|
+
}
|
package/src/views/ApiKeys.tsx
CHANGED
|
@@ -134,7 +134,7 @@ export function ApiKeys({ embedded = false, onNavigate }: ApiKeysProps = {}) {
|
|
|
134
134
|
</div>
|
|
135
135
|
)}
|
|
136
136
|
|
|
137
|
-
{keys.length === 0 ? (
|
|
137
|
+
{keys.length === 0 && error ? null : keys.length === 0 ? (
|
|
138
138
|
<div className="py-10 text-center">
|
|
139
139
|
<KeyRound className="text-muted-foreground mx-auto mb-3 h-8 w-8" aria-hidden="true" />
|
|
140
140
|
<p className="text-foreground mb-1 text-sm font-medium">No API keys yet</p>
|
|
@@ -414,9 +414,12 @@ export function CollectionList({ collectionSlug, config, onNavigate, role }: Col
|
|
|
414
414
|
<h1 className="text-xl font-medium sm:text-2xl" style={{ color: 'var(--txt)' }}>
|
|
415
415
|
{labels.plural}
|
|
416
416
|
</h1>
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
417
|
+
{/* No count until a load succeeds: a failed one is not "0 total". */}
|
|
418
|
+
{data ? (
|
|
419
|
+
<p className="text-sm" style={{ color: 'var(--sub)' }}>
|
|
420
|
+
{total} total
|
|
421
|
+
</p>
|
|
422
|
+
) : null}
|
|
420
423
|
</div>
|
|
421
424
|
{/* Below 769px the create action floats above the tab bar. */}
|
|
422
425
|
<div data-header-actions="" className="flex items-center gap-2">
|
|
@@ -567,7 +570,7 @@ export function CollectionList({ collectionSlug, config, onNavigate, role }: Col
|
|
|
567
570
|
)}
|
|
568
571
|
|
|
569
572
|
{/* Table — flex-1 + min-h-0 so the body scrolls; footer stays pinned. */}
|
|
570
|
-
{docs.length === 0 && !loading ? (
|
|
573
|
+
{docs.length === 0 && error ? null : docs.length === 0 && !loading ? (
|
|
571
574
|
<div
|
|
572
575
|
className="flex min-h-0 flex-1 flex-col items-center justify-center rounded-lg border p-8"
|
|
573
576
|
style={{
|
package/src/views/Dashboard.tsx
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
} from 'lucide-react'
|
|
31
31
|
import { useApiData } from '../lib/useApiData.js'
|
|
32
32
|
import { editPathForDoc } from '../lib/collection-routes.js'
|
|
33
|
+
import { createPathForCollection } from '../lib/document-editor-path.js'
|
|
33
34
|
import { AuthorAvatar } from '../components/ui/AuthorAvatar.js'
|
|
34
35
|
import { DateRangePicker } from '../components/ui/DateRangePicker.js'
|
|
35
36
|
import { Button } from '../components/ui/Button.js'
|
|
@@ -393,19 +394,20 @@ export function Dashboard({ config, session, onNavigate, basePath = '/admin' }:
|
|
|
393
394
|
const pagesSlug = pages?.slug ?? 'pages'
|
|
394
395
|
const newPostPath =
|
|
395
396
|
postTypes.length === 1
|
|
396
|
-
?
|
|
397
|
+
? createPathForCollection(config, postTypes[0]!.slug)
|
|
397
398
|
: postTypes.length > 1
|
|
398
399
|
? '/posts/new'
|
|
399
400
|
: '/posts/types/new'
|
|
401
|
+
const newPagePath = createPathForCollection(config, pagesSlug)
|
|
400
402
|
return [
|
|
401
403
|
{ label: 'New Post', onClick: () => nav(newPostPath) },
|
|
402
|
-
{ label: 'New Page', onClick: () => nav(
|
|
404
|
+
{ label: 'New Page', onClick: () => nav(newPagePath) },
|
|
403
405
|
{ label: 'Upload Media', onClick: () => nav('/media') },
|
|
404
406
|
{ label: 'New Form', onClick: () => nav('/forms') },
|
|
405
407
|
{ label: 'Run SEO Audit', onClick: () => nav('/seo?run=1') },
|
|
406
408
|
]
|
|
407
409
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
408
|
-
}, [collections, onNavigate])
|
|
410
|
+
}, [collections, config, onNavigate])
|
|
409
411
|
|
|
410
412
|
const activity = useMemo(() => {
|
|
411
413
|
const docs = stats?.recentDocuments ?? []
|
package/src/views/Forms.tsx
CHANGED
|
@@ -164,35 +164,40 @@ export function Forms({ onNavigate, initialCreateOpen = false }: FormsProps) {
|
|
|
164
164
|
|
|
165
165
|
const totalEntries = stats?.totalEntries ?? 0
|
|
166
166
|
const unread = stats?.unreadEntries ?? 0
|
|
167
|
+
// Counts only once a load has succeeded: a failed or rate-limited load must
|
|
168
|
+
// not read as "0 forms, 0 entries".
|
|
169
|
+
const showCounts = !error && stats !== null
|
|
167
170
|
|
|
168
171
|
return (
|
|
169
172
|
<div className="flex h-full min-h-0 flex-col">
|
|
170
173
|
<PageHeader
|
|
171
174
|
title="Forms"
|
|
172
175
|
subtitle={
|
|
173
|
-
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
n={totalEntries}
|
|
178
|
-
label="total entries"
|
|
179
|
-
onClick={() => onNavigate?.('/forms/entries')}
|
|
180
|
-
/>
|
|
181
|
-
<CountChip
|
|
182
|
-
n={unread}
|
|
183
|
-
label="unread"
|
|
184
|
-
tone={unread > 0 ? 'bad' : undefined}
|
|
185
|
-
onClick={() => onNavigate?.('/forms/entries?filter=unread')}
|
|
186
|
-
/>
|
|
187
|
-
{failedEmails > 0 ? (
|
|
176
|
+
showCounts ? (
|
|
177
|
+
<div className="mt-[5px] flex flex-wrap gap-1.5">
|
|
178
|
+
<CountChip n={counts.all} label={counts.all === 1 ? 'form' : 'forms'} />
|
|
179
|
+
<CountChip n={counts.active} label="active" tone="ok" />
|
|
188
180
|
<CountChip
|
|
189
|
-
n={
|
|
190
|
-
label=
|
|
191
|
-
|
|
192
|
-
onClick={() => onNavigate?.('/forms/deliveries')}
|
|
181
|
+
n={totalEntries}
|
|
182
|
+
label="total entries"
|
|
183
|
+
onClick={() => onNavigate?.('/forms/entries')}
|
|
193
184
|
/>
|
|
194
|
-
|
|
195
|
-
|
|
185
|
+
<CountChip
|
|
186
|
+
n={unread}
|
|
187
|
+
label="unread"
|
|
188
|
+
tone={unread > 0 ? 'bad' : undefined}
|
|
189
|
+
onClick={() => onNavigate?.('/forms/entries?filter=unread')}
|
|
190
|
+
/>
|
|
191
|
+
{failedEmails > 0 ? (
|
|
192
|
+
<CountChip
|
|
193
|
+
n={failedEmails}
|
|
194
|
+
label={failedEmails === 1 ? 'email didn’t arrive' : 'emails didn’t arrive'}
|
|
195
|
+
tone="bad"
|
|
196
|
+
onClick={() => onNavigate?.('/forms/deliveries')}
|
|
197
|
+
/>
|
|
198
|
+
) : null}
|
|
199
|
+
</div>
|
|
200
|
+
) : undefined
|
|
196
201
|
}
|
|
197
202
|
actions={
|
|
198
203
|
<>
|
|
@@ -246,7 +251,7 @@ export function Forms({ onNavigate, initialCreateOpen = false }: FormsProps) {
|
|
|
246
251
|
<Segmented
|
|
247
252
|
label="Status"
|
|
248
253
|
options={FILTERS}
|
|
249
|
-
counts={counts}
|
|
254
|
+
counts={showCounts ? counts : undefined}
|
|
250
255
|
value={filter}
|
|
251
256
|
onChange={(id) => setFilter(id as StatusFilter)}
|
|
252
257
|
/>
|
package/src/views/Login.tsx
CHANGED
|
@@ -22,6 +22,49 @@ export interface CaptchaConfig {
|
|
|
22
22
|
*/
|
|
23
23
|
type LoginBrandingConfig = AuthBrandingConfig
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* After an OAuth sign-in for a TOTP user, the server holds the MFA-pending
|
|
27
|
+
* token in an HttpOnly cookie and redirects here with `?mfa=totp` (#1251). The
|
|
28
|
+
* code step then sends an empty token and `/auth/totp/login` reads the cookie.
|
|
29
|
+
*/
|
|
30
|
+
const COOKIE_MFA_PENDING = ''
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Messages the OAuth callback may put in `?error=` that are safe to show as
|
|
34
|
+
* they are: fixed text from `handleOAuthCallback` (and the account-state
|
|
35
|
+
* messages it shares with password login) that tells the user what to do.
|
|
36
|
+
* Anything else (a provider's own text, or a crafted link) gets the generic
|
|
37
|
+
* line, so the sign-in screen can't be made to show arbitrary text.
|
|
38
|
+
*/
|
|
39
|
+
const OAUTH_ERROR_MESSAGES = new Set([
|
|
40
|
+
'Account is deactivated',
|
|
41
|
+
'Account is suspended',
|
|
42
|
+
'Account is locked',
|
|
43
|
+
'An account already exists for this email. Sign in with your password and link your account from Settings to enable OAuth.',
|
|
44
|
+
'This provider did not verify your email address, so it cannot be used to sign in to an existing account. Sign in with your original method and link this provider from Settings.',
|
|
45
|
+
'No account found for this email. Ask an administrator to invite you before signing in with OAuth.',
|
|
46
|
+
])
|
|
47
|
+
const OAUTH_ERROR_FALLBACK = 'Sign-in with that provider did not complete. Try again.'
|
|
48
|
+
|
|
49
|
+
/** Reads and removes the OAuth callback's `?mfa=` / `?error=` from the URL. */
|
|
50
|
+
function takeOAuthRedirectParams(): { mfa: boolean; error: string | null } {
|
|
51
|
+
if (typeof window === 'undefined') return { mfa: false, error: null }
|
|
52
|
+
const params = new URLSearchParams(window.location.search)
|
|
53
|
+
const mfa = params.get('mfa') === 'totp'
|
|
54
|
+
const raw = params.get('error')
|
|
55
|
+
if (!mfa && raw === null) return { mfa: false, error: null }
|
|
56
|
+
params.delete('mfa')
|
|
57
|
+
params.delete('error')
|
|
58
|
+
const qs = params.toString()
|
|
59
|
+
window.history.replaceState(
|
|
60
|
+
window.history.state,
|
|
61
|
+
'',
|
|
62
|
+
`${window.location.pathname}${qs ? `?${qs}` : ''}${window.location.hash}`,
|
|
63
|
+
)
|
|
64
|
+
const error = raw === null ? null : OAUTH_ERROR_MESSAGES.has(raw) ? raw : OAUTH_ERROR_FALLBACK
|
|
65
|
+
return { mfa, error }
|
|
66
|
+
}
|
|
67
|
+
|
|
25
68
|
export interface LoginProps {
|
|
26
69
|
onLogin: (
|
|
27
70
|
email: string,
|
|
@@ -254,6 +297,15 @@ export function Login({
|
|
|
254
297
|
|
|
255
298
|
const brand = useAuthBrand(branding)
|
|
256
299
|
|
|
300
|
+
// Arriving from an OAuth callback: open the code step for a TOTP user, or
|
|
301
|
+
// show why the provider sign-in was refused. Read after mount so the server
|
|
302
|
+
// render and the first client render match.
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
const { mfa, error: oauthError } = takeOAuthRedirectParams()
|
|
305
|
+
if (mfa) setMfaPendingToken(COOKIE_MFA_PENDING)
|
|
306
|
+
else if (oauthError) setError(oauthError)
|
|
307
|
+
}, [])
|
|
308
|
+
|
|
257
309
|
useCaptchaScript(captchaConfig?.provider, captchaConfig?.siteKey)
|
|
258
310
|
|
|
259
311
|
const loggedOut = hasLoggedOutQuery()
|
|
@@ -300,7 +352,7 @@ export function Login({
|
|
|
300
352
|
const handleVerifyTotp = async (e: FormEvent) => {
|
|
301
353
|
e.preventDefault()
|
|
302
354
|
const code = totpCode.trim()
|
|
303
|
-
if (!code ||
|
|
355
|
+
if (!code || mfaPendingToken === null) return
|
|
304
356
|
|
|
305
357
|
setTotpError('')
|
|
306
358
|
|
|
@@ -353,7 +405,7 @@ export function Login({
|
|
|
353
405
|
<p className="text-muted-foreground mt-2">{brandTagline}</p>
|
|
354
406
|
</div>
|
|
355
407
|
|
|
356
|
-
{mfaPendingToken ? (
|
|
408
|
+
{mfaPendingToken !== null ? (
|
|
357
409
|
<form
|
|
358
410
|
onSubmit={handleVerifyTotp}
|
|
359
411
|
className="border-border bg-card space-y-5 rounded-xl border p-6 shadow-sm"
|
|
@@ -826,13 +826,16 @@ export function MediaBrowser({ onNavigate, currentPath, role, config }: MediaBro
|
|
|
826
826
|
<p className="text-body text-sub mt-[3px] leading-[normal]">
|
|
827
827
|
Manage and optimize all your media assets
|
|
828
828
|
</p>
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
<
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
829
|
+
{/* No counts until a load succeeds: a failed one is not "0 files". */}
|
|
830
|
+
{data ? (
|
|
831
|
+
<div className="mt-[18px] flex flex-wrap items-center gap-1.5">
|
|
832
|
+
<CountChip n={mediaStats.total} label="Total Files" />
|
|
833
|
+
<CountChip n={mediaStats.images} label="Images" />
|
|
834
|
+
<CountChip n={mediaStats.videos} label="Videos" />
|
|
835
|
+
<CountChip n={mediaStats.documents} label="Documents" />
|
|
836
|
+
<CountChip n={formatStorage(mediaStats.bytes)} label="Storage used" />
|
|
837
|
+
</div>
|
|
838
|
+
) : null}
|
|
836
839
|
</div>
|
|
837
840
|
</div>
|
|
838
841
|
{/* Below 769px Upload floats above the tab bar. */}
|
|
@@ -1067,7 +1070,8 @@ export function MediaBrowser({ onNavigate, currentPath, role, config }: MediaBro
|
|
|
1067
1070
|
</div>
|
|
1068
1071
|
)}
|
|
1069
1072
|
|
|
1070
|
-
{
|
|
1073
|
+
{/* `loading` returned early above, so only error vs. empty is left. */}
|
|
1074
|
+
{filteredAndSorted.length === 0 && error ? null : filteredAndSorted.length === 0 ? (
|
|
1071
1075
|
<div className="flex flex-col items-center justify-center py-16 text-center">
|
|
1072
1076
|
<div className="bg-muted mb-4 flex h-12 w-12 items-center justify-center rounded-full">
|
|
1073
1077
|
<ImageIcon className="text-muted-foreground h-6 w-6" />
|
|
@@ -571,11 +571,14 @@ export function PagesListView({ onNavigate, role, config }: PagesListViewProps)
|
|
|
571
571
|
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
572
572
|
<div className="flex flex-col gap-1">
|
|
573
573
|
<h1 className="text-[var(--txt)]">Pages</h1>
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
574
|
+
{/* No count until a load succeeds: a failed one is not "0 pages". */}
|
|
575
|
+
{dataset ? (
|
|
576
|
+
<p className="text-sm text-[var(--sub)]">
|
|
577
|
+
{treeMode
|
|
578
|
+
? `${grandTotal} page${grandTotal === 1 ? '' : 's'} total`
|
|
579
|
+
: `${grandTotal} page${grandTotal === 1 ? '' : 's'} · organized by tags`}
|
|
580
|
+
</p>
|
|
581
|
+
) : null}
|
|
579
582
|
</div>
|
|
580
583
|
{/* Below 769px the create action floats above the tab bar. */}
|
|
581
584
|
<div data-header-actions="" className="flex items-center gap-2">
|
|
@@ -646,11 +649,13 @@ export function PagesListView({ onNavigate, role, config }: PagesListViewProps)
|
|
|
646
649
|
{!treeMode && <ColumnsMenu hidden={hiddenCols} onToggle={toggleColumn} />}
|
|
647
650
|
|
|
648
651
|
<span className="ml-auto text-sm text-[var(--sub)] tabular-nums">
|
|
649
|
-
{
|
|
650
|
-
?
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
652
|
+
{!dataset
|
|
653
|
+
? null
|
|
654
|
+
: treeMode
|
|
655
|
+
? treeFiltersActive
|
|
656
|
+
? `${treeRows.length} result${treeRows.length === 1 ? '' : 's'}`
|
|
657
|
+
: `${grandTotal} page${grandTotal === 1 ? '' : 's'}`
|
|
658
|
+
: `${total} of ${grandTotal}`}
|
|
654
659
|
</span>
|
|
655
660
|
</div>
|
|
656
661
|
|
|
@@ -966,7 +971,7 @@ export function PagesListView({ onNavigate, role, config }: PagesListViewProps)
|
|
|
966
971
|
|
|
967
972
|
{/* Pagination only for the flat (ungrouped) view — shrink-0 so it
|
|
968
973
|
stays visible below the scrolling table body (#736). */}
|
|
969
|
-
{!grouped && (
|
|
974
|
+
{!grouped && dataset && (
|
|
970
975
|
<div className="shrink-0">
|
|
971
976
|
<PaginationFooter
|
|
972
977
|
page={page}
|
package/src/views/Pages.tsx
CHANGED
|
@@ -284,9 +284,12 @@ export function Pages({ onNavigate }: PagesProps) {
|
|
|
284
284
|
</button>
|
|
285
285
|
<div>
|
|
286
286
|
<h1 className="text-foreground">Pages</h1>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
{/* No count until a load succeeds: a failed one is not "0 pages". */}
|
|
288
|
+
{data ? (
|
|
289
|
+
<p className="text-muted-foreground text-sm">
|
|
290
|
+
{totalCount} page{totalCount !== 1 ? 's' : ''}
|
|
291
|
+
</p>
|
|
292
|
+
) : null}
|
|
290
293
|
</div>
|
|
291
294
|
</div>
|
|
292
295
|
<button
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
cardTable,
|
|
49
49
|
} from '../../components/ui/card-table.js'
|
|
50
50
|
import { TIER_MEDIA, useMediaQuery } from '../../lib/tiers.js'
|
|
51
|
+
import { createPathForCollection } from '../../lib/document-editor-path.js'
|
|
51
52
|
import { CardListControls, type CardSortOption } from '../../components/ui/CardListControls.js'
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -182,9 +183,9 @@ export function PostsListView({ onNavigate, role, config }: PostsListViewProps)
|
|
|
182
183
|
// none → the Post Type setup instructions.
|
|
183
184
|
const newPostPath = useMemo(() => {
|
|
184
185
|
const typeList = data?.types ?? []
|
|
185
|
-
if (typeList.length === 1) return
|
|
186
|
+
if (typeList.length === 1) return createPathForCollection(config, typeList[0]!.slug)
|
|
186
187
|
return typeList.length > 1 ? '/posts/new' : '/posts/types/new'
|
|
187
|
-
}, [data?.types])
|
|
188
|
+
}, [data?.types, config])
|
|
188
189
|
const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE))
|
|
189
190
|
const posts = data?.posts ?? []
|
|
190
191
|
const listScrollRef = useRef<HTMLDivElement>(null)
|
|
@@ -330,9 +331,12 @@ export function PostsListView({ onNavigate, role, config }: PostsListViewProps)
|
|
|
330
331
|
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
331
332
|
<div className="flex flex-col gap-1">
|
|
332
333
|
<h1 className="text-foreground">Posts</h1>
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
{/* No count until a load succeeds: a failed one is not "0 posts". */}
|
|
335
|
+
{data ? (
|
|
336
|
+
<p className="text-muted-foreground text-sm">
|
|
337
|
+
{totalAll} total post{totalAll === 1 ? '' : 's'} across all types
|
|
338
|
+
</p>
|
|
339
|
+
) : null}
|
|
336
340
|
</div>
|
|
337
341
|
{/* Below 769px the create action floats above the tab bar. */}
|
|
338
342
|
<div data-header-actions="" className="flex items-center gap-2">
|
|
@@ -367,7 +371,7 @@ export function PostsListView({ onNavigate, role, config }: PostsListViewProps)
|
|
|
367
371
|
setPage(1)
|
|
368
372
|
}}
|
|
369
373
|
authors={authors}
|
|
370
|
-
resultCount={total}
|
|
374
|
+
resultCount={data ? total : null}
|
|
371
375
|
onManageTypes={() => onNavigate('/posts/types')}
|
|
372
376
|
/>
|
|
373
377
|
|
|
@@ -587,15 +591,17 @@ export function PostsListView({ onNavigate, role, config }: PostsListViewProps)
|
|
|
587
591
|
</div>
|
|
588
592
|
|
|
589
593
|
{/* shrink-0 so pagination stays visible below the scrolling table (#736). */}
|
|
590
|
-
|
|
591
|
-
<
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
594
|
+
{data ? (
|
|
595
|
+
<div className="shrink-0">
|
|
596
|
+
<PaginationFooter
|
|
597
|
+
page={page}
|
|
598
|
+
totalPages={totalPages}
|
|
599
|
+
total={total}
|
|
600
|
+
pageSize={PAGE_SIZE}
|
|
601
|
+
onPage={setPage}
|
|
602
|
+
/>
|
|
603
|
+
</div>
|
|
604
|
+
) : null}
|
|
599
605
|
</div>
|
|
600
606
|
|
|
601
607
|
<ConfirmDialog
|
|
@@ -750,7 +756,8 @@ function ControlsRow({
|
|
|
750
756
|
author: string
|
|
751
757
|
onAuthorChange: (a: string) => void
|
|
752
758
|
authors: { id: string; name: string }[]
|
|
753
|
-
|
|
759
|
+
/** `null` until a load succeeds, so a failed load shows no count. */
|
|
760
|
+
resultCount: number | null
|
|
754
761
|
onManageTypes: () => void
|
|
755
762
|
}) {
|
|
756
763
|
return (
|
|
@@ -801,9 +808,11 @@ function ControlsRow({
|
|
|
801
808
|
<Settings className="h-3.5 w-3.5" aria-hidden />
|
|
802
809
|
Manage types
|
|
803
810
|
</button>
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
811
|
+
{resultCount === null ? null : (
|
|
812
|
+
<span className="text-muted-foreground text-sm tabular-nums">
|
|
813
|
+
{resultCount} {resultCount === 1 ? 'result' : 'results'}
|
|
814
|
+
</span>
|
|
815
|
+
)}
|
|
807
816
|
</div>
|
|
808
817
|
</div>
|
|
809
818
|
)
|
package/src/views/Redirects.tsx
CHANGED
|
@@ -151,9 +151,11 @@ export function Redirects({ onNavigate }: RedirectsProps) {
|
|
|
151
151
|
<div className="mb-4 flex items-center justify-between">
|
|
152
152
|
<div>
|
|
153
153
|
<h1 className="text-foreground mb-1">Redirects</h1>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
{data ? (
|
|
155
|
+
<p className="text-muted-foreground text-sm">
|
|
156
|
+
{filteredAndSorted.length} total redirects
|
|
157
|
+
</p>
|
|
158
|
+
) : null}
|
|
157
159
|
</div>
|
|
158
160
|
<button
|
|
159
161
|
type="button"
|
|
@@ -189,7 +191,8 @@ export function Redirects({ onNavigate }: RedirectsProps) {
|
|
|
189
191
|
</div>
|
|
190
192
|
</div>
|
|
191
193
|
|
|
192
|
-
{
|
|
194
|
+
{/* `loading` returned early above, so only error vs. empty is left. */}
|
|
195
|
+
{filteredAndSorted.length === 0 && error ? null : filteredAndSorted.length === 0 ? (
|
|
193
196
|
<div className="flex flex-col items-center justify-center py-16 text-center">
|
|
194
197
|
<div className="bg-muted mb-4 flex h-12 w-12 items-center justify-center rounded-full">
|
|
195
198
|
<ArrowRightLeft className="text-muted-foreground h-6 w-6" />
|