META-INF.resources.js.article.SelectAssetDisplayPage.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 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}
/>
{selectedDisplayPageType === DISPLAY_PAGE_TYPE.default && (
)}
{selectedDisplayPageType === DISPLAY_PAGE_TYPE.specific && (
)}
{selectedDisplayPageType !== DISPLAY_PAGE_TYPE.none && (
previewURL}
namespace={namespace}
newArticle={newArticle}
saveAsDraftURL={saveAsDraftURL}
/>
)}
>
);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy