From 7b15e6e3c789f82ce682b011d0904e818dfbadc3 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Wed, 11 Jan 2023 19:24:18 +0200 Subject: [PATCH] fix(nav): make doc and bug buttons customizable (#22682) --- superset-frontend/src/types/bootstrapTypes.ts | 4 + .../src/views/components/RightMenu.tsx | 47 ++++--- superset/config.py | 2 + .../templates/appbuilder/navbar_right.html | 127 ------------------ superset/views/base.py | 4 + 5 files changed, 40 insertions(+), 144 deletions(-) delete mode 100644 superset/templates/appbuilder/navbar_right.html diff --git a/superset-frontend/src/types/bootstrapTypes.ts b/superset-frontend/src/types/bootstrapTypes.ts index b667b9a80c..db646b84a7 100644 --- a/superset-frontend/src/types/bootstrapTypes.ts +++ b/superset-frontend/src/types/bootstrapTypes.ts @@ -94,10 +94,14 @@ export interface BrandProps { export interface NavBarProps { show_watermark: boolean; bug_report_url?: string; + bug_report_text?: string; + bug_report_icon?: string; version_string?: string; version_sha?: string; build_number?: string; documentation_url?: string; + documentation_text?: string; + documentation_icon?: string; languages: Languages; show_language_picker: boolean; user_is_anonymous: boolean; diff --git a/superset-frontend/src/views/components/RightMenu.tsx b/superset-frontend/src/views/components/RightMenu.tsx index e551440034..59e7f7f448 100644 --- a/superset-frontend/src/views/components/RightMenu.tsx +++ b/superset-frontend/src/views/components/RightMenu.tsx @@ -539,25 +539,38 @@ const RightMenu = ({ )} {navbarRight.documentation_url && ( - - -   - + <> + + {navbarRight.documentation_icon ? ( + + ) : ( + + )} + +   + )} {navbarRight.bug_report_url && ( - - - + <> + + {navbarRight.bug_report_icon ? ( + + ) : ( + + )} + +   + )} {navbarRight.user_is_anonymous && ( diff --git a/superset/config.py b/superset/config.py index 64ff09a5c8..d9c36955e3 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1303,6 +1303,8 @@ EMAIL_PAGE_RENDER_WAIT = int(timedelta(seconds=30).total_seconds()) # Send user to a link where they can report bugs BUG_REPORT_URL = None +BUG_REPORT_TEXT = "Report a bug" +BUG_REPORT_ICON = None # Recommended size: 16x16 # Send user to a link where they can read more about Superset DOCUMENTATION_URL = None diff --git a/superset/templates/appbuilder/navbar_right.html b/superset/templates/appbuilder/navbar_right.html deleted file mode 100644 index 334e7ea2ad..0000000000 --- a/superset/templates/appbuilder/navbar_right.html +++ /dev/null @@ -1,127 +0,0 @@ -{# - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -#} - -{% set bug_report_url = appbuilder.app.config['BUG_REPORT_URL'] %} -{% set documentation_url = appbuilder.app.config['DOCUMENTATION_URL'] %} -{% set documentation_text = appbuilder.app.config['DOCUMENTATION_TEXT'] %} -{% set documentation_icon = appbuilder.app.config['DOCUMENTATION_ICON'] %} -{% set version_string = appbuilder.app.config['VERSION_STRING'] %} -{% set version_sha = appbuilder.app.config['VERSION_SHA'] %} - -{% set locale = session['locale'] %} -{% if not locale %} - {% set locale = 'en' %} -{% endif %} - -{% if not current_user.is_anonymous %} - -{% endif %} -{% if documentation_url %} -
  • - - {% if documentation_icon %} - {{ documentation_text }} - {% else %} -   - {% endif %} - -
  • -{% endif %} -{% if bug_report_url %} -
  • - -   - -
  • -{% endif %} -{% if languages.keys()|length > 1 %} - -{% endif %} - -{% if not current_user.is_anonymous %} - -{% else %} -
  • - {{_("Login")}}
  • -{% endif %} diff --git a/superset/views/base.py b/superset/views/base.py index 41a27b4139..5153840822 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -367,7 +367,11 @@ def menu_data(user: User) -> Dict[str, Any]: # show the watermark if the default app icon has been overriden "show_watermark": ("superset-logo-horiz" not in appbuilder.app_icon), "bug_report_url": appbuilder.app.config["BUG_REPORT_URL"], + "bug_report_icon": appbuilder.app.config["BUG_REPORT_ICON"], + "bug_report_text": appbuilder.app.config["BUG_REPORT_TEXT"], "documentation_url": appbuilder.app.config["DOCUMENTATION_URL"], + "documentation_icon": appbuilder.app.config["DOCUMENTATION_ICON"], + "documentation_text": appbuilder.app.config["DOCUMENTATION_TEXT"], "version_string": appbuilder.app.config["VERSION_STRING"], "version_sha": appbuilder.app.config["VERSION_SHA"], "build_number": build_number,