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

META-INF.resources.page_editor.app.components.ManageAllowedFragmentModal.js 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 from '@clayui/modal';
import PropTypes from 'prop-types';
import React, {useCallback, useState} from 'react';

import {useDispatch} from '../contexts/StoreContext';
import updateItemConfig from '../thunks/updateItemConfig';
import AllowedFragmentSelectorTree from './AllowedFragmentSelectorTree';

const ManageAllowedFragmentModal = ({item, observer, onClose}) => {
	const dispatch = useDispatch();

	const [allowNewFragmentEntries, setAllowNewFragmentEntries] =
		useState(true);
	const [selectedFragments, setSelectedFragments] = useState(new Set([]));
	const [loading, setLoading] = useState();

	const handleSaveClick = () => {
		setLoading(true);

		dispatch(
			updateItemConfig({
				itemConfig: {
					allowNewFragmentEntries,
					fragmentEntryKeys: [...selectedFragments],
				},
				itemIds: [item.itemId],
			})
		).then(() => {
			setLoading(false);
			onClose();
		});
	};

	const onSelectedFragment = useCallback(
		({allowNewFragmentEntries, selectedFragments}) => {
			setAllowNewFragmentEntries(allowNewFragmentEntries);
			setSelectedFragments(selectedFragments);
		},
		[]
	);

	return (
		
			
				{Liferay.Language.get('allowed-fragments')}
			

			
				

{Liferay.Language.get( 'specify-which-fragments-a-page-author-is-allowed-to-use-within-the-drop-zone-when-creating-a-page-from-this-master' )}

{Liferay.Language.get('cancel')} {loading && ( )} {Liferay.Language.get('save')} } >
); }; ManageAllowedFragmentModal.propTypes = { item: PropTypes.shape({ config: PropTypes.object.isRequired, itemId: PropTypes.string.isRequired, }).isRequired, observer: PropTypes.object.isRequired, onClose: PropTypes.func.isRequired, }; export default ManageAllowedFragmentModal;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy