From fbf8d4b09adb932d2ccff8f3440e68fe21ef9b6c Mon Sep 17 00:00:00 2001 From: riahk Date: Mon, 14 Dec 2020 16:17:28 -0800 Subject: [PATCH] reset active tab on open --- .../views/CRUD/data/database/DatabaseModal.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index b8f061c1b9ccb..9f14afe7bbd8e 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -39,6 +39,8 @@ interface DatabaseModalProps { database?: DatabaseObject | null; // If included, will go into edit mode } +const DEFAULT_TAB_KEY = '1'; + const StyledIcon = styled(Icon)` margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0; `; @@ -129,6 +131,7 @@ const DatabaseModal: FunctionComponent = ({ const [disableSave, setDisableSave] = useState(true); const [db, setDB] = useState(null); const [isHidden, setIsHidden] = useState(true); + const [tabKey, setTabKey] = useState(DEFAULT_TAB_KEY); const isEditMode = database !== null; const defaultExtra = @@ -291,12 +294,14 @@ const DatabaseModal: FunctionComponent = ({ ) { if (database && database.id !== null && !dbLoading) { const id = database.id || 0; + setTabKey(DEFAULT_TAB_KEY); fetchResource(id).then(() => { setDB(dbFetched); }); } } else if (!isEditMode && (!db || db.id || (isHidden && show))) { + setTabKey(DEFAULT_TAB_KEY); setDB({ database_name: '', sqlalchemy_uri: '', @@ -313,6 +318,10 @@ const DatabaseModal: FunctionComponent = ({ setIsHidden(false); } + const tabChange = (key: string) => { + setTabKey(key); + }; + return ( = ({ } > - +