Skip to content

Commit

Permalink
fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Nov 4, 2021
1 parent 81dc533 commit bd3bf6e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const CONFIRM_OVERWRITE_MESSAGE = t(
interface DatabaseDeleteObject extends DatabaseObject {
chart_count: number;
dashboard_count: number;
sqllab_tab_state: number;
sqllab_tab_count: number;
}
interface DatabaseListProps {
addDangerToast: (msg: string) => void;
Expand Down Expand Up @@ -123,7 +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,
sqllab_tab_count: json.sqllab_tab_states.count,
});
})
.catch(
Expand Down Expand Up @@ -439,11 +439,11 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
{databaseCurrentlyDeleting && (
<DeleteModal
description={t(
'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.',
'The database %s is linked to %s charts that appear on %s dashboards and 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,
databaseCurrentlyDeleting.sqllab_tab_count,
)}
onConfirm={() => {
if (databaseCurrentlyDeleting) {
Expand Down
2 changes: 1 addition & 1 deletion superset/databases/dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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
from superset.models.sql_lab import TabState

logger = logging.getLogger(__name__)

Expand Down
26 changes: 26 additions & 0 deletions tests/integration_tests/databases/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,3 +1989,29 @@ def test_validate_parameters_invalid_port_range(self, is_hostname_valid):
},
]
}

def test_get_related_objects(self):
username = "admin"
self.login(username)
example_db = get_example_database()

# Create a tab
data = {
"queryEditor": json.dumps(
{
"title": "Untitled Query 1",
"dbId": example_db.id,
"schema": None,
"autorun": False,
"sql": "SELECT ...",
"queryLimit": 1000,
}
)
}
self.get_json_resp("/tabstateview/", data=data)

self.login(username="admin")
uri = f"api/v1/database/{example_db.id}/related_objects/"
rv = self.client.get(uri)
assert rv.status_code == 200
assert rv.json["sqllab_tab_states"]["count"] == 1

0 comments on commit bd3bf6e

Please sign in to comment.