feat: implement setting modal

This commit is contained in:
steven
2023-03-24 15:58:08 +08:00
parent f2c4e33be4
commit 0218a9c065
8 changed files with 164 additions and 22 deletions

View File

@ -1,4 +1,4 @@
import { cloneDeep } from "lodash-es";
import { cloneDeep, head } from "lodash-es";
import { useState } from "react";
import { toast } from "react-hot-toast";
import { testConnection, useConnectionStore } from "@/store";
@ -41,7 +41,14 @@ const CreateConnectionModal = (props: Props) => {
toast.error("Failed to connect");
return;
}
connectionStore.createConnection(connectionCreate);
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),
});
close();
};
return (