/* * SPDX-FileCopyrightText: 2026 Coffey Labs * * SPDX-License-Identifier: AGPL-3.0-only */ /** * inbuxa: shown when saved settings are stored but the server couldn't apply * them. It stays until they are applied or it is dismissed, names the object * the server couldn't build and links to it, and offers to try again. */ import { Link } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { AlertTriangle, Loader2, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { humanize } from '@/lib/humanize'; import { resolveList } from '@/lib/schemaResolver'; import { useSchemaStore } from '@/stores/schemaStore'; import { useSettingsApplyStore } from '@/stores/settingsApplyStore'; export function SettingsApplyBanner() { const { t } = useTranslation(); const failure = useSettingsApplyStore((s) => s.failure); const applying = useSettingsApplyStore((s) => s.applying); const applyNow = useSettingsApplyStore((s) => s.applyNow); const dismiss = useSettingsApplyStore((s) => s.dismiss); const schema = useSchemaStore((s) => s.schema); const viewToSection = useSchemaStore((s) => s.viewToSection); if (!failure) return null; let objectLabel: string | null = null; let objectLink: string | null = null; if (failure.object) { const objectName = `x:${failure.object.object}`; const objectType = schema?.objects[objectName]; const list = schema ? resolveList(schema, objectName, objectName) : null; objectLabel = list?.singularName ?? humanize(failure.object.object); const section = viewToSection[objectName]; if (section) { objectLink = objectType?.type === 'singleton' || failure.object.id === 'singleton' ? `/${section}/${objectName}` : `/${section}/${objectName}/${encodeURIComponent(failure.object.id)}`; } } return (
{t('settingsApply.failed', "Saved, but the server couldn't apply the settings: {{reason}}", { reason: failure.message, })}
{objectLabel && ({t('settingsApply.failedObject', 'The problem is in {{object}}.', { object: objectLabel })}{' '} {objectLink && ( {t('settingsApply.openObject', 'Open it')} )}
)}{t( 'settingsApply.stillRunning', 'The server keeps running on the settings it had. Your changes are saved and apply once this is fixed.', )}