UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

123 lines (121 loc) 4.32 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import DialogHeader from '../DialogHeader/DialogHeader'; import DialogBody from '../DialogBody/DialogBody'; import DialogFooter from '../DialogFooter/DialogFooter'; import DialogContentText from '@mui/material/DialogContentText'; import React, { useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import Dialog from '@mui/material/Dialog'; import SecondaryButton from '../SecondaryButton'; import PrimaryButton from '../PrimaryButton'; import { useUnmount } from '../../hooks/useUnmount'; const translations = defineMessages({ go: { id: 'words.go', defaultMessage: 'Go' }, stay: { id: 'words.stay', defaultMessage: 'Stay' }, title: { id: 'previewCompatDialog.title', defaultMessage: 'Preview Compatibility Notice' }, nextCompatibility: { id: 'previewCompatDialog.nextCompatMessage', defaultMessage: 'This page is compatible with the new editing experience. Would you like to go there now?' }, legacyCompatibility: { id: 'previewCompatDialog.legacyCompatMessage', defaultMessage: 'This page is compatible with the previous editing experience. Would you like to go there now?' }, rememberChoice: { id: 'previewCompatDialog.rememberChoice', defaultMessage: 'Remember choice' } }); export function LegacyContainer(props) { const [open, setOpen] = useState(true); return React.createElement( PreviewCompatibilityDialogContainer, Object.assign({}, props, { open: open, onCancel: (options) => { setOpen(false); props.onCancel(options); } }) ); } export function PreviewCompatibilityDialogContainer(props) { return React.createElement( Dialog, { open: props.open, onClose: props.onClose, 'aria-labelledby': 'previewCompatDialogTitle', 'aria-describedby': 'previewCompatDialogBody' }, React.createElement(PreviewCompatibilityDialog, Object.assign({}, props)) ); } export function PreviewCompatibilityDialog(props) { const { onOk, onCancel, isPreviewNext } = props; const { formatMessage } = useIntl(); useUnmount(props.onClosed); return React.createElement( React.Fragment, null, React.createElement(DialogHeader, { id: 'previewCompatDialogTitle', title: formatMessage(translations.title) }), React.createElement( DialogBody, { id: 'previewCompatDialogBody' }, React.createElement( DialogContentText, { color: 'textPrimary' }, formatMessage(isPreviewNext ? translations.nextCompatibility : translations.legacyCompatibility) ) ), React.createElement( DialogFooter, null, React.createElement( SecondaryButton, { onClick: onCancel, style: { marginRight: 5 } }, formatMessage(translations.stay) ), React.createElement(PrimaryButton, { onClick: onOk, autoFocus: true }, formatMessage(translations.go)) ) ); } export default LegacyContainer;