You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2021/11/03 03:05:31 UTC
[superset] branch hugh/show-tabstates created (now 81dc533)
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a change to branch hugh/show-tabstates
in repository https://gitbox.apache.org/repos/asf/superset.git.
at 81dc533 saving
This branch includes the following new commits:
new 81dc533 saving
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: saving
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hugh pushed a commit to branch hugh/show-tabstates
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 81dc53370da7fa6ade31540934ad6281a9041c1a
Author: hughhhh <hu...@gmail.com>
AuthorDate: Tue Nov 2 19:13:49 2021 -0700
saving
---
.../src/views/CRUD/data/database/DatabaseList.tsx | 5 ++++-
superset/databases/api.py | 8 ++++++++
superset/databases/dao.py | 10 +++++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
index a60fa25..a6d7dd0 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
@@ -51,6 +51,7 @@ const CONFIRM_OVERWRITE_MESSAGE = t(
interface DatabaseDeleteObject extends DatabaseObject {
chart_count: number;
dashboard_count: number;
+ sqllab_tab_state: number;
}
interface DatabaseListProps {
addDangerToast: (msg: string) => void;
@@ -122,6 +123,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
...database,
chart_count: json.charts.count,
dashboard_count: json.dashboards.count,
+ sqllab_tabs_count: json.sqllab_tab_states.count,
});
})
.catch(
@@ -437,10 +439,11 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
{databaseCurrentlyDeleting && (
<DeleteModal
description={t(
- 'The database %s is linked to %s charts that appear on %s dashboards. Are you sure you want to continue? Deleting the database will break those objects.',
+ 'The database %s is linked to %s charts that appear on %s dashboards nd users have %s SQL Lab tabs using this database open. Are you sure you want to continue? Deleting the database will break those objects.',
databaseCurrentlyDeleting.database_name,
databaseCurrentlyDeleting.chart_count,
databaseCurrentlyDeleting.dashboard_count,
+ databaseCurrentlyDeleting.sqllab_tabs_count,
)}
onConfirm={() => {
if (databaseCurrentlyDeleting) {
diff --git a/superset/databases/api.py b/superset/databases/api.py
index 91290bc..b347503 100644
--- a/superset/databases/api.py
+++ b/superset/databases/api.py
@@ -689,10 +689,18 @@ class DatabaseRestApi(BaseSupersetModelRestApi):
}
for dashboard in data["dashboards"]
]
+ sqllab_tab_states = [
+ {"id": tab_state.id, "label": tab_state.label, "active": tab_state.active}
+ for tab_state in data["sqllab_tab_states"]
+ ]
return self.response(
200,
charts={"count": len(charts), "result": charts},
dashboards={"count": len(dashboards), "result": dashboards},
+ sqllab_tab_states={
+ "count": len(sqllab_tab_states),
+ "result": sqllab_tab_states,
+ },
)
@expose("/export/", methods=["GET"])
diff --git a/superset/databases/dao.py b/superset/databases/dao.py
index e24cdcd..4f0452e 100644
--- a/superset/databases/dao.py
+++ b/superset/databases/dao.py
@@ -23,6 +23,7 @@ from superset.extensions import db
from superset.models.core import Database
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice
+from superset.models.sql_lab import Query, SavedQuery, TableSchema, TabState
logger = logging.getLogger(__name__)
@@ -87,4 +88,11 @@ class DatabaseDAO(BaseDAO):
.distinct()
.all()
)
- return dict(charts=charts, dashboards=dashboards)
+
+ sqllab_tab_states = (
+ db.session.query(TabState).filter(TabState.database_id == database_id).all()
+ )
+
+ return dict(
+ charts=charts, dashboards=dashboards, sqllab_tab_states=sqllab_tab_states
+ )