/** * * LeftMenuLinkContainer * */ import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { get, snakeCase, isEmpty, map, sortBy } from 'lodash'; import LeftMenuLink from 'components/LeftMenuLink'; import styles from './styles.scss'; import messages from './messages.json'; function LeftMenuLinkContainer({ plugins }) { const pluginsObject = plugins.toJS(); // Generate the list of sections const pluginsSections = Object.keys(pluginsObject).reduce((acc, current) => { pluginsObject[current].leftMenuSections.forEach((section = {}) => { acc[snakeCase(section.name)] = { name: section.name, links: (get(acc[snakeCase(section.name)], 'links') || []).concat(section.links.map(link => { link.source = current; link.plugin = !isEmpty(pluginsObject[link.plugin]) ? link.plugin : pluginsObject[current].id; return link; })), }; }); return acc; }, {}); const linkSections = Object.keys(pluginsSections).map((current, j) => (
{pluginsSections[current].name}