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

META-INF.resources.sxp_blueprint_options.js.configuration.index.js Maven / Gradle / Ivy

/**
 * 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 ClayForm, {ClayInput} from '@clayui/form';
import ClayIcon from '@clayui/icon';
import ClayLink from '@clayui/link';
import {useModal} from '@clayui/modal';
import ClaySticker from '@clayui/sticker';
import {ClayTooltipProvider} from '@clayui/tooltip';
import React, {useState} from 'react';

import getLocalizedLearnMessageObject from '../../../sxp_blueprint_admin/js/utils/language/get_localized_learn_message_object';
import SelectSXPBlueprintModal from './SelectSXPBlueprintModal';

const Configuration = ({
	initialFederatedSearchKey = '',
	initialSXPBlueprintExternalReferenceCode = '',
	initialSXPBlueprintTitle = '',
	learnMessages,
	portletNamespace,
	preferenceKeyFederatedSearchKey,
	preferenceKeySXPBlueprintExternalReferenceCode,
}) => {
	const [federatedSearchKey, setFederatedSearchKey] = useState(
		initialFederatedSearchKey
	);
	const [
		sxpBlueprintExternalReferenceCode,
		setSXPBlueprintExternalReferenceCode,
	] = useState(initialSXPBlueprintExternalReferenceCode);
	const [sxpBlueprintTitle, setSXPBlueprintTitle] = useState(
		initialSXPBlueprintTitle
	);
	const [visibleModal, setVisibleModal] = useState(false);

	const {observer, onClose} = useModal({
		onClose: () => setVisibleModal(false),
	});

	const learnMessageObject = getLocalizedLearnMessageObject(
		'search-blueprint-on-search-page',
		learnMessages
	);

	const _handleChangeFederatedSearchKey = (event) => {
		setFederatedSearchKey(event.target.value);
	};

	const _handleClickRemove = () => {
		setSXPBlueprintExternalReferenceCode('');
		setSXPBlueprintTitle('');
	};

	const _handleClickSelect = () => {
		setVisibleModal(true);
	};

	const _handleSubmitModal = (externalReferenceCode, title) => {
		setSXPBlueprintExternalReferenceCode(externalReferenceCode);
		setSXPBlueprintTitle(title);
	};

	return (
		<>
			{visibleModal && (
				
			)}

			

			
				

				
					
						
					

					
						
							{Liferay.Language.get('select')}
						
					

					
						
							{Liferay.Language.get('remove')}
						
					
				

				{learnMessageObject.url && (
					
{learnMessageObject.message}
)}
); }; export default Configuration;




© 2015 - 2025 Weber Informatics LLC | Privacy Policy