@prenta/admin 2.11.2 → 2.12.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 +21 -0
- package/dist/__tests__/components/modal.render.test.js +30 -1
- package/dist/__tests__/components/modal.render.test.js.map +1 -1
- package/dist/__tests__/lib/media-download.test.d.ts +2 -0
- package/dist/__tests__/lib/media-download.test.d.ts.map +1 -0
- package/dist/__tests__/lib/media-download.test.js +14 -0
- package/dist/__tests__/lib/media-download.test.js.map +1 -0
- package/dist/__tests__/views/media-browser.render.test.d.ts +2 -0
- package/dist/__tests__/views/media-browser.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/media-browser.render.test.js +270 -0
- package/dist/__tests__/views/media-browser.render.test.js.map +1 -0
- package/dist/__tests__/views/media-grid.test.js +12 -1
- package/dist/__tests__/views/media-grid.test.js.map +1 -1
- package/dist/__tests__/views/search-data-card.render.test.d.ts +2 -0
- package/dist/__tests__/views/search-data-card.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/search-data-card.render.test.js +236 -0
- package/dist/__tests__/views/search-data-card.render.test.js.map +1 -0
- package/dist/__tests__/views/seo-settings.render.test.js +8 -4
- package/dist/__tests__/views/seo-settings.render.test.js.map +1 -1
- package/dist/components/MediaLightbox.d.ts +22 -0
- package/dist/components/MediaLightbox.d.ts.map +1 -0
- package/dist/components/MediaLightbox.js +38 -0
- package/dist/components/MediaLightbox.js.map +1 -0
- package/dist/components/ui/ConfirmDialog.d.ts +3 -1
- package/dist/components/ui/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/ui/ConfirmDialog.js +2 -2
- package/dist/components/ui/ConfirmDialog.js.map +1 -1
- package/dist/components/ui/Modal.d.ts +7 -1
- package/dist/components/ui/Modal.d.ts.map +1 -1
- package/dist/components/ui/Modal.js +4 -2
- package/dist/components/ui/Modal.js.map +1 -1
- package/dist/lib/dialog-return-focus.d.ts +10 -0
- package/dist/lib/dialog-return-focus.d.ts.map +1 -0
- package/dist/lib/dialog-return-focus.js +26 -0
- package/dist/lib/dialog-return-focus.js.map +1 -0
- package/dist/lib/media-download.d.ts +8 -0
- package/dist/lib/media-download.d.ts.map +1 -0
- package/dist/lib/media-download.js +21 -0
- package/dist/lib/media-download.js.map +1 -0
- package/dist/prenta-admin.css +1 -1
- package/dist/views/MediaBrowser.d.ts +34 -0
- package/dist/views/MediaBrowser.d.ts.map +1 -1
- package/dist/views/MediaBrowser.js +190 -51
- package/dist/views/MediaBrowser.js.map +1 -1
- package/dist/views/MediaSeoAudit.d.ts +6 -0
- package/dist/views/MediaSeoAudit.d.ts.map +1 -1
- package/dist/views/MediaSeoAudit.js +12 -0
- package/dist/views/MediaSeoAudit.js.map +1 -1
- package/dist/views/settings/SearchDataCard.d.ts.map +1 -1
- package/dist/views/settings/SearchDataCard.js +162 -24
- package/dist/views/settings/SearchDataCard.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/components/modal.render.test.tsx +52 -0
- package/src/__tests__/lib/media-download.test.ts +23 -0
- package/src/__tests__/views/media-browser.render.test.tsx +325 -0
- package/src/__tests__/views/media-grid.test.ts +13 -1
- package/src/__tests__/views/search-data-card.render.test.tsx +275 -0
- package/src/__tests__/views/seo-settings.render.test.tsx +15 -5
- package/src/components/MediaLightbox.tsx +127 -0
- package/src/components/ui/ConfirmDialog.tsx +4 -0
- package/src/components/ui/Modal.tsx +10 -0
- package/src/lib/dialog-return-focus.ts +33 -0
- package/src/lib/media-download.ts +18 -0
- package/src/views/MediaBrowser.tsx +367 -143
- package/src/views/MediaSeoAudit.tsx +11 -0
- package/src/views/settings/SearchDataCard.tsx +306 -45
|
@@ -75,6 +75,17 @@ function scoreBarClass(score: number): string {
|
|
|
75
75
|
return 'bg-[var(--err)]'
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Grid card score badge (Media.html `.seo-score-badge`). The kit fills the
|
|
80
|
+
* badge and sets white text, which fails 4.5:1 on amber and on every dark-mode
|
|
81
|
+
* tone; the tint/tone pairs clear it in both modes (CONFLICTS.md §8, §9).
|
|
82
|
+
*/
|
|
83
|
+
export function scoreBadgeClass(score: number): string {
|
|
84
|
+
if (score >= 80) return 'bg-[var(--suc-l)] text-[var(--suc)]'
|
|
85
|
+
if (score >= 30) return 'bg-[var(--warn-l)] text-[var(--warn)]'
|
|
86
|
+
return 'bg-[var(--err-l)] text-[var(--err)]'
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
function scoreLabel(score: number): string {
|
|
79
90
|
if (score >= 80) return 'Good'
|
|
80
91
|
if (score >= 55) return 'Fair'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useCallback, useEffect, useId, useState } from 'react'
|
|
3
|
+
import { useCallback, useEffect, useId, useRef, useState } from 'react'
|
|
4
4
|
import { AlertTriangle, CheckCircle2, KeyRound, Loader2, PlugZap, RefreshCw, X } from 'lucide-react'
|
|
5
5
|
import { toast } from 'sonner'
|
|
6
|
+
import { searchConsolePropertyError } from '@prenta/core/seo/search-console-property'
|
|
6
7
|
import { cmsApi } from '../../lib/api.js'
|
|
7
8
|
import { SettingsCard } from './components.js'
|
|
8
9
|
|
|
@@ -28,6 +29,19 @@ interface SearchConsoleStatus {
|
|
|
28
29
|
suggestedProperty: string | null
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
interface SearchConsoleProperty {
|
|
33
|
+
siteUrl: string
|
|
34
|
+
permissionLevel: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** `GET /seo/search-console/properties`: the properties the stored key can read. */
|
|
38
|
+
type PropertyList =
|
|
39
|
+
| { state: 'idle' | 'loading' }
|
|
40
|
+
| { state: 'ok'; properties: SearchConsoleProperty[]; serviceAccountEmail: string }
|
|
41
|
+
| { state: 'error'; message: string }
|
|
42
|
+
|
|
43
|
+
const FIELD_ERROR_CLASS = 'text-destructive mt-1 flex items-start gap-1 text-sm'
|
|
44
|
+
|
|
31
45
|
function KeyStoredBadge() {
|
|
32
46
|
return (
|
|
33
47
|
<span className="text-muted-foreground border-border bg-muted inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-xs">
|
|
@@ -45,8 +59,11 @@ function KeyStoredBadge() {
|
|
|
45
59
|
*/
|
|
46
60
|
export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
47
61
|
const propertyId = useId()
|
|
62
|
+
const propertyHelpId = useId()
|
|
48
63
|
const keyId = useId()
|
|
64
|
+
const keyErrorId = useId()
|
|
49
65
|
const cruxId = useId()
|
|
66
|
+
const cruxErrorId = useId()
|
|
50
67
|
|
|
51
68
|
const [status, setStatus] = useState<SearchConsoleStatus | null>(null)
|
|
52
69
|
const [loading, setLoading] = useState(true)
|
|
@@ -59,6 +76,43 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
59
76
|
const [testing, setTesting] = useState(false)
|
|
60
77
|
const [syncing, setSyncing] = useState(false)
|
|
61
78
|
|
|
79
|
+
// Inline, per-field errors. The key, property and CrUX key save in separate
|
|
80
|
+
// requests, so a bad property never discards a good key (#1102).
|
|
81
|
+
const [propertyTouched, setPropertyTouched] = useState(false)
|
|
82
|
+
const [propertyServerError, setPropertyServerError] = useState<string | null>(null)
|
|
83
|
+
const [keyError, setKeyError] = useState<string | null>(null)
|
|
84
|
+
const [cruxError, setCruxError] = useState<string | null>(null)
|
|
85
|
+
|
|
86
|
+
const [propertyList, setPropertyList] = useState<PropertyList>({ state: 'idle' })
|
|
87
|
+
const [manualProperty, setManualProperty] = useState(false)
|
|
88
|
+
|
|
89
|
+
// Each lookup (and every key change) takes a new generation; a response is
|
|
90
|
+
// only applied if no newer one started, so a slow lookup for a replaced or
|
|
91
|
+
// removed key can't bring back its account's list.
|
|
92
|
+
const propertiesGeneration = useRef(0)
|
|
93
|
+
|
|
94
|
+
const loadProperties = useCallback(async () => {
|
|
95
|
+
const generation = ++propertiesGeneration.current
|
|
96
|
+
setPropertyList({ state: 'loading' })
|
|
97
|
+
const res = await cmsApi<
|
|
98
|
+
| { ok: true; properties: SearchConsoleProperty[]; serviceAccountEmail: string }
|
|
99
|
+
| { ok: false; code: string; message: string }
|
|
100
|
+
>('/seo/search-console/properties')
|
|
101
|
+
if (generation !== propertiesGeneration.current) return
|
|
102
|
+
if (res.data?.ok) {
|
|
103
|
+
setPropertyList({
|
|
104
|
+
state: 'ok',
|
|
105
|
+
properties: res.data.properties,
|
|
106
|
+
serviceAccountEmail: res.data.serviceAccountEmail,
|
|
107
|
+
})
|
|
108
|
+
} else {
|
|
109
|
+
setPropertyList({
|
|
110
|
+
state: 'error',
|
|
111
|
+
message: res.data?.message ?? res.error ?? 'Could not load your Search Console properties',
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
}, [])
|
|
115
|
+
|
|
62
116
|
const load = useCallback(async () => {
|
|
63
117
|
setLoading(true)
|
|
64
118
|
setLoadError(null)
|
|
@@ -66,40 +120,111 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
66
120
|
if (res.data) {
|
|
67
121
|
setStatus(res.data)
|
|
68
122
|
setProperty(res.data.propertyUrl ?? '')
|
|
123
|
+
if (res.data.hasServiceAccountKey) {
|
|
124
|
+
void loadProperties()
|
|
125
|
+
} else {
|
|
126
|
+
propertiesGeneration.current++
|
|
127
|
+
setPropertyList({ state: 'idle' })
|
|
128
|
+
}
|
|
69
129
|
} else {
|
|
70
130
|
setLoadError(res.error ?? 'Failed to load search data settings')
|
|
71
131
|
}
|
|
72
132
|
setLoading(false)
|
|
73
|
-
}, [])
|
|
133
|
+
}, [loadProperties])
|
|
74
134
|
|
|
75
135
|
useEffect(() => {
|
|
76
136
|
void load()
|
|
77
137
|
}, [load])
|
|
78
138
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
139
|
+
const propertyChanged = property.trim() !== (status?.propertyUrl ?? '')
|
|
140
|
+
const dirty = propertyChanged || serviceKey.trim() !== '' || cruxKey.trim() !== ''
|
|
141
|
+
const propertyFormatError = searchConsolePropertyError(property)
|
|
142
|
+
const propertyError =
|
|
143
|
+
propertyServerError ?? (propertyTouched || propertyChanged ? propertyFormatError : null)
|
|
144
|
+
|
|
145
|
+
async function put(body: Record<string, string>): Promise<string | null> {
|
|
146
|
+
const res = await cmsApi('/seo/search-console', { method: 'PUT', body: JSON.stringify(body) })
|
|
147
|
+
return res.error ?? null
|
|
148
|
+
}
|
|
83
149
|
|
|
84
|
-
async function save(
|
|
150
|
+
async function save() {
|
|
151
|
+
setPropertyTouched(true)
|
|
152
|
+
setPropertyServerError(null)
|
|
153
|
+
setKeyError(null)
|
|
154
|
+
setCruxError(null)
|
|
85
155
|
setSaving(true)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
156
|
+
|
|
157
|
+
const saved: string[] = []
|
|
158
|
+
let failed = false
|
|
159
|
+
|
|
160
|
+
const key = serviceKey.trim()
|
|
161
|
+
if (key) {
|
|
162
|
+
const err = await put({ serviceAccountKey: key })
|
|
163
|
+
if (err) {
|
|
164
|
+
setKeyError(err)
|
|
165
|
+
failed = true
|
|
166
|
+
} else {
|
|
167
|
+
// The old key's lookup is stale now; the reload below starts a new one.
|
|
168
|
+
propertiesGeneration.current++
|
|
169
|
+
setServiceKey('')
|
|
170
|
+
saved.push('service account key')
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const crux = cruxKey.trim()
|
|
175
|
+
if (crux) {
|
|
176
|
+
const err = await put({ cruxApiKey: crux })
|
|
177
|
+
if (err) {
|
|
178
|
+
setCruxError(err)
|
|
179
|
+
failed = true
|
|
180
|
+
} else {
|
|
181
|
+
setCruxKey('')
|
|
182
|
+
saved.push('CrUX key')
|
|
183
|
+
}
|
|
90
184
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
185
|
+
|
|
186
|
+
if (propertyChanged) {
|
|
187
|
+
if (propertyFormatError) {
|
|
188
|
+
failed = true
|
|
189
|
+
} else {
|
|
190
|
+
const err = await put({ propertyUrl: property.trim() })
|
|
191
|
+
if (err) {
|
|
192
|
+
setPropertyServerError(err)
|
|
193
|
+
failed = true
|
|
194
|
+
} else {
|
|
195
|
+
saved.push('property')
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
95
200
|
setSaving(false)
|
|
96
|
-
if (
|
|
97
|
-
toast.
|
|
201
|
+
if (saved.length > 0) {
|
|
202
|
+
toast.success(
|
|
203
|
+
failed
|
|
204
|
+
? `Saved the ${saved.join(' and ')}. Fix the highlighted field to save the rest.`
|
|
205
|
+
: 'Search data settings saved',
|
|
206
|
+
)
|
|
207
|
+
const keepProperty = failed && propertyChanged ? property : null
|
|
208
|
+
await load()
|
|
209
|
+
if (keepProperty !== null) setProperty(keepProperty)
|
|
210
|
+
} else if (failed) {
|
|
211
|
+
toast.error('Nothing was saved. Fix the highlighted field.')
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function removeKey(field: 'serviceAccountKey' | 'cruxApiKey') {
|
|
216
|
+
if (field === 'serviceAccountKey') {
|
|
217
|
+
propertiesGeneration.current++
|
|
218
|
+
setPropertyList({ state: 'idle' })
|
|
219
|
+
}
|
|
220
|
+
setSaving(true)
|
|
221
|
+
const err = await put({ [field]: '' })
|
|
222
|
+
setSaving(false)
|
|
223
|
+
if (err) {
|
|
224
|
+
toast.error(err)
|
|
98
225
|
return
|
|
99
226
|
}
|
|
100
|
-
toast.success('
|
|
101
|
-
setServiceKey('')
|
|
102
|
-
setCruxKey('')
|
|
227
|
+
toast.success('Key removed')
|
|
103
228
|
await load()
|
|
104
229
|
}
|
|
105
230
|
|
|
@@ -187,6 +312,13 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
187
312
|
}
|
|
188
313
|
|
|
189
314
|
const lastSync = status?.lastSyncAt ? new Date(status.lastSyncAt).toLocaleString() : 'Never'
|
|
315
|
+
const pickerProperties =
|
|
316
|
+
propertyList.state === 'ok' && propertyList.properties.length > 0
|
|
317
|
+
? propertyList.properties
|
|
318
|
+
: null
|
|
319
|
+
// An invalid value (e.g. kept after a partial save) shows in the text field,
|
|
320
|
+
// where its error and the "Use sc-domain:…" fix are.
|
|
321
|
+
const showPicker = Boolean(pickerProperties) && !manualProperty && !propertyFormatError
|
|
190
322
|
|
|
191
323
|
return (
|
|
192
324
|
<SettingsCard
|
|
@@ -215,33 +347,138 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
215
347
|
<label htmlFor={propertyId} className={LABEL_CLASS}>
|
|
216
348
|
Search Console property
|
|
217
349
|
</label>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
350
|
+
{showPicker && pickerProperties ? (
|
|
351
|
+
<select
|
|
352
|
+
id={propertyId}
|
|
353
|
+
value={property}
|
|
354
|
+
disabled={!canEdit}
|
|
355
|
+
aria-invalid={propertyError ? true : undefined}
|
|
356
|
+
aria-describedby={propertyHelpId}
|
|
357
|
+
onChange={(e) => {
|
|
358
|
+
setProperty(e.target.value)
|
|
359
|
+
setPropertyServerError(null)
|
|
360
|
+
}}
|
|
361
|
+
className={INPUT_CLASS}
|
|
362
|
+
>
|
|
363
|
+
<option value="">Choose a property…</option>
|
|
364
|
+
{pickerProperties.map((p) => (
|
|
365
|
+
<option key={p.siteUrl} value={p.siteUrl}>
|
|
366
|
+
{p.siteUrl}
|
|
367
|
+
</option>
|
|
368
|
+
))}
|
|
369
|
+
{property && !pickerProperties.some((p) => p.siteUrl === property) && (
|
|
370
|
+
<option value={property}>{property} (not granted to this key)</option>
|
|
371
|
+
)}
|
|
372
|
+
</select>
|
|
373
|
+
) : (
|
|
374
|
+
<input
|
|
375
|
+
id={propertyId}
|
|
376
|
+
type="text"
|
|
377
|
+
autoComplete="off"
|
|
378
|
+
spellCheck={false}
|
|
379
|
+
value={property}
|
|
380
|
+
disabled={!canEdit}
|
|
381
|
+
aria-invalid={propertyError ? true : undefined}
|
|
382
|
+
aria-describedby={propertyHelpId}
|
|
383
|
+
placeholder={status?.suggestedProperty ?? 'sc-domain:example.com'}
|
|
384
|
+
onChange={(e) => {
|
|
385
|
+
setProperty(e.target.value)
|
|
386
|
+
setPropertyServerError(null)
|
|
387
|
+
}}
|
|
388
|
+
onBlur={() => setPropertyTouched(true)}
|
|
389
|
+
className={INPUT_CLASS}
|
|
390
|
+
/>
|
|
391
|
+
)}
|
|
392
|
+
<div id={propertyHelpId}>
|
|
393
|
+
{propertyError && (
|
|
394
|
+
<p role="alert" className={FIELD_ERROR_CLASS}>
|
|
395
|
+
<AlertTriangle size={14} className="mt-0.5 shrink-0" aria-hidden="true" />
|
|
396
|
+
<span>{propertyError}</span>
|
|
397
|
+
</p>
|
|
398
|
+
)}
|
|
399
|
+
{status?.hasServiceAccountKey && propertyList.state === 'loading' && (
|
|
400
|
+
<p className="text-muted-foreground mt-1 inline-flex items-center gap-1 text-sm">
|
|
401
|
+
<Loader2
|
|
402
|
+
size={13}
|
|
403
|
+
className="animate-spin motion-reduce:animate-none"
|
|
404
|
+
aria-hidden="true"
|
|
405
|
+
/>
|
|
406
|
+
Loading the properties this key can read…
|
|
407
|
+
</p>
|
|
408
|
+
)}
|
|
409
|
+
{propertyList.state === 'ok' && propertyList.properties.length === 0 && (
|
|
410
|
+
<p className="text-muted-foreground mt-1 text-sm">
|
|
411
|
+
No properties yet — add{' '}
|
|
412
|
+
<span className="text-foreground font-medium">
|
|
413
|
+
{propertyList.serviceAccountEmail}
|
|
414
|
+
</span>{' '}
|
|
415
|
+
in Search Console → Settings → Users and permissions, then{' '}
|
|
235
416
|
<button
|
|
236
417
|
type="button"
|
|
237
|
-
onClick={() =>
|
|
418
|
+
onClick={() => void loadProperties()}
|
|
238
419
|
className="text-brand hover:underline"
|
|
239
420
|
>
|
|
240
|
-
|
|
421
|
+
refresh the list
|
|
241
422
|
</button>
|
|
242
|
-
|
|
423
|
+
.
|
|
424
|
+
</p>
|
|
243
425
|
)}
|
|
244
|
-
|
|
426
|
+
{propertyList.state === 'error' && (
|
|
427
|
+
<p className="text-muted-foreground mt-1 text-sm">
|
|
428
|
+
Couldn’t list your properties: {propertyList.message}{' '}
|
|
429
|
+
<button
|
|
430
|
+
type="button"
|
|
431
|
+
onClick={() => void loadProperties()}
|
|
432
|
+
className="text-brand hover:underline"
|
|
433
|
+
>
|
|
434
|
+
Try again
|
|
435
|
+
</button>
|
|
436
|
+
</p>
|
|
437
|
+
)}
|
|
438
|
+
{!showPicker && (
|
|
439
|
+
<p className="text-muted-foreground mt-1 text-sm">
|
|
440
|
+
Domain property (<code>sc-domain:example.com</code>) or URL prefix (
|
|
441
|
+
<code>https://example.com/</code>) exactly as it appears in Search Console.
|
|
442
|
+
{status?.suggestedProperty &&
|
|
443
|
+
(!property.trim() || propertyFormatError) &&
|
|
444
|
+
property.trim() !== status.suggestedProperty &&
|
|
445
|
+
canEdit && (
|
|
446
|
+
<>
|
|
447
|
+
{' '}
|
|
448
|
+
<button
|
|
449
|
+
type="button"
|
|
450
|
+
onClick={() => {
|
|
451
|
+
setProperty(status.suggestedProperty ?? '')
|
|
452
|
+
setPropertyServerError(null)
|
|
453
|
+
}}
|
|
454
|
+
className="text-brand hover:underline"
|
|
455
|
+
>
|
|
456
|
+
Use {status.suggestedProperty}
|
|
457
|
+
</button>
|
|
458
|
+
</>
|
|
459
|
+
)}
|
|
460
|
+
</p>
|
|
461
|
+
)}
|
|
462
|
+
{pickerProperties && canEdit && (
|
|
463
|
+
<button
|
|
464
|
+
type="button"
|
|
465
|
+
onClick={() => {
|
|
466
|
+
if (showPicker) {
|
|
467
|
+
setManualProperty(true)
|
|
468
|
+
return
|
|
469
|
+
}
|
|
470
|
+
if (propertyFormatError) {
|
|
471
|
+
setProperty('')
|
|
472
|
+
setPropertyServerError(null)
|
|
473
|
+
}
|
|
474
|
+
setManualProperty(false)
|
|
475
|
+
}}
|
|
476
|
+
className="text-brand mt-1 text-sm hover:underline"
|
|
477
|
+
>
|
|
478
|
+
{showPicker ? 'Enter it manually' : 'Choose from your properties'}
|
|
479
|
+
</button>
|
|
480
|
+
)}
|
|
481
|
+
</div>
|
|
245
482
|
</div>
|
|
246
483
|
|
|
247
484
|
{/* Service account key */}
|
|
@@ -262,9 +499,20 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
262
499
|
? 'Paste a new key to replace the stored one'
|
|
263
500
|
: '{ "type": "service_account", "client_email": … }'
|
|
264
501
|
}
|
|
265
|
-
onChange={(e) =>
|
|
502
|
+
onChange={(e) => {
|
|
503
|
+
setServiceKey(e.target.value)
|
|
504
|
+
setKeyError(null)
|
|
505
|
+
}}
|
|
506
|
+
aria-invalid={keyError ? true : undefined}
|
|
507
|
+
aria-describedby={keyError ? keyErrorId : undefined}
|
|
266
508
|
className={`${INPUT_CLASS} resize-y font-mono text-sm`}
|
|
267
509
|
/>
|
|
510
|
+
{keyError && (
|
|
511
|
+
<p id={keyErrorId} role="alert" className={FIELD_ERROR_CLASS}>
|
|
512
|
+
<AlertTriangle size={14} className="mt-0.5 shrink-0" aria-hidden="true" />
|
|
513
|
+
<span>{keyError}</span>
|
|
514
|
+
</p>
|
|
515
|
+
)}
|
|
268
516
|
<p className="text-muted-foreground mt-1 text-sm">
|
|
269
517
|
{status?.serviceAccountEmail ? (
|
|
270
518
|
<>
|
|
@@ -279,7 +527,8 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
279
527
|
{status?.hasServiceAccountKey && canEdit && (
|
|
280
528
|
<button
|
|
281
529
|
type="button"
|
|
282
|
-
onClick={() => void
|
|
530
|
+
onClick={() => void removeKey('serviceAccountKey')}
|
|
531
|
+
disabled={saving}
|
|
283
532
|
className="text-muted-foreground hover:text-destructive mt-1 inline-flex items-center gap-1 rounded-md text-sm transition-colors"
|
|
284
533
|
>
|
|
285
534
|
<X size={13} aria-hidden="true" />
|
|
@@ -303,16 +552,28 @@ export function SearchDataCard({ canEdit }: { canEdit: boolean }) {
|
|
|
303
552
|
placeholder={
|
|
304
553
|
status?.hasCruxApiKey ? 'Paste a new key to replace the stored one' : 'AIza…'
|
|
305
554
|
}
|
|
306
|
-
onChange={(e) =>
|
|
555
|
+
onChange={(e) => {
|
|
556
|
+
setCruxKey(e.target.value)
|
|
557
|
+
setCruxError(null)
|
|
558
|
+
}}
|
|
559
|
+
aria-invalid={cruxError ? true : undefined}
|
|
560
|
+
aria-describedby={cruxError ? cruxErrorId : undefined}
|
|
307
561
|
className={INPUT_CLASS}
|
|
308
562
|
/>
|
|
563
|
+
{cruxError && (
|
|
564
|
+
<p id={cruxErrorId} role="alert" className={FIELD_ERROR_CLASS}>
|
|
565
|
+
<AlertTriangle size={14} className="mt-0.5 shrink-0" aria-hidden="true" />
|
|
566
|
+
<span>{cruxError}</span>
|
|
567
|
+
</p>
|
|
568
|
+
)}
|
|
309
569
|
<p className="text-muted-foreground mt-1 text-sm">
|
|
310
570
|
Optional — collects real-user Core Web Vitals (LCP, INP, CLS) from the Chrome UX Report.
|
|
311
571
|
</p>
|
|
312
572
|
{status?.hasCruxApiKey && canEdit && (
|
|
313
573
|
<button
|
|
314
574
|
type="button"
|
|
315
|
-
onClick={() => void
|
|
575
|
+
onClick={() => void removeKey('cruxApiKey')}
|
|
576
|
+
disabled={saving}
|
|
316
577
|
className="text-muted-foreground hover:text-destructive mt-1 inline-flex items-center gap-1 rounded-md text-sm transition-colors"
|
|
317
578
|
>
|
|
318
579
|
<X size={13} aria-hidden="true" />
|