META-INF.resources.js.components.control-menu.ControlMenu.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 ClayIcon from '@clayui/icon';
import {ReactPortal} from '@liferay/frontend-js-react-web';
import React, {useEffect, useState} from 'react';
import {Link as InternalLink} from 'react-router-dom';
const ExternalLink = ({children, to, ...props}) => {
return (
{children}
);
};
export function BackButtonPortal({backURL = '/'}) {
const [container, setContainer] = useState(null);
const Link =
backURL && backURL.startsWith('http') ? ExternalLink : InternalLink;
useEffect(() => {
if (!container) {
setContainer(
document.querySelector('.sites-control-group .control-menu-nav')
);
}
}, [container]);
if (!container) {
return <>>;
}
return (
);
}