diff --git a/superset-frontend/src/components/IconButton/index.tsx b/superset-frontend/src/components/IconButton/index.tsx index e7f9c2d89d52..fb10b77a4a2a 100644 --- a/superset-frontend/src/components/IconButton/index.tsx +++ b/superset-frontend/src/components/IconButton/index.tsx @@ -32,6 +32,7 @@ const StyledButton = styled(Button)` display: flex; flex-direction: column; padding: 0; + width: 33%; `; const StyledImage = styled.div` margin: ${({ theme }) => theme.gridUnit * 8}px 0; @@ -76,8 +77,6 @@ const StyledInner = styled.div` `; const StyledBottom = styled.div` - padding: ${({ theme }) => theme.gridUnit * 6}px - ${({ theme }) => theme.gridUnit * 4}px; border-radius: 0 0 ${({ theme }) => theme.borderRadius}px ${({ theme }) => theme.borderRadius}px; background-color: ${({ theme }) => theme.colors.grayscale.light4}; diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx index 659a9bca30da..6f6cc709c8d8 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/DatabaseConnectionForm.tsx @@ -198,6 +198,7 @@ const DatabaseConnectionForm = ({ }) => ( <> +

Step 2 of 3

Enter the required {name} credentials

Need help? Learn more about connecting to {name}. 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 ee8367b87cb9..38140c5426fb 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, @@ -61,6 +62,7 @@ import { formStyles, StyledBasicTab, SelectDatabaseStyles, + StyledFormHeader, } from './styles'; const DOCUMENTATION_LINK = @@ -290,6 +292,76 @@ const DatabaseModal: FunctionComponent = ({ } }; + const setDatabaseModel = engine => { + const isDynamic = + availableDbs?.databases.filter(db => db.engine === engine)[0] + .parameters !== undefined; + setDB({ + type: ActionType.dbSelected, + payload: { + configuration_method: isDynamic + ? CONFIGURATION_METHOD.DYNAMIC_FORM + : CONFIGURATION_METHOD.SQLALCHEMY_URI, + engine, + }, + }); + }; + + const renderAvailableSelector = () => ( +

+ + Or choose from a list of other databases we support{' '} + + + +
+ ); + + const renderPreferredSelector = () => ( +
+ {availableDbs?.databases + ?.filter(db => db.preferred) + .map(database => ( + setDatabaseModel(database.engine)} + buttonText={database.name} + /> + ))} +
+ ); + + const renderModalFooter = () => + db // if db show back + connect + ? [ + , + !hasConnectedDb ? ( // if hasConnectedDb show back + finish + + ) : ( + + ), + ] + : []; + useEffect(() => { if (show) { setTabKey(DEFAULT_TAB_KEY); @@ -359,15 +431,18 @@ const DatabaseModal: FunctionComponent = ({ title={

{isEditMode ? t('Edit database') : t('Connect a database')}

} + footer={renderModalFooter()} > - {isEditMode ? ( + {isEditMode && ( {db?.backend} {dbName} - ) : ( - // TODO: Fix headers when we get rid of tabs + )} + {/* Show Legacy Header */} + {useSqlAlchemyForm && ( +

Step 2 of 2

Enter Primary Credentials Need help? Learn how to connect your database{' '} @@ -382,6 +457,7 @@ const DatabaseModal: FunctionComponent = ({
)} + {/* Add styled header here when not in edit mode */}
= ({ width="500px" show={show} title={

{t('Connect a database')}

} + footer={renderModalFooter()} > {hasConnectedDb ? ( = ({ /> ) : ( <> - - onChange(ActionType.parametersChange, { - type: target.type, - name: target.name, - checked: target.checked, - value: target.value, - }) - } - onChange={({ target }: { target: HTMLInputElement }) => - onChange(ActionType.textChange, { - name: target.name, - value: target.value, - }) - } - getValidation={() => getValidation(db)} - validationErrors={validationErrors} - /> + {/* Step 1 */} {!isLoading && !db && ( - - - + Connect this database with a SQLAlchemy URI string instead + + {/* Step 2 */} + )} - )} 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 abecfb6daec3..e1a77890ad39 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/styles.ts @@ -42,6 +42,15 @@ export const StyledFormHeader = styled.header` font-weight: bold; font-size: ${({ theme }) => theme.typography.sizes.l}px; } + + .select-db { + .helper { + margin-top: 0; + } + h4 { + margin: 0 0 29px; + } + } `; export const antdCollapseStyles = (theme: SupersetTheme) => css` @@ -312,6 +321,12 @@ export const TabHeader = styled.div` padding: 0px; margin: 0 ${({ theme }) => theme.gridUnit * 4}px ${({ theme }) => theme.gridUnit * 8}px; + + .helper { + color: ${({ theme }) => theme.colors.grayscale.base}; + font-size: ${({ theme }) => theme.typography.sizes.s - 1}px; + margin: 0px; + } `; export const CreateHeaderTitle = styled.div` @@ -339,5 +354,30 @@ export const EditHeaderSubtitle = styled.div` `; export const SelectDatabaseStyles = styled.div` - margin: ${({ theme }) => theme.gridUnit * 4}px; + margin: 0 ${({ theme }) => theme.gridUnit * 8}px; + + .preferred { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + margin-bottom: ${({ theme }) => theme.gridUnit * 16}px; + } + + .preferred-item { + width: 133px; + height: 133px; + } + + .available { + .available-label { + font-weight: bold; + margin-top: ${({ theme }) => theme.gridUnit * 16}px; + margin-bottom: ${({ theme }) => theme.gridUnit * 8}px; + } + } + + .label-available-select { + text-transform: uppercase; + font-size: ${({ theme }) => theme.typography.sizes.s - 1}px; + } `; diff --git a/superset/config.py b/superset/config.py index a6427b528d77..435b5b259da2 100644 --- a/superset/config.py +++ b/superset/config.py @@ -1075,10 +1075,10 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC( # 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. ]