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/08/11 18:33:15 UTC

[superset] 01/01: hugh/dbui-other

This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hugh/dbui-other
in repository https://gitbox.apache.org/repos/asf/superset.git

commit cd653effe102e748c3225fcc5453bf08cfa578c4
Author: hughhhh <hu...@gmail.com>
AuthorDate: Wed Aug 11 14:27:05 2021 -0400

    hugh/dbui-other
---
 .../CRUD/data/database/DatabaseModal/index.tsx     | 47 +++++++++++++++-------
 1 file changed, 32 insertions(+), 15 deletions(-)

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 54c9702..131f907 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<DatabaseModalProps> = ({
   };
 
   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 || database_name === 'Other';
+      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<DatabaseModalProps> = ({
               {database.name}
             </Select.Option>
           ))}
+        {/* Allow users to connect to DB via legacy SQLA form */}
+        <Select.Option value="Other" key="Other">
+          Other
+        </Select.Option>
       </Select>
       <Alert
         showIcon