diff --git a/packages/lib/plugin.js b/packages/lib/plugin.js index 01be7c82..a0d94805 100644 --- a/packages/lib/plugin.js +++ b/packages/lib/plugin.js @@ -588,11 +588,14 @@ class BaseControlPlugin { /** * Plugin supplied pages - * @typedef {Object} module:Lib/plugin~Page + * @typedef {Object} module:lib/plugin~Page * @property {string} path - URL path to this page. * @property {string=} sidebarPath - * If present and this path matches one of the pages in the sidebar it * will cause that sidebar entry to be highlighted as active. + * @property {string=} sidebarGroup - + * If present group this entry under a group of the given name in the + * sidebar. * @property {string=} sidebarName - * If present creates an entry in the sidebar for this page with the * given text. diff --git a/packages/web_ui/src/components/SiteLayout.jsx b/packages/web_ui/src/components/SiteLayout.jsx index 089b605d..5a547205 100644 --- a/packages/web_ui/src/components/SiteLayout.jsx +++ b/packages/web_ui/src/components/SiteLayout.jsx @@ -37,6 +37,27 @@ export default function SiteLayout(props) { combinedPages.push(...plugin.pages); } + let menuItems = []; + let menuGroups = new Map(); + for (let { sidebarName, sidebarGroup, permission, path } of combinedPages) { + if (!sidebarName || permission && !account.hasPermission(permission)) { + continue; + } + if (sidebarGroup) { + let group = menuGroups.get(sidebarGroup); + if (!group) { + group = []; + menuGroups.set(sidebarGroup, group); + } + group.push(