feat: Allow users to connect via legacy SQLA form (#16201)

* hugh/dbui-other

* remove extra condition

* add not callable

* Update .pylintrc

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>

Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
Hugh A. Miles II 2021-08-12 15:10:42 -04:00 committed by GitHub
parent 67c4c0116e
commit 171514360e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 16 deletions

View File

@ -91,7 +91,6 @@ disable=
too-few-public-methods,
too-many-locals,
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs

View File

@ -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 });
};
@ -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