Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/strapi-admin/admin/src/components/LeftMenu/LeftMenuLink/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
*
* LeftMenuLink
*
*/
import React from 'react';
import { startsWith } from 'lodash';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import styled from 'styled-components';
import { Link, withRouter } from 'react-router-dom';
import en from '../../../translations/en.json';
import LeftMenuIcon from './LeftMenuIcon';
import A from './A';
import NotificationCount from './NotificationCount';
const LinkLabel = styled.span`
display: inline-block;
width: 100%;
padding-right: 1rem;
padding-left: 2.5rem;
`;
// TODO: refacto this file
const LeftMenuLinkContent = ({
destination,
iconName,
label,
location,
notificationsCount,
search,
}) => {
const isLinkActive = startsWith(
location.pathname.replace('/admin', '').concat('/'),
destination.concat('/')
);
// Check if messageId exists in en locale to prevent warning messages
const labelId = label.id || label;
const content =
en[labelId] || label.defaultMessage ? (
<FormattedMessage
id={labelId}
defaultMessage={label.defaultMessage || '{label}'}
values={{
label: `${label.id || label}`,
}}
>
{message => <LinkLabel>{message}</LinkLabel>}
</FormattedMessage>
) : (
<LinkLabel>{labelId}</LinkLabel>
);
// Create external or internal link.
return destination.includes('http') ? (
<A
className={isLinkActive ? 'linkActive' : ''}
href={destination}
target="_blank"
rel="noopener noreferrer"
>
<LeftMenuIcon icon={iconName} />
{content}
</A>
) : (
<A
as={Link}
className={isLinkActive ? 'linkActive' : ''}
to={{
pathname: destination,
search,
}}
>
<LeftMenuIcon icon={iconName} />
{content}
{notificationsCount > 0 && <NotificationCount count={notificationsCount} />}
</A>
);
};
LeftMenuLinkContent.defaultProps = {
search: null,
};
LeftMenuLinkContent.propTypes = {
destination: PropTypes.string.isRequired,
iconName: PropTypes.string.isRequired,
label: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired,
location: PropTypes.shape({
pathname: PropTypes.string,
}).isRequired,
notificationsCount: PropTypes.number.isRequired,
search: PropTypes.string,
};
export default withRouter(LeftMenuLinkContent);
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]-- |