@asteby/metacore-runtime-react 53.4.0 → 53.5.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +73 -0
  3. package/dist/display-value.d.ts +11 -0
  4. package/dist/display-value.d.ts.map +1 -1
  5. package/dist/display-value.js +26 -1
  6. package/dist/dynamic-columns.d.ts.map +1 -1
  7. package/dist/dynamic-columns.js +17 -6
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -0
  11. package/dist/setup/addon-config-surface.d.ts +110 -0
  12. package/dist/setup/addon-config-surface.d.ts.map +1 -0
  13. package/dist/setup/addon-config-surface.js +553 -0
  14. package/dist/setup/connector-form-model.d.ts +40 -0
  15. package/dist/setup/connector-form-model.d.ts.map +1 -0
  16. package/dist/setup/connector-form-model.js +76 -0
  17. package/dist/setup/flow-model.d.ts +49 -0
  18. package/dist/setup/flow-model.d.ts.map +1 -0
  19. package/dist/setup/flow-model.js +124 -0
  20. package/dist/setup/health-card.d.ts +25 -0
  21. package/dist/setup/health-card.d.ts.map +1 -0
  22. package/dist/setup/health-card.js +21 -0
  23. package/dist/setup/index.d.ts +11 -0
  24. package/dist/setup/index.d.ts.map +1 -0
  25. package/dist/setup/index.js +13 -0
  26. package/dist/setup/messages.d.ts +15 -0
  27. package/dist/setup/messages.d.ts.map +1 -0
  28. package/dist/setup/messages.js +249 -0
  29. package/dist/setup/records-table.d.ts +24 -0
  30. package/dist/setup/records-table.d.ts.map +1 -0
  31. package/dist/setup/records-table.js +80 -0
  32. package/dist/setup/setup-flow.d.ts +30 -0
  33. package/dist/setup/setup-flow.d.ts.map +1 -0
  34. package/dist/setup/setup-flow.js +277 -0
  35. package/dist/setup/setup-form-step.d.ts +20 -0
  36. package/dist/setup/setup-form-step.d.ts.map +1 -0
  37. package/dist/setup/setup-form-step.js +173 -0
  38. package/dist/setup/step-status-badge.d.ts +12 -0
  39. package/dist/setup/step-status-badge.d.ts.map +1 -0
  40. package/dist/setup/step-status-badge.js +21 -0
  41. package/dist/setup/tone.d.ts +8 -0
  42. package/dist/setup/tone.d.ts.map +1 -0
  43. package/dist/setup/tone.js +33 -0
  44. package/dist/setup/types.d.ts +130 -0
  45. package/dist/setup/types.d.ts.map +1 -0
  46. package/dist/setup/types.js +1 -0
  47. package/package.json +5 -1
  48. package/src/__tests__/addon-config-surface.test.tsx +248 -0
  49. package/src/__tests__/image-stack.test.tsx +58 -1
  50. package/src/__tests__/setup-components.test.tsx +147 -0
  51. package/src/__tests__/setup-flow-model.test.ts +117 -0
  52. package/src/__tests__/setup-flow.test.tsx +424 -0
  53. package/src/display-value.tsx +30 -1
  54. package/src/dynamic-columns.tsx +21 -5
  55. package/src/index.ts +25 -0
  56. package/src/setup/addon-config-surface.tsx +1262 -0
  57. package/src/setup/connector-form-model.ts +115 -0
  58. package/src/setup/flow-model.ts +156 -0
  59. package/src/setup/health-card.tsx +131 -0
  60. package/src/setup/index.ts +23 -0
  61. package/src/setup/messages.ts +263 -0
  62. package/src/setup/records-table.tsx +186 -0
  63. package/src/setup/setup-flow.tsx +562 -0
  64. package/src/setup/setup-form-step.tsx +342 -0
  65. package/src/setup/step-status-badge.tsx +47 -0
  66. package/src/setup/tone.ts +44 -0
  67. package/src/setup/types.ts +147 -0
