add config to hide some user menu items (#16156)

This commit is contained in:
Elizabeth Thompson 2021-08-10 09:03:13 -07:00 committed by GitHub
parent 6e1d16d956
commit 5488a8a948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -136,9 +136,11 @@ const RightMenu = ({
<a href={navbarRight.user_profile_url}>{t('Profile')}</a>
</Menu.Item>
)}
<Menu.Item key="info">
<a href={navbarRight.user_info_url}>{t('Info')}</a>
</Menu.Item>
{navbarRight.user_info_url && (
<Menu.Item key="info">
<a href={navbarRight.user_info_url}>{t('Info')}</a>
</Menu.Item>
)}
<Menu.Item key="logout">
<a href={navbarRight.user_logout_url}>{t('Logout')}</a>
</Menu.Item>

View File

@ -1233,6 +1233,9 @@ GLOBAL_ASYNC_QUERIES_WEBSOCKET_URL = "ws://127.0.0.1:8080/"
#
DATASET_HEALTH_CHECK: Optional[Callable[["SqlaTable"], str]] = None
# Do not show user info or profile in the menu
MENU_HIDE_USER_INFO = False
# SQLalchemy link doc reference
SQLALCHEMY_DOCS_URL = "https://docs.sqlalchemy.org/en/13/core/engines.html"
SQLALCHEMY_DISPLAY_TEXT = "SQLAlchemy docs"

View File

@ -332,11 +332,13 @@ def menu_data() -> Dict[str, Any]:
"languages": languages,
"show_language_picker": len(languages.keys()) > 1,
"user_is_anonymous": g.user.is_anonymous,
"user_info_url": appbuilder.get_url_for_userinfo,
"user_info_url": None
if appbuilder.app.config["MENU_HIDE_USER_INFO"]
else appbuilder.get_url_for_userinfo,
"user_logout_url": appbuilder.get_url_for_logout,
"user_login_url": appbuilder.get_url_for_login,
"user_profile_url": None
if g.user.is_anonymous
if g.user.is_anonymous or appbuilder.app.config["MENU_HIDE_USER_INFO"]
else f"/superset/profile/{g.user.username}",
"locale": session.get("locale", "en"),
},