/** * * LeftMenuLink * */ import React from 'react'; import { startsWith, upperFirst } from 'lodash'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; import en from '../../translations/en.json'; import styles from './styles.scss'; function LeftMenuLink(props) { const isLinkActive = startsWith( props.location.pathname.replace('/admin', '').concat('/'), props.destination.concat('/'), ); const plugin = props.source !== 'content-manager' && props.source !== '' ? (
{upperFirst(props.source.split('-').join(' '))}
) : ( '' ); // Check if messageId exists in en locale to prevent warning messages const content = en[props.label] ? ( ) : ( {props.label} ); // Icon. const icon = ; // Create external or internal link. const link = props.destination.includes('http') ? ( {icon} {content} ) : ( {icon} {content} ); return (
  • {link} {plugin}
  • ); } LeftMenuLink.propTypes = { destination: PropTypes.string.isRequired, icon: PropTypes.string.isRequired, label: PropTypes.string.isRequired, location: PropTypes.shape({ pathname: PropTypes.string, }).isRequired, source: PropTypes.string, }; LeftMenuLink.defaultProps = { source: '', }; export default LeftMenuLink;