/** * * 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'; class LeftMenuLink extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { // We need to create our own active url checker, // because of the two levels router. const isLinkActive = startsWith(window.location.pathname.replace('/admin', ''), this.props.destination); const plugin = this.props.source !== 'content-manager' && this.props.source !== '' ? (
{upperFirst(this.props.source.split('-').join(' '))}
) : ''; // Check if messageId exists in en locale to prevent warning messages const content = en[this.props.label] ? ( ) : ( {this.props.label} ); return (
  • {content} {plugin}
  • ); } } LeftMenuLink.propTypes = { destination: PropTypes.string.isRequired, icon: PropTypes.string.isRequired, label: PropTypes.string.isRequired, source: PropTypes.string, }; LeftMenuLink.defaultProps = { source: '', }; export default LeftMenuLink;