eschutho commented on a change in pull request #14951:
URL: https://github.com/apache/superset/pull/14951#discussion_r645083843



##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -299,6 +301,73 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
     }
   };
 
+  const setDatabaseModel = option => {

Review comment:
       can the param be "engine" if it's just a string? Maybe a type on that 
would help, too.

##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -299,6 +301,73 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
     }
   };
 
+  const setDatabaseModel = option => {
+    const isDynamic =
+      availableDbs?.databases.filter(db => db.engine === option)[0]
+        .parameters !== undefined;
+    setDB({
+      type: ActionType.dbSelected,
+      payload: {
+        configuration_method: isDynamic
+          ? CONFIGURATION_METHOD.DYNAMIC_FORM
+          : CONFIGURATION_METHOD.SQLALCHEMY_URI,
+        engine: option,
+      },
+    });
+    console.log('isDynamic', isDynamic);

Review comment:
       nit remove

##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -299,6 +301,73 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
     }
   };
 
+  const setDatabaseModel = option => {
+    const isDynamic =
+      availableDbs?.databases.filter(db => db.engine === option)[0]
+        .parameters !== undefined;
+    setDB({
+      type: ActionType.dbSelected,
+      payload: {
+        configuration_method: isDynamic
+          ? CONFIGURATION_METHOD.DYNAMIC_FORM
+          : CONFIGURATION_METHOD.SQLALCHEMY_URI,
+        engine: option,
+      },
+    });
+    console.log('isDynamic', isDynamic);
+  };
+
+  const renderAvailableSelector = () => (

Review comment:
       can we move step one into a separate file?

##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -299,6 +301,73 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
     }
   };
 
+  const setDatabaseModel = option => {
+    const isDynamic =
+      availableDbs?.databases.filter(db => db.engine === option)[0]
+        .parameters !== undefined;
+    setDB({
+      type: ActionType.dbSelected,
+      payload: {
+        configuration_method: isDynamic
+          ? CONFIGURATION_METHOD.DYNAMIC_FORM
+          : CONFIGURATION_METHOD.SQLALCHEMY_URI,
+        engine: option,
+      },
+    });
+    console.log('isDynamic', isDynamic);
+  };
+
+  const renderAvailableSelector = () => (
+    <div className="available">
+      <span className="available-label">
+        Or choose from a list of other databases we support{' '}
+      </span>
+      <label className="label-available-select">supported databases</label>
+      <Select style={{ width: '100%' }} onChange={setDatabaseModel}>
+        {availableDbs?.databases?.map(database => (
+          <Select.Option value={database.engine} key={database.engine}>
+            {database.name}
+          </Select.Option>
+        ))}
+      </Select>
+    </div>
+  );
+
+  const renderPreferredSelector = () => (
+    <div className="preferred">
+      {availableDbs?.databases
+        ?.filter(db => db.preferred)
+        .map(database => (
+          <IconButton
+            className="preferred-item"
+            onClick={() => setDatabaseModel(database.engine)}
+            buttonText={database.name}
+          />
+        ))}
+    </div>
+  );
+
+  const renderModalFooter = () =>
+    db // if db show back + connect
+      ? [

Review comment:
       db && (
   <>
   
   would that work instead?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to