'use client' /** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import { useTranslation } from '@byline/i18n/react' import { Button, CloseIcon, IconButton, Modal } from '@byline/ui/react' import cx from 'clsx' import styles from './form-renderer.module.css' /** * Shown when the editor triggers a guarded action (status change, duplicate, * copy-to-locale) while the form is dirty. Those actions operate on the saved * version, so the editor must save first. */ export const UnsavedChangesModal = ({ onClose }: { onClose: () => void }) => { const { t } = useTranslation('byline-admin') return (

{t('forms.unsavedChanges.title')}

{t('forms.unsavedChanges.message')}

) } /** * Confirms an immediate, non-versioned write of the document-grain system * fields (path / advertised locales) — which does NOT reset workflow status. * When content is also dirty, the copy reassures that content edits still * follow the normal revision + publish workflow. See docs/08-internationalization/index.md. */ export const SystemFieldsConfirmModal = ({ contentDirty, pathDirty, availableLocalesDirty, onCancel, onConfirm, }: { contentDirty: boolean pathDirty: boolean availableLocalesDirty: boolean onCancel: () => void onConfirm: () => void }) => { const { t } = useTranslation('byline-admin') return (

{contentDirty ? t('forms.systemFieldsConfirm.bothTitle') : t('forms.systemFieldsConfirm.title')}

{/* Lead with reassurance: content edits follow the normal revision + publish workflow. The immediate, document-level system-field write is explained below the divider. */} {contentDirty && (

{t('forms.systemFieldsConfirm.contentNote')}

)}

{t('forms.systemFieldsConfirm.intro')}

    {pathDirty &&
  • {t('forms.systemFieldsConfirm.bulletPath')}
  • } {availableLocalesDirty &&
  • {t('forms.systemFieldsConfirm.bulletLocales')}
  • }

{t('forms.systemFieldsConfirm.effectLine')}

) } /** * Blocks router navigation / browser unload while the form is dirty. Driven by * the navigation-guard adapter's `isBlocked` state; `onStay` keeps the editor * on the page, `onProceed` discards and continues. */ export const NavigationGuardModal = ({ onStay, onProceed, }: { onStay: () => void onProceed: () => void }) => { const { t } = useTranslation('byline-admin') return (

{t('forms.navigationGuard.title')}

{t('forms.navigationGuard.message')}

) }