From 171514360e8ba821b2343706e74c9a537b76047c Mon Sep 17 00:00:00 2001 From: "Hugh A. Miles II" Date: Thu, 12 Aug 2021 15:10:42 -0400 Subject: [PATCH] feat: Allow users to connect via legacy SQLA form (#16201) * hugh/dbui-other * remove extra condition * add not callable * Update .pylintrc Co-authored-by: Beto Dealmeida Co-authored-by: Beto Dealmeida --- .pylintrc | 1 - .../data/database/DatabaseModal/index.tsx | 47 +++++++++++++------ 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.pylintrc b/.pylintrc index b624dfbc5a..59c215e30d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -91,7 +91,6 @@ disable= too-few-public-methods, too-many-locals, - [REPORTS] # Set the output format. Available formats are text, parseable, colorized, msvs diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index 54c9702659..80a73a6f80 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -656,21 +656,34 @@ const DatabaseModal: FunctionComponent = ({ }; const setDatabaseModel = (database_name: string) => { - const selectedDbModel = availableDbs?.databases.filter( - (db: DatabaseObject) => db.name === database_name, - )[0]; - const { engine, parameters } = selectedDbModel; - const isDynamic = parameters !== undefined; - setDB({ - type: ActionType.dbSelected, - payload: { - database_name, - configuration_method: isDynamic - ? CONFIGURATION_METHOD.DYNAMIC_FORM - : CONFIGURATION_METHOD.SQLALCHEMY_URI, - engine, - }, - }); + if (database_name === 'Other') { + // Allow users to connect to DB via legacy SQLA form + setDB({ + type: ActionType.dbSelected, + payload: { + database_name, + configuration_method: CONFIGURATION_METHOD.SQLALCHEMY_URI, + engine: undefined, + }, + }); + } else { + const selectedDbModel = availableDbs?.databases.filter( + (db: DatabaseObject) => db.name === database_name, + )[0]; + const { engine, parameters } = selectedDbModel; + const isDynamic = parameters !== undefined; + setDB({ + type: ActionType.dbSelected, + payload: { + database_name, + configuration_method: isDynamic + ? CONFIGURATION_METHOD.DYNAMIC_FORM + : CONFIGURATION_METHOD.SQLALCHEMY_URI, + engine, + }, + }); + } + setDB({ type: ActionType.addTableCatalogSheet }); }; @@ -694,6 +707,10 @@ const DatabaseModal: FunctionComponent = ({ {database.name} ))} + {/* Allow users to connect to DB via legacy SQLA form */} + + Other +