@@ -0,0 +1,263 @@
1
+ // i18n for the setup / health components. Every string resolves through
2
+ // react-i18next (`setup.*` keys, so a host can override any of them) with the
3
+ // bundled es/en text as the default. No bundle has to be registered.
4
+ import { useCallback } from 'react'
5
+ import { useTranslation } from 'react-i18next'
6
+
7
+ type Dict = Record<string, string>
8
+
9
+ export const SETUP_MESSAGES_ES: Dict = {
10
+ 'status.pending': 'Pendiente',
11
+ 'status.running': 'En curso',
12
+ 'status.ok': 'Listo',
13
+ 'status.warn': 'Con avisos',
14
+ 'status.error': 'Con error',
15
+ 'status.blocked': 'Bloqueado',
16
+ 'status.skipped': 'Omitido',
17
+ 'record.status.ok': 'Correcto',
18
+ 'record.status.missing': 'No encontrado',
19
+ 'record.status.wrong_value': 'Valor distinto',
20
+ 'record.status.propagating': 'Propagando',
21
+ 'record.status.pending': 'Sin verificar',
22
+ 'record.status.error': 'Error',
23
+ 'health.status.ok': 'Todo en orden',
24
+ 'health.status.warn': 'Requiere atención',
25
+ 'health.status.error': 'Con problemas',
26
+ 'health.status.unknown': 'Sin datos',
27
+ 'health.metrics': 'Métricas',
28
+ 'health.issues': 'Avisos',
29
+ 'health.no_issues': 'Sin avisos.',
30
+ 'health.checked_at': 'Revisado {{when}}',
31
+ 'health.refresh': 'Actualizar',
32
+ 'health.continue': 'Continuar configuración',
33
+ 'health.progress': '{{done}} de {{total}} pasos',
34
+ 'records.type': 'Tipo',
35
+ 'records.name': 'Nombre',
36
+ 'records.value': 'Valor',
37
+ 'records.status': 'Estado',
38
+ 'records.copy': 'Copiar',
39
+ 'records.copy_label': 'Copiar {{what}}',
40
+ 'records.copied': 'Copiado',
41
+ 'records.copy_failed': 'No se pudo copiar. Selecciona el texto y cópialo a mano.',
42
+ 'records.empty': 'No hay registros por mostrar.',
43
+ 'records.found': 'Encontrado: {{value}}',
44
+ 'records.recheck': 'Verificar ahora',
45
+ 'flow.steps': 'Pasos de configuración',
46
+ 'flow.progress': 'Progreso de la configuración',
47
+ 'flow.step_of': 'Paso {{n}} de {{total}}',
48
+ 'flow.loading': 'Cargando configuración…',
49
+ 'flow.load_error': 'No se pudo cargar el estado de la configuración.',
50
+ 'flow.retry': 'Reintentar',
51
+ 'flow.complete': 'La configuración está completa.',
52
+ 'flow.optional': 'Opcional',
53
+ 'flow.skip': 'Omitir este paso',
54
+ 'flow.run': 'Ejecutar',
55
+ 'flow.check': 'Verificar',
56
+ 'flow.recheck': 'Volver a verificar',
57
+ 'flow.refresh': 'Revisar ahora',
58
+ 'flow.running': 'En curso…',
59
+ 'flow.waiting_for': 'Antes completa: {{steps}}',
60
+ 'flow.next_check': 'Próxima revisión en {{s}} s',
61
+ 'flow.poll_stopped': 'Dejamos de revisar solo. Pulsa «Revisar ahora» para actualizar.',
62
+ 'flow.step_failed': 'No se pudo ejecutar el paso.',
63
+ 'flow.custom_missing': 'Este paso no tiene una pantalla disponible.',
64
+ 'flow.fix': 'Arreglar',
65
+ 'flow.go_to_step': 'Ir al paso',
66
+ 'flow.open_link': 'Abrir',
67
+ 'flow.status_changed': '{{step}}: {{status}}',
68
+ 'form.continue': 'Guardar y continuar',
69
+ 'form.back': 'Atrás',
70
+ 'form.next': 'Siguiente',
71
+ 'form.saving': 'Guardando…',
72
+ 'form.saved': 'Guardado automáticamente',
73
+ 'form.save_error': 'No se pudo guardar automáticamente.',
74
+ 'form.missing': 'Faltan campos obligatorios: {{fields}}.',
75
+ 'form.field_required': 'Falta completar este campo.',
76
+ 'form.stored': 'Guardado. Escribe un valor nuevo solo si quieres cambiarlo.',
77
+ 'form.choose': 'Elige una opción',
78
+ 'form.step': 'Paso',
79
+ // AddonConfigSurface (same keys the ops host already ships)
80
+ 'installed_addons.configure_title': 'Configurar {{name}}',
81
+ 'installed_addons.configure_description': 'Credenciales y ajustes del addon.',
82
+ 'installed_addons.section_credentials': 'Credenciales',
83
+ 'installed_addons.section_settings': 'Ajustes',
84
+ 'installed_addons.advanced': 'Avanzado',
85
+ 'installed_addons.no_settings': 'Este addon no tiene nada que configurar.',
86
+ 'installed_addons.config_saved': 'Configuración guardada',
87
+ 'installed_addons.settings_error': 'No se pudo guardar la configuración',
88
+ 'installed_addons.test_connection': 'Probar conexión',
89
+ 'installed_addons.test_ok': 'Conexión válida',
90
+ 'installed_addons.test_failed': 'No se pudo conectar',
91
+ 'installed_addons.sync_now': 'Sincronizar ahora',
92
+ 'installed_addons.sync_skipped': 'Sincronización omitida',
93
+ 'installed_addons.sync_done': 'Sincronizado: {{licenses}} licencias, {{instances}} instancias, {{accounts}} cuentas',
94
+ 'installed_addons.sync_failed': 'No se pudo sincronizar',
95
+ 'installed_addons.issuer_admin_only':
96
+ 'Solo un administrador de la organización puede ver y guardar los datos del emisor y el certificado. Pide a un administrador que los configure.',
97
+ 'installed_addons.field_required': 'Falta completar este campo.',
98
+ 'installed_addons.missing_fields': 'Faltan campos obligatorios: {{fields}}.',
99
+ 'installed_addons.shape_public_key': 'Este valor tiene forma de {{target}}. Pégalo en ese campo.',
100
+ 'installed_addons.shape_secret_key': 'Este valor tiene forma de una clave secreta. Pégalo en {{target}}.',
101
+ 'installed_addons.dynamic_select_error':
102
+ 'No se pudieron listar las opciones. Guarda la conexión y vuelve a intentar.',
103
+ 'installed_addons.dynamic_select_choose': 'Elige una opción',
104
+ 'installed_addons.dynamic_select_placeholder': 'Guarda la conexión y actualiza para elegir',
105
+ 'installed_addons.dynamic_select_refresh': 'Actualizar opciones',
106
+ 'installed_addons.per_branch': 'Por sucursal',
107
+ 'installed_addons.inherit_pending': 'Heredará de la organización al guardar',
108
+ 'installed_addons.branch_own': 'Valor propio de esta sucursal',
109
+ 'installed_addons.branch_inherited': 'Hereda de la organización',
110
+ 'installed_addons.inherit': 'Heredar de la organización',
111
+ 'installed_addons.applies_to': 'Los ajustes aplican a:',
112
+ 'installed_addons.whole_org': 'Toda la organización',
113
+ 'installed_addons.only_branch': 'Solo {{name}}',
114
+ 'installed_addons.secret_stored': 'Hay un valor guardado. Déjalo vacío para conservarlo.',
115
+ 'common.back': 'Atrás',
116
+ 'common.next': 'Siguiente',
117
+ 'common.cancel': 'Cancelar',
118
+ 'common.save': 'Guardar',
119
+ }
120
+
121
+ export const SETUP_MESSAGES_EN: Dict = {
122
+ 'status.pending': 'Pending',
123
+ 'status.running': 'In progress',
124
+ 'status.ok': 'Done',
125
+ 'status.warn': 'Has warnings',
126
+ 'status.error': 'Has errors',
127
+ 'status.blocked': 'Blocked',
128
+ 'status.skipped': 'Skipped',
129
+ 'record.status.ok': 'Correct',
130
+ 'record.status.missing': 'Not found',
131
+ 'record.status.wrong_value': 'Different value',
132
+ 'record.status.propagating': 'Propagating',
133
+ 'record.status.pending': 'Not checked',
134
+ 'record.status.error': 'Error',
135
+ 'health.status.ok': 'All good',
136
+ 'health.status.warn': 'Needs attention',
137
+ 'health.status.error': 'Has problems',
138
+ 'health.status.unknown': 'No data',
139
+ 'health.metrics': 'Metrics',
140
+ 'health.issues': 'Issues',
141
+ 'health.no_issues': 'No issues.',
142
+ 'health.checked_at': 'Checked {{when}}',
143
+ 'health.refresh': 'Refresh',
144
+ 'health.continue': 'Continue setup',
145
+ 'health.progress': '{{done}} of {{total}} steps',
146
+ 'records.type': 'Type',
147
+ 'records.name': 'Name',
148
+ 'records.value': 'Value',
149
+ 'records.status': 'Status',
150
+ 'records.copy': 'Copy',
151
+ 'records.copy_label': 'Copy {{what}}',
152
+ 'records.copied': 'Copied',
153
+ 'records.copy_failed': 'Could not copy. Select the text and copy it by hand.',
154
+ 'records.empty': 'No records to show.',
155
+ 'records.found': 'Found: {{value}}',
156
+ 'records.recheck': 'Check now',
157
+ 'flow.steps': 'Setup steps',
158
+ 'flow.progress': 'Setup progress',
159
+ 'flow.step_of': 'Step {{n}} of {{total}}',
160
+ 'flow.loading': 'Loading setup…',
161
+ 'flow.load_error': 'Could not load the setup state.',
162
+ 'flow.retry': 'Try again',
163
+ 'flow.complete': 'Setup is complete.',
164
+ 'flow.optional': 'Optional',
165
+ 'flow.skip': 'Skip this step',
166
+ 'flow.run': 'Run',
167
+ 'flow.check': 'Check',
168
+ 'flow.recheck': 'Check again',
169
+ 'flow.refresh': 'Check now',
170
+ 'flow.running': 'In progress…',
171
+ 'flow.waiting_for': 'Finish first: {{steps}}',
172
+ 'flow.next_check': 'Next check in {{s}} s',
173
+ 'flow.poll_stopped': 'We stopped checking automatically. Press "Check now" to refresh.',
174
+ 'flow.step_failed': 'The step could not be run.',
175
+ 'flow.custom_missing': 'This step has no screen available.',
176
+ 'flow.fix': 'Fix',
177
+ 'flow.go_to_step': 'Go to step',
178
+ 'flow.open_link': 'Open',
179
+ 'flow.status_changed': '{{step}}: {{status}}',
180
+ 'form.continue': 'Save and continue',
181
+ 'form.back': 'Back',
182
+ 'form.next': 'Next',
183
+ 'form.saving': 'Saving…',
184
+ 'form.saved': 'Saved automatically',
185
+ 'form.save_error': 'Could not save automatically.',
186
+ 'form.missing': 'Required fields are missing: {{fields}}.',
187
+ 'form.field_required': 'This field is required.',
188
+ 'form.stored': 'Saved. Type a new value only if you want to change it.',
189
+ 'form.choose': 'Choose an option',
190
+ 'form.step': 'Step',
191
+ 'installed_addons.configure_title': 'Configure {{name}}',
192
+ 'installed_addons.configure_description': 'Credentials and settings for this addon.',
193
+ 'installed_addons.section_credentials': 'Credentials',
194
+ 'installed_addons.section_settings': 'Settings',
195
+ 'installed_addons.advanced': 'Advanced',
196
+ 'installed_addons.no_settings': 'This addon has nothing to configure.',
197
+ 'installed_addons.config_saved': 'Configuration saved',
198
+ 'installed_addons.settings_error': 'Could not save the configuration',
199
+ 'installed_addons.test_connection': 'Test connection',
200
+ 'installed_addons.test_ok': 'Connection is valid',
201
+ 'installed_addons.test_failed': 'Could not connect',
202
+ 'installed_addons.sync_now': 'Sync now',
203
+ 'installed_addons.sync_skipped': 'Sync skipped',
204
+ 'installed_addons.sync_done': 'Synced: {{licenses}} licenses, {{instances}} instances, {{accounts}} accounts',
205
+ 'installed_addons.sync_failed': 'Could not sync',
206
+ 'installed_addons.issuer_admin_only':
207
+ 'Only an organization administrator can view and save the issuer and certificate data. Ask an administrator to set them up.',
208
+ 'installed_addons.field_required': 'This field is required.',
209
+ 'installed_addons.missing_fields': 'Required fields are missing: {{fields}}.',
210
+ 'installed_addons.shape_public_key': 'This value looks like {{target}}. Paste it in that field.',
211
+ 'installed_addons.shape_secret_key': 'This value looks like a secret key. Paste it in {{target}}.',
212
+ 'installed_addons.dynamic_select_error': 'Could not list the options. Save the connection and try again.',
213
+ 'installed_addons.dynamic_select_choose': 'Choose an option',
214
+ 'installed_addons.dynamic_select_placeholder': 'Save the connection and refresh to choose',
215
+ 'installed_addons.dynamic_select_refresh': 'Refresh options',
216
+ 'installed_addons.per_branch': 'Per branch',
217
+ 'installed_addons.inherit_pending': 'Will inherit from the organization on save',
218
+ 'installed_addons.branch_own': "This branch's own value",
219
+ 'installed_addons.branch_inherited': 'Inherits from the organization',
220
+ 'installed_addons.inherit': 'Inherit from the organization',
221
+ 'installed_addons.applies_to': 'Settings apply to:',
222
+ 'installed_addons.whole_org': 'Whole organization',
223
+ 'installed_addons.only_branch': 'Only {{name}}',
224
+ 'installed_addons.secret_stored': 'A value is stored. Leave it empty to keep it.',
225
+ 'common.back': 'Back',
226
+ 'common.next': 'Next',
227
+ 'common.cancel': 'Cancel',
228
+ 'common.save': 'Save',
229
+ }
230
+
231
+ export type TFn = (key: string, vars?: Record<string, unknown>) => string
232
+
233
+ function interpolate(s: string, vars?: Record<string, unknown>): string {
234
+ if (!vars) return s
235
+ return s.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, k) => (vars[k] == null ? '' : String(vars[k])))
236
+ }
237
+
238
+ /** Resolves the bundled text for `lang` (es default; any `en*` → English). */
239
+ export function defaultMessage(key: string, lang?: string): string {
240
+ const dict = lang && lang.toLowerCase().startsWith('en') ? SETUP_MESSAGES_EN : SETUP_MESSAGES_ES
241
+ return dict[key] ?? SETUP_MESSAGES_ES[key] ?? key
242
+ }
243
+
244
+ /**
245
+ * Translator for the setup components. Keys that start with `setup.` (or are
246
+ * the shared `installed_addons.*` / `common.*` ones) go through i18next first,
247
+ * so a host can override; the bundled es/en text is the default value.
248
+ * Interpolation is done here too, so it works even without an i18next instance.
249
+ */
250
+ export function useSetupT(): TFn {
251
+ const { t, i18n } = useTranslation()
252
+ const lang = i18n?.language
253
+ return useCallback(
254
+ (key, vars) => {
255
+ const hostKey = key.includes('.') && /^(installed_addons|common)\./.test(key) ? key : `setup.${key}`
256
+ const fallback = defaultMessage(key, lang)
257
+ const out = t(hostKey, { ...(vars ?? {}), defaultValue: fallback }) as string
258
+ // Mocked / minimal `t` implementations may ignore interpolation.
259
+ return interpolate(typeof out === 'string' ? out : fallback, vars)
260
+ },
261
+ [t, lang],
262
+ )
263
+ }
@@ -0,0 +1,186 @@
1
+ import { Fragment, useCallback, useEffect, useRef, useState } from 'react'
2
+ import { Check, Copy, RefreshCw } from 'lucide-react'
3
+ import { Button } from '@asteby/metacore-ui/primitives'
4
+ import { cn } from '@asteby/metacore-ui/lib'
5
+ import { useSetupT } from './messages'
6
+ import { RECORD_TONE, TONE_BADGE } from './tone'
7
+ import type { RecordStatus, SetupDiagnostic, SetupFix, SetupRecord } from './types'
8
+
9
+ /**
10
+ * Copies text with a fallback: the async Clipboard API when the page may use
11
+ * it, otherwise a hidden textarea + `execCommand('copy')` (http pages, older
12
+ * webviews, denied permission). Resolves to whether something was copied.
13
+ */
14
+ export async function copyText(text: string): Promise<boolean> {
15
+ try {
16
+ if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
17
+ await navigator.clipboard.writeText(text)
18
+ return true
19
+ }
20
+ } catch {
21
+ /* fall through to the legacy path */
22
+ }
23
+ if (typeof document === 'undefined') return false
24
+ const ta = document.createElement('textarea')
25
+ ta.value = text
26
+ ta.setAttribute('readonly', '')
27
+ ta.style.position = 'fixed'
28
+ ta.style.opacity = '0'
29
+ document.body.appendChild(ta)
30
+ ta.select()
31
+ try {
32
+ return document.execCommand('copy')
33
+ } catch {
34
+ return false
35
+ } finally {
36
+ document.body.removeChild(ta)
37
+ }
38
+ }
39
+
40
+ function CopyButton({ text, what }: { text: string; what: string }) {
41
+ const t = useSetupT()
42
+ const [state, setState] = useState<'idle' | 'copied' | 'failed'>('idle')
43
+ const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
44
+ useEffect(() => () => clearTimeout(timer.current), [])
45
+ const onCopy = useCallback(async () => {
46
+ const ok = await copyText(text)
47
+ setState(ok ? 'copied' : 'failed')
48
+ clearTimeout(timer.current)
49
+ timer.current = setTimeout(() => setState('idle'), 2500)
50
+ }, [text])
51
+ return (
52
+ <span className='inline-flex items-center gap-1'>
53
+ <Button
54
+ type='button'
55
+ variant='ghost'
56
+ size='sm'
57
+ className='h-7 w-7 shrink-0 p-0'
58
+ onClick={onCopy}
59
+ aria-label={t('records.copy_label', { what })}
60
+ title={t('records.copy')}
61
+ >
62
+ {state === 'copied' ? (
63
+ <Check className='h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400' aria-hidden='true' />
64
+ ) : (
65
+ <Copy className='h-3.5 w-3.5' aria-hidden='true' />
66
+ )}
67
+ </Button>
68
+ <span role='status' className={cn('text-xs', state === 'failed' ? 'text-destructive' : 'text-muted-foreground', state === 'idle' && 'sr-only')}>
69
+ {state === 'copied' ? t('records.copied') : state === 'failed' ? t('records.copy_failed') : ''}
70
+ </span>
71
+ </span>
72
+ )
73
+ }
74
+
75
+ function diagOf(d: SetupRecord['diagnostic']): SetupDiagnostic | null {
76
+ if (!d) return null
77
+ return typeof d === 'string' ? { message: d } : d
78
+ }
79
+
80
+ export interface RecordsTableProps {
81
+ records: SetupRecord[]
82
+ caption?: string
83
+ /** Fix button of a row's diagnostic (`fix.action|url|step`). */
84
+ onFix?: (fix: SetupFix, record: SetupRecord) => void
85
+ /** Shows a "check now" button above the table. */
86
+ onRecheck?: () => void
87
+ rechecking?: boolean
88
+ className?: string
89
+ }
90
+
91
+ /**
92
+ * Type / name / value table (DNS records and the like) with per-row copy,
93
+ * status and diagnostic. Scrolls horizontally on narrow screens instead of
94
+ * squeezing the values; values wrap (`break-all`) so a long DKIM key is readable.
95
+ */
96
+ export function RecordsTable({ records, caption, onFix, onRecheck, rechecking, className }: RecordsTableProps) {
97
+ const t = useSetupT()
98
+ if (!records || records.length === 0) {
99
+ return <p className={cn('text-sm text-muted-foreground', className)}>{t('records.empty')}</p>
100
+ }
101
+ return (
102
+ <div className={cn('flex flex-col gap-2', className)}>
103
+ {onRecheck ? (
104
+ <div className='flex justify-end'>
105
+ <Button type='button' variant='outline' size='sm' onClick={onRecheck} disabled={rechecking} className='gap-2'>
106
+ <RefreshCw className={cn('h-3.5 w-3.5', rechecking && 'animate-spin motion-reduce:animate-none')} aria-hidden='true' />
107
+ {t('records.recheck')}
108
+ </Button>
109
+ </div>
110
+ ) : null}
111
+ <div className='overflow-x-auto rounded-md border'>
112
+ <table className='w-full min-w-[34rem] border-collapse text-left text-sm'>
113
+ {caption ? <caption className='sr-only'>{caption}</caption> : null}
114
+ <thead className='bg-muted/50 text-xs text-muted-foreground'>
115
+ <tr>
116
+ <th scope='col' className='px-3 py-2 font-medium'>{t('records.type')}</th>
117
+ <th scope='col' className='px-3 py-2 font-medium'>{t('records.name')}</th>
118
+ <th scope='col' className='px-3 py-2 font-medium'>{t('records.value')}</th>
119
+ <th scope='col' className='px-3 py-2 font-medium'>{t('records.status')}</th>
120
+ </tr>
121
+ </thead>
122
+ <tbody>
123
+ {records.map((r, i) => {
124
+ const status: RecordStatus = r.status ?? 'pending'
125
+ const diag = diagOf(r.diagnostic)
126
+ const tone = RECORD_TONE[status] ?? 'neutral'
127
+ return (
128
+ <Fragment key={r.id ?? `${r.type}-${r.name}-${i}`}>
129
+ <tr className={cn(!diag && i < records.length - 1 && 'border-b')}>
130
+ <td className='whitespace-nowrap px-3 py-2 align-top'>
131
+ <span className='rounded border bg-muted px-1.5 py-0.5 font-mono text-xs'>{r.type}</span>
132
+ </td>
133
+ <td className='px-3 py-2 align-top'>
134
+ <div className='flex items-start gap-1'>
135
+ <code className='break-all font-mono text-xs'>{r.name}</code>
136
+ <CopyButton text={r.name} what={t('records.name').toLowerCase()} />
137
+ </div>
138
+ </td>
139
+ <td className='px-3 py-2 align-top'>
140
+ <div className='flex items-start gap-1'>
141
+ <code className='break-all font-mono text-xs'>{r.value}</code>
142
+ <CopyButton text={r.value} what={t('records.value').toLowerCase()} />
143
+ </div>
144
+ {r.found && r.found !== r.value ? (
145
+ <p className='pt-1 text-xs text-muted-foreground break-all'>{t('records.found', { value: r.found })}</p>
146
+ ) : null}
147
+ </td>
148
+ <td className='px-3 py-2 align-top'>
149
+ <span className={cn('inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium', TONE_BADGE[tone])} data-record-status={status}>
150
+ {t(`record.status.${status}`)}
151
+ </span>
152
+ </td>
153
+ </tr>
154
+ {diag ? (
155
+ <tr className={cn(i < records.length - 1 && 'border-b')}>
156
+ <DiagnosticCell diag={diag} onFix={onFix ? (f) => onFix(f, r) : undefined} />
157
+ </tr>
158
+ ) : null}
159
+ </Fragment>
160
+ )
161
+ })}
162
+ </tbody>
163
+ </table>
164
+ </div>
165
+ </div>
166
+ )
167
+ }
168
+
169
+ function DiagnosticCell({ diag, onFix }: { diag: SetupDiagnostic; onFix?: (f: SetupFix) => void }) {
170
+ const t = useSetupT()
171
+ return (
172
+ <td colSpan={4} className='bg-muted/30 px-3 py-2 text-xs'>
173
+ <div className='flex flex-wrap items-center justify-between gap-2'>
174
+ <p className='min-w-0 flex-1 text-muted-foreground'>
175
+ {diag.message}
176
+ {diag.detail ? <span className='block break-words'>{diag.detail}</span> : null}
177
+ </p>
178
+ {diag.fix && onFix ? (
179
+ <Button type='button' size='sm' variant='outline' className='h-7' onClick={() => onFix(diag.fix!)}>
180
+ {diag.fix.label ?? t('flow.fix')}
181
+ </Button>
182
+ ) : null}
183
+ </div>
184
+ </td>
185
+ )
186
+ }