Skip to content

Commit

Permalink
fix: empty "manage" menu showing in ACP
Browse files Browse the repository at this point in the history
... if no privileges corresponding to those menu items
are given
  • Loading branch information
julianlam committed Aug 21, 2020
1 parent cc26860 commit 4b0cb26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/middleware/admin.js
Expand Up @@ -73,6 +73,7 @@ middleware.renderHeader = async (req, res, data) => {
version: version,
latestVersion: results.latestVersion,
upgradeAvailable: results.latestVersion && semver.gt(results.latestVersion, version),
showManageMenu: results.privileges.superadmin || ['categories', 'privileges', 'users', 'settings'].some(priv => results.privileges[`admin:${priv}`]),
};

templateValues.template = { name: res.locals.template };
Expand Down
4 changes: 4 additions & 0 deletions src/views/admin/partials/menu.tpl
Expand Up @@ -11,6 +11,7 @@
</ul>
</section>

{{{ if showManageMenu }}}
<section class="menu-section">
<h3 class="menu-section-title">[[admin/menu:section-manage]]</h3>
<ul class="menu-section-list">
Expand All @@ -30,6 +31,7 @@
{{{ end }}}
</ul>
</section>
{{{ end }}}

{{{ if user.privileges.admin:settings }}}
<section class="menu-section">
Expand Down Expand Up @@ -180,6 +182,7 @@
</li>
{{{ end }}}

{{{ if showManageMenu }}}
<li class="dropdown menu-item">
<a id="manage-menu" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">[[admin/menu:section-manage]]</a>
<ul class="dropdown-menu" role="menu">
Expand All @@ -199,6 +202,7 @@
{{{ end }}}
</ul>
</li>
{{{ end }}}

{{{ if user.privileges.admin:settings }}}
<li class="dropdown menu-item">
Expand Down

0 comments on commit 4b0cb26

Please sign in to comment.