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

hugh pushed a commit to branch pexdax/db-connection-ui-show-preferred
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 96a87d80004b2a8480eb8314ffdfc8ee23b7dd5b
Author: hughhhh <[email protected]>
AuthorDate: Tue Jun 1 18:16:13 2021 -0400

    saving for now
---
 .../CRUD/data/database/DatabaseModal/index.tsx     | 25 +++++++++++++++++++++-
 .../CRUD/data/database/DatabaseModal/styles.ts     |  4 +++-
 superset/config.py                                 |  8 +++----
 3 files changed, 31 insertions(+), 6 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 e73ea12..e992e67 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
@@ -28,6 +28,7 @@ import Tabs from 'src/components/Tabs';
 import { Alert, Select } from 'src/common/components';
 import Modal from 'src/components/Modal';
 import Button from 'src/components/Button';
+import IconButton from 'src/components/IconButton';
 import withToasts from 'src/messageToasts/enhancers/withToasts';
 import {
   testDatabaseConnection,
@@ -120,7 +121,7 @@ type DBReducerActionType =
   | {
       type: ActionType.configMethodChange;
       payload: { configuration_method: CONFIGURATION_METHOD };
-    }
+    };
 
 function dbReducer(
   state: Partial<DatabaseObject> | null,
@@ -524,8 +525,29 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
             getValidation={() => getValidation(db)}
             validationErrors={validationErrors}
           />
+          {/* Step 1 */}
           {!isLoading && !db && (
             <SelectDatabaseStyles>
+              <div className="preferred">
+                {availableDbs?.databases
+                  ?.filter(db => db.preferred)
+                  .map(database => (
+                    <IconButton
+                      value={database.engine}
+                      onClick={e => {
+                        console.log(e.target.value);
+                        setDB({
+                          type: ActionType.dbSelected,
+                          payload: {
+                            configuration_method: 
CONFIGURATION_METHOD.DYNAMIC_FORM,
+                            engine: e.target.value,
+                          },
+                        });
+                      }}
+                      buttonText={database.name}
+                    />
+                  ))}
+              </div>
               <label className="label-select">
                 What database would you like to connect?
               </label>
@@ -549,6 +571,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> 
= ({
               </Select>
             </SelectDatabaseStyles>
           )}
+          {/* Step 1 */}
           <Button
             buttonStyle="link"
             onClick={() =>
diff --git 
a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts 
b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts
index 20a86ba..63dedab 100644
--- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts
+++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts
@@ -340,5 +340,7 @@ export const EditHeaderSubtitle = styled.div`
 `;
 
 export const SelectDatabaseStyles = styled.div`
-  margin: ${({ theme }) => theme.gridUnit * 4}px;
+  .preferred {
+    display: flex;
+  }
 `;
diff --git a/superset/config.py b/superset/config.py
index 2bbb249..969dedf 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -1072,10 +1072,10 @@ SQL_VALIDATORS_BY_ENGINE = {
 # use the "engine_name" attribute of the corresponding DB engine spec
 # in `superset/db_engine_specs/`.
 PREFERRED_DATABASES: List[str] = [
-    # "PostgreSQL",
-    # "Presto",
-    # "MySQL",
-    # "SQLite",
+    "PostgreSQL",
+    "Presto",
+    "MySQL",
+    "SQLite",
     # etc.
 ]
 

Reply via email to