Skip to content

Commit

Permalink
feat: Allow users to connect via legacy SQLA form (apache#16201)
Browse files Browse the repository at this point in the history
* hugh/dbui-other

* remove extra condition

* add not callable

* Update .pylintrc

Co-authored-by: Beto Dealmeida <[email protected]>

Co-authored-by: Beto Dealmeida <[email protected]>
  • Loading branch information
2 people authored and Emmanuel Bavoux committed Nov 14, 2021
1 parent 01e6228 commit 00ae1c9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ disable=
too-few-public-methods,
too-many-locals,


[REPORTS]

# Set the output format. Available formats are text, parseable, colorized, msvs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
setDB({
type: ActionType.dbSelected,
payload: {
database_name,
configuration_method: isDynamic
? CONFIGURATION_METHOD.DYNAMIC_FORM
: CONFIGURATION_METHOD.SQLALCHEMY_URI,
engine,
},
});
}

setDB({ type: ActionType.addTableCatalogSheet });
};

Expand All @@ -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
Expand Down

0 comments on commit 00ae1c9

Please sign in to comment.