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-few-public-methods,
too-many-locals, too-many-locals,
[REPORTS] [REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs # 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 setDatabaseModel = (database_name: string) => {
const selectedDbModel = availableDbs?.databases.filter( if (database_name === 'Other') {
(db: DatabaseObject) => db.name === database_name, // Allow users to connect to DB via legacy SQLA form
)[0]; setDB({
const { engine, parameters } = selectedDbModel; type: ActionType.dbSelected,
const isDynamic = parameters !== undefined; payload: {
setDB({ database_name,
type: ActionType.dbSelected, configuration_method: CONFIGURATION_METHOD.SQLALCHEMY_URI,
payload: { engine: undefined,
database_name, },
configuration_method: isDynamic });
? CONFIGURATION_METHOD.DYNAMIC_FORM } else {
: CONFIGURATION_METHOD.SQLALCHEMY_URI, const selectedDbModel = availableDbs?.databases.filter(
engine, (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 }); setDB({ type: ActionType.addTableCatalogSheet });
}; };
@ -694,6 +707,10 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
{database.name} {database.name}
</Select.Option> </Select.Option>
))} ))}
{/* Allow users to connect to DB via legacy SQLA form */}
<Select.Option value="Other" key="Other">
Other
</Select.Option>
</Select> </Select>
<Alert <Alert
showIcon showIcon