2016-08-24 15:09:42 +02:00
|
|
|
/**
|
2017-03-15 11:48:56 +01:00
|
|
|
*
|
|
|
|
* LeftMenuLinkContainer
|
|
|
|
*
|
|
|
|
*/
|
2016-08-24 15:09:42 +02:00
|
|
|
|
2017-09-26 16:36:28 +02:00
|
|
|
import React from 'react';
|
2017-09-20 11:12:04 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2017-08-17 15:39:09 +02:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2017-10-11 16:54:58 +02:00
|
|
|
import { get, map, size } from 'lodash';
|
2017-08-18 14:17:15 +02:00
|
|
|
|
2016-08-24 15:09:42 +02:00
|
|
|
import LeftMenuLink from 'components/LeftMenuLink';
|
2017-08-17 15:39:09 +02:00
|
|
|
|
2016-08-24 15:09:42 +02:00
|
|
|
import styles from './styles.scss';
|
2017-08-17 15:39:09 +02:00
|
|
|
import messages from './messages.json';
|
2016-08-24 15:09:42 +02:00
|
|
|
|
2017-10-11 16:54:58 +02:00
|
|
|
function LeftMenuLinkContainer({ plugins }) {
|
|
|
|
// Generate the list of sections
|
|
|
|
const linkSections = map(plugins.toJS(), plugin => (
|
|
|
|
plugin.leftMenuSections.map((leftMenuSection, j) => {
|
|
|
|
|
|
|
|
if (size(get(leftMenuSection, 'links')) === 0) {
|
2017-10-16 09:52:47 +02:00
|
|
|
return <div key="emptyDiv" />;
|
2017-10-11 16:54:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2017-09-14 12:19:24 +02:00
|
|
|
<div key={j}>
|
|
|
|
<p className={styles.title}>{leftMenuSection.name}</p>
|
|
|
|
<ul className={styles.list}>
|
2017-10-16 09:52:47 +02:00
|
|
|
{leftMenuSection.links.map((link) =>
|
|
|
|
<LeftMenuLink key={link.label} icon={link.icon || 'link'} label={link.label} destination={`/plugins/${plugin.id}/${link.destination}`} />
|
2017-09-14 12:19:24 +02:00
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
2017-09-09 16:06:19 +02:00
|
|
|
);
|
2017-10-11 16:54:58 +02:00
|
|
|
})
|
|
|
|
));
|
2016-08-24 15:09:42 +02:00
|
|
|
|
2017-10-11 16:54:58 +02:00
|
|
|
// Check if the plugins list is empty or not
|
|
|
|
const pluginsLinks = plugins.size
|
|
|
|
? plugins.valueSeq().map((plugin) => (
|
|
|
|
<LeftMenuLink
|
|
|
|
key={plugin.get('id')}
|
|
|
|
icon={plugin.get('icon') || 'plug'}
|
|
|
|
label={plugin.get('name')}
|
|
|
|
destination={`/plugins/${plugin.get('id')}`}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
: (
|
|
|
|
<li className={styles.noPluginsInstalled}>
|
|
|
|
<FormattedMessage {...messages.noPluginsInstalled} />.
|
|
|
|
</li>
|
2016-08-24 15:09:42 +02:00
|
|
|
);
|
2017-10-11 16:54:58 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.leftMenuLinkContainer}>
|
|
|
|
{linkSections}
|
|
|
|
<div>
|
|
|
|
<p className={styles.title}><FormattedMessage {...messages.plugins} /></p>
|
|
|
|
<ul className={styles.list}>
|
|
|
|
{pluginsLinks}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<p className={styles.title}><FormattedMessage {...messages.general} /></p>
|
|
|
|
<ul className={styles.list}>
|
|
|
|
<LeftMenuLink
|
|
|
|
icon="cubes"
|
|
|
|
label={messages.listPlugins.id}
|
|
|
|
destination="/list-plugins"
|
|
|
|
/>
|
|
|
|
<LeftMenuLink
|
|
|
|
icon="download"
|
|
|
|
label={messages.installNewPlugin.id}
|
|
|
|
destination="/install-plugin"
|
|
|
|
/>
|
|
|
|
<LeftMenuLink
|
|
|
|
icon="gear"
|
|
|
|
label={messages.configuration.id}
|
|
|
|
destination="/configuration"
|
|
|
|
/>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2016-08-24 15:09:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LeftMenuLinkContainer.propTypes = {
|
2017-09-20 11:12:04 +02:00
|
|
|
plugins: PropTypes.object.isRequired,
|
2016-08-24 15:09:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default LeftMenuLinkContainer;
|