You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2026/04/23 17:37:36 UTC
(superset) 19/25: Fix header name
This is an automated email from the ASF dual-hosted git repository.
betodealmeida pushed a commit to branch backup/semantic-layer-rename-database-dataset-before-rebase-20260423-133321
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 07712fbd20d22292f91b234c617100aceed52178
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Fri Apr 17 14:27:48 2026 -0400
Fix header name
---
superset-frontend/src/features/home/Menu.tsx | 13 ++-
superset-frontend/src/pages/DatabaseList/index.tsx | 2 +-
superset/initialization/__init__.py | 3 +-
superset/utils/semantic_layer_labels.py | 105 +++++++++++++++++++++
4 files changed, 120 insertions(+), 3 deletions(-)
diff --git a/superset-frontend/src/features/home/Menu.tsx b/superset-frontend/src/features/home/Menu.tsx
index b7eacb65cf4..bea7e32717a 100644
--- a/superset-frontend/src/features/home/Menu.tsx
+++ b/superset-frontend/src/features/home/Menu.tsx
@@ -34,6 +34,7 @@ import {
MenuObjectProps,
MenuData,
} from 'src/types/bootstrapTypes';
+import { datasetsLabel } from 'src/utils/semanticLayerLabels';
import RightMenu from './RightMenu';
import { NAVBAR_MENU_POPUP_OFFSET } from './commonMenuData';
@@ -221,7 +222,7 @@ export function Menu({
setActiveTabs(['Charts']);
break;
case path.startsWith(Paths.Datasets):
- setActiveTabs(['Datasets']);
+ setActiveTabs([datasetsLabel()]);
break;
case path.startsWith(Paths.SqlLab) || path.startsWith(Paths.SavedQueries):
setActiveTabs(['SQL']);
@@ -399,6 +400,12 @@ export default function MenuWrapper({ data, ...rest }: MenuProps) {
Manage: true,
};
+ // Remap labels that depend on feature flags so they stay in sync with
+ // the active-tab key used in the Menu component above.
+ const labelOverrides: Record<string, () => string> = {
+ Datasets: datasetsLabel,
+ };
+
// Cycle through menu.menu to build out cleanedMenu and settings
const cleanedMenu: MenuObjectProps[] = [];
const settings: MenuObjectProps[] = [];
@@ -410,6 +417,10 @@ export default function MenuWrapper({ data, ...rest }: MenuProps) {
const children: (MenuObjectProps | string)[] = [];
const newItem = {
...item,
+ // Apply any label override for this item (keyed by FAB internal name).
+ ...(item.name && labelOverrides[item.name]
+ ? { label: labelOverrides[item.name]() }
+ : {}),
};
// Filter childs
diff --git a/superset-frontend/src/pages/DatabaseList/index.tsx b/superset-frontend/src/pages/DatabaseList/index.tsx
index c428d84b229..1722d5dbc8b 100644
--- a/superset-frontend/src/pages/DatabaseList/index.tsx
+++ b/superset-frontend/src/pages/DatabaseList/index.tsx
@@ -842,7 +842,7 @@ function DatabaseList({
operator: FilterOperator.Equals,
unfilteredLabel: t('All'),
selects: [
- { label: databaseLabel(), value: 'database' },
+ { label: t('Database'), value: 'database' },
{ label: t('Semantic Layer'), value: 'semantic_layer' },
],
});
diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py
index c8ec9bbe516..ba096bdd23a 100644
--- a/superset/initialization/__init__.py
+++ b/superset/initialization/__init__.py
@@ -66,6 +66,7 @@ from superset.superset_typing import FlaskResponse
from superset.utils.core import is_test, pessimistic_connection_handling
from superset.utils.decorators import transaction
from superset.utils.log import DBEventLogger, get_event_logger_from_cfg_value
+from superset.utils.semantic_layer_labels import database_connections_menu_label
if TYPE_CHECKING:
from superset.app import SupersetApp
@@ -308,7 +309,7 @@ class SupersetAppInitializer: # pylint: disable=too-many-public-methods
appbuilder.add_view(
DatabaseView,
"Databases",
- label=_("Database Connections"),
+ label=database_connections_menu_label(),
icon="fa-database",
category="Data",
category_label=_("Data"),
diff --git a/superset/utils/semantic_layer_labels.py b/superset/utils/semantic_layer_labels.py
new file mode 100644
index 00000000000..8e690973209
--- /dev/null
+++ b/superset/utils/semantic_layer_labels.py
@@ -0,0 +1,105 @@
+# 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.
+
+"""
+Label helpers for SEMANTIC_LAYERS feature flag.
+
+When the SEMANTIC_LAYERS feature flag is enabled the UI broadens
+"dataset" → "datasource" and "database" → "data connection" so
+that semantic views and semantic layers feel like first-class
+citizens alongside traditional datasets and database connections.
+
+Mirror of superset-frontend/src/utils/semanticLayerLabels.ts.
+"""
+
+from __future__ import annotations
+
+from flask_babel import lazy_gettext as _
+
+
+def _sl(legacy: str, semantic: str) -> str:
+ """Return *semantic* when SEMANTIC_LAYERS is enabled, else *legacy*."""
+ # Imported lazily to avoid a circular import at module load time
+ # (superset.utils.semantic_layer_labels is imported by superset.initialization,
+ # which is itself imported during superset package initialization).
+ from superset import feature_flag_manager # pylint: disable=import-outside-toplevel
+
+ return (
+ semantic
+ if feature_flag_manager.is_feature_enabled("SEMANTIC_LAYERS")
+ else legacy
+ )
+
+
+# ---------------------------------------------------------------------------
+# "dataset" family
+# ---------------------------------------------------------------------------
+
+
+def dataset_label() -> str:
+ """Capitalized singular: "Dataset" / "Datasource" """
+ return _sl(_("Dataset"), _("Datasource"))
+
+
+def dataset_label_lower() -> str:
+ """Lower-case singular: "dataset" / "datasource" """
+ return _sl(_("dataset"), _("datasource"))
+
+
+def datasets_label() -> str:
+ """Capitalized plural: "Datasets" / "Datasources" """
+ return _sl(_("Datasets"), _("Datasources"))
+
+
+def datasets_label_lower() -> str:
+ """Lower-case plural: "datasets" / "datasources" """
+ return _sl(_("datasets"), _("datasources"))
+
+
+# ---------------------------------------------------------------------------
+# "database" family
+# ---------------------------------------------------------------------------
+
+
+def database_label() -> str:
+ """Capitalized singular: "Database" / "Data connection" """
+ return _sl(_("Database"), _("Data connection"))
+
+
+def database_label_lower() -> str:
+ """Lower-case singular: "database" / "data connection" """
+ return _sl(_("database"), _("data connection"))
+
+
+def databases_label() -> str:
+ """Capitalized plural: "Databases" / "Data connections" """
+ return _sl(_("Databases"), _("Data connections"))
+
+
+def databases_label_lower() -> str:
+ """Lower-case plural: "databases" / "data connections" """
+ return _sl(_("databases"), _("data connections"))
+
+
+# ---------------------------------------------------------------------------
+# Menu label (includes the word "Connections")
+# ---------------------------------------------------------------------------
+
+
+def database_connections_menu_label() -> str:
+ """Menu entry label: "Database Connections" / "Data Connections" """
+ return _sl(_("Database Connections"), _("Data Connections"))