mirror of
https://github.com/strapi/strapi.git
synced 2025-08-11 18:27:22 +00:00
24 lines
657 B
JavaScript
24 lines
657 B
JavaScript
![]() |
import { get, omit, set, sortBy } from 'lodash';
|
||
|
|
||
|
const sortLinks = links => sortBy(links, object => object.name);
|
||
|
|
||
|
const init = (initialState, plugins = {}) => {
|
||
|
const pluginsLinks = Object.values(plugins).reduce((acc, current) => {
|
||
|
const pluginsSectionLinks = get(current, 'menu.pluginsSectionLinks', []);
|
||
|
|
||
|
return [...acc, ...pluginsSectionLinks];
|
||
|
}, []);
|
||
|
const sortedLinks = sortLinks(pluginsLinks).map(link => {
|
||
|
return { ...omit(link, 'name'), isDisplayed: false };
|
||
|
});
|
||
|
|
||
|
if (sortedLinks.length) {
|
||
|
set(initialState, 'pluginsSectionLinks', sortedLinks);
|
||
|
}
|
||
|
|
||
|
return initialState;
|
||
|
};
|
||
|
|
||
|
export default init;
|
||
|
export { sortLinks };
|