mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-07-28 17:53:21 +08:00
chore: update create connection handler
This commit is contained in:
@ -50,19 +50,28 @@ const CreateConnectionModal = (props: Props) => {
|
|||||||
if (!showDatabaseField) {
|
if (!showDatabaseField) {
|
||||||
connectionCreate.database = undefined;
|
connectionCreate.database = undefined;
|
||||||
}
|
}
|
||||||
const result = await testConnection(connectionCreate);
|
try {
|
||||||
setIsRequesting(false);
|
const result = await testConnection(connectionCreate);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
toast.error("Failed to connect");
|
setIsRequesting(false);
|
||||||
|
toast.error("Failed to test connection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const createdConnection = connectionStore.createConnection(connectionCreate);
|
||||||
|
// Set the created connection as the current connection.
|
||||||
|
const databaseList = await connectionStore.getOrFetchDatabaseList(createdConnection);
|
||||||
|
connectionStore.setCurrentConnectionCtx({
|
||||||
|
connection: createdConnection,
|
||||||
|
database: head(databaseList),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
setIsRequesting(false);
|
||||||
|
toast.error("Failed to create connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const createdConnection = connectionStore.createConnection(connectionCreate);
|
|
||||||
// Set the created connection as the current connection.
|
setIsRequesting(false);
|
||||||
const databaseList = await connectionStore.getOrFetchDatabaseList(createdConnection);
|
|
||||||
connectionStore.setCurrentConnectionCtx({
|
|
||||||
connection: createdConnection,
|
|
||||||
database: head(databaseList),
|
|
||||||
});
|
|
||||||
close();
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user