You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ta...@apache.org on 2021/09/13 17:59:57 UTC
[superset] branch master updated: feat: show build number value in
the About if present in the config (#14955)
This is an automated email from the ASF dual-hosted git repository.
tai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new c6ac107 feat: show build number value in the About if present in the config (#14955)
c6ac107 is described below
commit c6ac10716a8d2dfe222fb2b1639b8486c93687ce
Author: cccs-joel <jo...@cyber.gc.ca>
AuthorDate: Mon Sep 13 12:59:08 2021 -0500
feat: show build number value in the About if present in the config (#14955)
---
superset-frontend/src/components/Menu/Menu.test.tsx | 7 +++++--
superset-frontend/src/components/Menu/Menu.tsx | 1 +
superset-frontend/src/components/Menu/MenuRight.tsx | 9 ++++++++-
superset/config.py | 4 ++++
superset/views/base.py | 2 ++
5 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/components/Menu/Menu.test.tsx b/superset-frontend/src/components/Menu/Menu.test.tsx
index 212521b..f3a2fd1 100644
--- a/superset-frontend/src/components/Menu/Menu.test.tsx
+++ b/superset-frontend/src/components/Menu/Menu.test.tsx
@@ -103,6 +103,7 @@ const mockedProps = {
locale: 'en',
version_string: '1.0.0',
version_sha: 'randomSHA',
+ build_number: 'randomBuildNumber',
},
settings: [
{
@@ -280,10 +281,10 @@ test('should render the Profile link when available', async () => {
expect(profile).toHaveAttribute('href', user_profile_url);
});
-test('should render the About section and version_string or sha when available', async () => {
+test('should render the About section and version_string, sha or build_number when available', async () => {
const {
data: {
- navbar_right: { version_sha, version_string },
+ navbar_right: { version_sha, version_string, build_number },
},
} = mockedProps;
@@ -292,9 +293,11 @@ test('should render the About section and version_string or sha when available',
const about = await screen.findByText('About');
const version = await screen.findByText(`Version: ${version_string}`);
const sha = await screen.findByText(`SHA: ${version_sha}`);
+ const build = await screen.findByText(`Build: ${build_number}`);
expect(about).toBeInTheDocument();
expect(version).toBeInTheDocument();
expect(sha).toBeInTheDocument();
+ expect(build).toBeInTheDocument();
});
test('should render the Documentation link when available', async () => {
diff --git a/superset-frontend/src/components/Menu/Menu.tsx b/superset-frontend/src/components/Menu/Menu.tsx
index 098aa3a..13d19fb 100644
--- a/superset-frontend/src/components/Menu/Menu.tsx
+++ b/superset-frontend/src/components/Menu/Menu.tsx
@@ -44,6 +44,7 @@ export interface NavBarProps {
bug_report_url?: string;
version_string?: string;
version_sha?: string;
+ build_number?: string;
documentation_url?: string;
languages: Languages;
show_language_picker: boolean;
diff --git a/superset-frontend/src/components/Menu/MenuRight.tsx b/superset-frontend/src/components/Menu/MenuRight.tsx
index 35d2cb0..1626713 100644
--- a/superset-frontend/src/components/Menu/MenuRight.tsx
+++ b/superset-frontend/src/components/Menu/MenuRight.tsx
@@ -146,7 +146,9 @@ const RightMenu = ({
</Menu.Item>
</Menu.ItemGroup>,
]}
- {(navbarRight.version_string || navbarRight.version_sha) && [
+ {(navbarRight.version_string ||
+ navbarRight.version_sha ||
+ navbarRight.build_number) && [
<Menu.Divider key="version-info-divider" />,
<Menu.ItemGroup key="about-section" title={t('About')}>
<div className="about-section">
@@ -165,6 +167,11 @@ const RightMenu = ({
SHA: {navbarRight.version_sha}
</div>
)}
+ {navbarRight.build_number && (
+ <div css={versionInfoStyles}>
+ Build: {navbarRight.build_number}
+ </div>
+ )}
</div>
</Menu.ItemGroup>,
]}
diff --git a/superset/config.py b/superset/config.py
index 7ccb695..c4b3a66 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -112,6 +112,10 @@ VERSION_STRING = _try_json_readversion(VERSION_INFO_FILE) or _try_json_readversi
VERSION_SHA_LENGTH = 8
VERSION_SHA = _try_json_readsha(VERSION_INFO_FILE, VERSION_SHA_LENGTH)
+# Build number is shown in the About section if available. This
+# can be replaced at build time to expose build information.
+BUILD_NUMBER = None
+
# default viz used in chart explorer
DEFAULT_VIZ_TYPE = "table"
diff --git a/superset/views/base.py b/superset/views/base.py
index 61bd312..9d27861 100644
--- a/superset/views/base.py
+++ b/superset/views/base.py
@@ -309,6 +309,7 @@ def menu_data() -> Dict[str, Any]:
brand_text = appbuilder.app.config["LOGO_RIGHT_TEXT"]
if callable(brand_text):
brand_text = brand_text()
+ build_number = appbuilder.app.config["BUILD_NUMBER"]
return {
"menu": menu,
"brand": {
@@ -326,6 +327,7 @@ def menu_data() -> Dict[str, Any]:
"documentation_url": appbuilder.app.config["DOCUMENTATION_URL"],
"version_string": appbuilder.app.config["VERSION_STRING"],
"version_sha": appbuilder.app.config["VERSION_SHA"],
+ "build_number": build_number,
"languages": languages,
"show_language_picker": len(languages.keys()) > 1,
"user_is_anonymous": g.user.is_anonymous,