mirror of
https://github.com/sqlchat/sqlchat.git
synced 2025-09-25 17:15:19 +08:00
fix: edit connection state
This commit is contained in:
@ -3,7 +3,7 @@ import { ChangeEvent, useEffect, useState } from "react";
|
|||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import TextareaAutosize from "react-textarea-autosize";
|
import TextareaAutosize from "react-textarea-autosize";
|
||||||
import { useConnectionStore } from "@/store";
|
import { useConnectionStore } from "@/store";
|
||||||
import { Connection, Engine, ResponseObject } from "@/types";
|
import { Connection, Engine, ResponseObject, SSLOptions } from "@/types";
|
||||||
import Select from "./kit/Select";
|
import Select from "./kit/Select";
|
||||||
import TextField from "./kit/TextField";
|
import TextField from "./kit/TextField";
|
||||||
import Modal from "./kit/Modal";
|
import Modal from "./kit/Modal";
|
||||||
@ -66,16 +66,11 @@ const CreateConnectionModal = (props: Props) => {
|
|||||||
} else {
|
} else {
|
||||||
setSSLType("ca-only");
|
setSSLType("ca-only");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setSSLType("none");
|
|
||||||
}
|
}
|
||||||
setSelectedSSLField("ca");
|
|
||||||
setIsRequesting(false);
|
|
||||||
setShowDeleteConnectionModal(false);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let ssl = undefined;
|
let ssl: SSLOptions | undefined = undefined;
|
||||||
if (sslType === "ca-only") {
|
if (sslType === "ca-only") {
|
||||||
ssl = {
|
ssl = {
|
||||||
ca: "",
|
ca: "",
|
||||||
@ -87,10 +82,10 @@ const CreateConnectionModal = (props: Props) => {
|
|||||||
key: "",
|
key: "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
setConnection({
|
setConnection((connection) => ({
|
||||||
...connection,
|
...connection,
|
||||||
ssl,
|
ssl: ssl,
|
||||||
});
|
}));
|
||||||
setSelectedSSLField("ca");
|
setSelectedSSLField("ca");
|
||||||
}, [sslType]);
|
}, [sslType]);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ export enum Engine {
|
|||||||
PostgreSQL = "POSTGRESQL",
|
PostgreSQL = "POSTGRESQL",
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SSLOptions {
|
export interface SSLOptions {
|
||||||
ca?: string;
|
ca?: string;
|
||||||
cert?: string;
|
cert?: string;
|
||||||
key?: string;
|
key?: string;
|
||||||
|
Reference in New Issue
Block a user