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

META-INF.resources.js.article.SelectAssetDisplayPage.js Maven / Gradle / Ivy

There is a newer version: 5.0.181
Show 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 ClayForm, {ClayInput, ClaySelectWithOption} from '@clayui/form';
import React, {useState} from 'react';

import AssetDisplayPageSelector from './AssetDisplayPageSelector';
import PreviewButton from './PreviewButton';

function getLabel(displayPageType) {
	if (displayPageType === DISPLAY_PAGE_TYPE.default) {
		return Liferay.Language.get('default');
	}
	else if (displayPageType === DISPLAY_PAGE_TYPE.specific) {
		return Liferay.Language.get('specific');
	}
	else {
		return Liferay.Language.get('none');
	}
}

const DISPLAY_PAGE_TYPE = {
	default: 1,
	none: 0,
	specific: 2,
};

export default function SelectAssetDisplayPage({
	assetDisplayPageId,
	assetDisplayPageType,
	defaultDisplayPageName,
	layoutUuid,
	newArticle,
	portletNamespace: namespace,
	saveAsDraftURL,
	selectAssetDisplayPageEventName,
	selectAssetDisplayPageURL,
	specificAssetDisplayPageName,
}) {
	const [selectedDisplayPageType, setSelectedDisplayPageType] =
		useState(assetDisplayPageType);

	const [assetDisplayPageSelected, setAssetDisplayPageSelected] = useState(
		() => {
			if (assetDisplayPageType === DISPLAY_PAGE_TYPE.specific) {
				return {
					assetDisplayPageId,
					layoutUuid,
					name: specificAssetDisplayPageName,
				};
			}

			return null;
		}
	);

	const ITEMS = [
		{
			label: getLabel(DISPLAY_PAGE_TYPE.default),
			value: DISPLAY_PAGE_TYPE.default,
		},
		{
			label: getLabel(DISPLAY_PAGE_TYPE.specific),
			value: DISPLAY_PAGE_TYPE.specific,
		},
		{
			label: getLabel(DISPLAY_PAGE_TYPE.none),
			value: DISPLAY_PAGE_TYPE.none,
		},
	];

	return (
		<>
			
				
						setSelectedDisplayPageType(
							parseInt(event.target.value, 10)
						)
					}
					options={ITEMS}
					value={selectedDisplayPageType}
				/>
			

			




© 2015 - 2024 Weber Informatics LLC | Privacy Policy