mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Hide unavailable page links to non-admin users in settings and header (#4524)
* Filter unavailable menu items in SettingsWrapper * Don't show Alert Destination in header to users
This commit is contained in:
committed by
Arik Fraimovich
parent
76f0dcb085
commit
465dbc03b7
@@ -17,11 +17,13 @@ function wrapSettingsTab(options, WrappedComponent) {
|
||||
<PageHeader title="Settings" />
|
||||
<div className="bg-white tiled">
|
||||
<Menu selectedKeys={[activeItem && activeItem.title]} selectable={false} mode="horizontal">
|
||||
{settingsMenu.items.map(item => (
|
||||
<Menu.Item key={item.title}>
|
||||
<a href={item.path}>{item.title}</a>
|
||||
</Menu.Item>
|
||||
))}
|
||||
{settingsMenu.items
|
||||
.filter(item => item.isAvailable())
|
||||
.map(item => (
|
||||
<Menu.Item key={item.title}>
|
||||
<a href={item.path}>{item.title}</a>
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu>
|
||||
<div className="p-15">
|
||||
<div>
|
||||
|
||||
@@ -134,7 +134,7 @@ function DesktopNavbar() {
|
||||
<a href="query_snippets">Query Snippets</a>
|
||||
</Menu.Item>
|
||||
)}
|
||||
{currentUser.hasPermission("list_users") && (
|
||||
{currentUser.isAdmin && (
|
||||
<Menu.Item key="destinations">
|
||||
<a href="destinations">Alert Destinations</a>
|
||||
</Menu.Item>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isFunction, extend, omit, sortBy, find } from "lodash";
|
||||
import { currentUser } from "@/services/auth";
|
||||
|
||||
class SettingsMenuItem {
|
||||
constructor(menuItem) {
|
||||
@@ -11,6 +12,10 @@ class SettingsMenuItem {
|
||||
isActive(path) {
|
||||
return path.startsWith(this.pathPrefix);
|
||||
}
|
||||
|
||||
isAvailable() {
|
||||
return this.permission === undefined || currentUser.hasPermission(this.permission);
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsMenu {
|
||||
|
||||
Reference in New Issue
Block a user