All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.js.components.ModalDeletionNotAllowed.tsx Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import ClayButton from '@clayui/button';
import ClayModal, {useModal} from '@clayui/modal';
import React, {useEffect, useState} from 'react';

interface ModalDeletionNotAllowedProps {
	content: React.ReactNode;
	onModalClose: () => void;
}

function ModalDeletionNotAllowed({
	content,
	onModalClose,
}: ModalDeletionNotAllowedProps) {
	const [bodyContent, setBodyContent] = useState(content);
	const [visible, setVisible] = useState(false);

	const {observer, onClose} = useModal({
		onClose: () => {
			onModalClose ? onModalClose() : setVisible(false);
		},
	});

	useEffect(() => {
		const openModal = ({contentLiferayFire = <>}) => {
			setVisible(true);
			setBodyContent(contentLiferayFire);
		};

		Liferay.on('openModalDeletionNotAllowed', openModal);

		return () =>
			Liferay.detach(
				'openModalDeletionNotAllowed',
				openModal as () => void
			);
	}, []);

	return (
		<>
			{(visible || !!content) && (
				
					
						{Liferay.Language.get('deletion-not-allowed')}
					

					{bodyContent}

					
								 onClose()}
								>
									{Liferay.Language.get('done')}
								
							
						}
					/>
				
			)}
		
	);
}

export default ModalDeletionNotAllowed;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy