Allow to hide menus with globals permissions. Fix: 940
This commit is contained in:
parent
613a6fb1f0
commit
ead7bbf9dd
3 changed files with 33 additions and 22 deletions
|
@ -28,10 +28,10 @@ import {getUrl} from "./lib/urls";
|
||||||
import {withComponentMixins} from "./lib/decorator-helpers";
|
import {withComponentMixins} from "./lib/decorator-helpers";
|
||||||
import Update from "./settings/Update";
|
import Update from "./settings/Update";
|
||||||
|
|
||||||
const topLevelMenuKeys = ['lists', 'channels', 'templates', 'campaigns'];
|
const topLevelMenuKeys = ['Lists', 'Channels', 'Templates', 'Campaigns'];
|
||||||
|
|
||||||
if (mailtrainConfig.reportsEnabled) {
|
if (mailtrainConfig.reportsEnabled) {
|
||||||
topLevelMenuKeys.push('reports');
|
topLevelMenuKeys.push('Reports');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,29 +67,38 @@ class Root extends Component {
|
||||||
|
|
||||||
const topLevelMenu = [];
|
const topLevelMenu = [];
|
||||||
|
|
||||||
|
if (mailtrainConfig.isAuthenticated) {
|
||||||
|
|
||||||
for (const entryKey of topLevelMenuKeys) {
|
for (const entryKey of topLevelMenuKeys) {
|
||||||
const entry = topLevelItems[entryKey];
|
const entry = topLevelItems[entryKey.toLowerCase()];
|
||||||
const link = entry.link || entry.externalLink;
|
const link = entry.link || entry.externalLink;
|
||||||
|
|
||||||
|
if (mailtrainConfig.user.admin || mailtrainConfig.globalPermissions["manage"+entryKey]) {
|
||||||
if (link && path.startsWith(link)) {
|
if (link && path.startsWith(link)) {
|
||||||
topLevelMenu.push(<NavLink key={entryKey} className="active" to={link}>{entry.title} <span className="sr-only">{t('current')}</span></NavLink>);
|
topLevelMenu.push(<NavLink key={entryKey.toLowerCase()} className="active" to={link}>{entry.title} <span className="sr-only">{t('current')}</span></NavLink>);
|
||||||
} else {
|
} else {
|
||||||
topLevelMenu.push(<NavLink key={entryKey} to={link}>{entry.title}</NavLink>);
|
topLevelMenu.push(<NavLink key={entryKey.toLowerCase()} to={link}>{entry.title}</NavLink>);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mailtrainConfig.isAuthenticated) {
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ul className="navbar-nav mt-navbar-nav-left">
|
<ul className="navbar-nav mt-navbar-nav-left">
|
||||||
{topLevelMenu}
|
{topLevelMenu}
|
||||||
<NavDropdown label={t('administration')}>
|
<NavDropdown label={t('administration')}>
|
||||||
{mailtrainConfig.globalPermissions.displayManageUsers && <DropdownLink to="/users">{t('users')}</DropdownLink>}
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageUsers) &&
|
||||||
<DropdownLink to="/namespaces">{t('namespaces')}</DropdownLink>
|
<DropdownLink to="/users">{t('users')}</DropdownLink>}
|
||||||
{mailtrainConfig.globalPermissions.manageSettings && <DropdownLink to="/settings">{t('globalSettings')}</DropdownLink>}
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageNamespaces) &&
|
||||||
<DropdownLink to="/send-configurations">{t('sendConfigurations')}</DropdownLink>
|
<DropdownLink to="/namespaces">{t('namespaces')}</DropdownLink>}
|
||||||
{mailtrainConfig.globalPermissions.manageBlacklist && <DropdownLink to="/blacklist">{t('blacklist')}</DropdownLink>}
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageSettings) &&
|
||||||
<DropdownLink to="/account/api">{t('api')}</DropdownLink>
|
<DropdownLink to="/settings">{t('globalSettings')}</DropdownLink>}
|
||||||
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageSendConfigurations) &&
|
||||||
|
<DropdownLink to="/send-configurations">{t('sendConfigurations')}</DropdownLink>}
|
||||||
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageBlacklist) &&
|
||||||
|
<DropdownLink to="/blacklist">{t('blacklist')}</DropdownLink>}
|
||||||
|
{(mailtrainConfig.user.admin || mailtrainConfig.globalPermissions.manageApi) &&
|
||||||
|
<DropdownLink to="/account/api">{t('api')}</DropdownLink>}
|
||||||
</NavDropdown>
|
</NavDropdown>
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="navbar-nav mt-navbar-nav-right">
|
<ul className="navbar-nav mt-navbar-nav-right">
|
||||||
|
@ -101,6 +110,7 @@ class Root extends Component {
|
||||||
</ul>
|
</ul>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -277,12 +277,12 @@ defaultRoles:
|
||||||
name: Global Master
|
name: Global Master
|
||||||
admin: true
|
admin: true
|
||||||
description: All permissions
|
description: All permissions
|
||||||
permissions: [rebuildPermissions, createJavascriptWithROAccess, displayManageUsers, manageBlacklist, manageSettings, setupAutomation]
|
permissions: [rebuildPermissions, createJavascriptWithROAccess, manageUsers, manageBlacklist, manageSettings, setupAutomation]
|
||||||
rootNamespaceRole: master
|
rootNamespaceRole: master
|
||||||
campaignsAdmin:
|
campaignsAdmin:
|
||||||
name: Campaigns Admin
|
name: Campaigns Admin
|
||||||
description: Under the namespace in which the user is located, the user has all permissions for managing lists, templates and campaigns and the permission to send to send configurations.
|
description: Under the namespace in which the user is located, the user has all permissions for managing lists, templates and campaigns and the permission to send to send configurations.
|
||||||
permissions: [setupAutomation]
|
permissions: [setupAutomation, manageLists, manageChannels, manageTemplates, manageCampaigns, manageReports, manageApi, manageSendConfigurations, manageNamespaces]
|
||||||
ownNamespaceRole: campaignsAdmin
|
ownNamespaceRole: campaignsAdmin
|
||||||
campaignsAdminWithoutNamespace:
|
campaignsAdminWithoutNamespace:
|
||||||
name: Campaigns Admin (multiple namespaces)
|
name: Campaigns Admin (multiple namespaces)
|
||||||
|
|
|
@ -40,7 +40,8 @@ async function getAuthenticatedConfig(context) {
|
||||||
user: {
|
user: {
|
||||||
id: context.user.id,
|
id: context.user.id,
|
||||||
username: context.user.username,
|
username: context.user.username,
|
||||||
namespace: context.user.namespace
|
namespace: context.user.namespace,
|
||||||
|
admin: (config.roles.global[context.user.role]["admin"] || false)
|
||||||
},
|
},
|
||||||
globalPermissions,
|
globalPermissions,
|
||||||
editors: config.editors,
|
editors: config.editors,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue