Skip to content

Commit 6763434

Browse files
committed
add dolt in import connection string
1 parent 860893f commit 6763434

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

src/database/add-connection-dropdown.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function ConnectionDropdownItem({
3939
}
4040

4141
export default function AddConnectionDropdown() {
42+
const navigate = useNavigate();
43+
4244
return (
4345
<Popover>
4446
<PopoverTrigger asChild>
@@ -78,7 +80,12 @@ export default function AddConnectionDropdown() {
7880
</div>
7981
</div>
8082
<div className="flex flex-1 border-t p-2">
81-
<button className="flex flex-1 items-center justify-start rounded-lg p-2 text-left text-sm font-semibold hover:bg-secondary">
83+
<button
84+
className="flex flex-1 items-center justify-start rounded-lg p-2 text-left text-sm font-semibold hover:bg-secondary"
85+
onClick={() => {
86+
navigate("/connection/import");
87+
}}
88+
>
8289
<LucidePlus className="mr-2 h-4 w-4" />
8390
Import Connection String
8491
</button>

src/database/import-connection-string.tsx

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import { Button } from "@/components/ui/button";
33
import { Textarea } from "@/components/ui/textarea";
44
import { useToast } from "@/hooks/use-toast";
55
import { ConnectionStoreItemConfig } from "@/lib/conn-manager-store";
6+
import { DoltIcon, MySQLIcon } from "@/lib/outerbase-icon";
7+
import { cn } from "@/lib/utils";
68
import { useCallback, useState } from "react";
79
import { useNavigate } from "react-router-dom";
810

911
export default function ImportConnectionStringRoute() {
1012
const { toast } = useToast();
1113
const navigate = useNavigate();
1214
const [connectionString, setConnectionString] = useState("");
15+
const [mysqlConnectionType, setMySQLConnectionType] = useState("mysql");
1316

1417
const onImportClick = useCallback(() => {
1518
let url = new URL(connectionString);
@@ -30,7 +33,7 @@ export default function ImportConnectionStringRoute() {
3033

3134
if (protocol === "mysql") {
3235
console.log("Importing MySQL connection string");
33-
navigate("/connection/create/mysql", {
36+
navigate(`/connection/create/${mysqlConnectionType}`, {
3437
replace: true,
3538
state: {
3639
host: url.hostname,
@@ -56,7 +59,9 @@ export default function ImportConnectionStringRoute() {
5659
} as ConnectionStoreItemConfig,
5760
});
5861
}
59-
}, [connectionString, navigate, toast]);
62+
}, [connectionString, navigate, toast, mysqlConnectionType]);
63+
64+
const isMySQL = connectionString.trim().startsWith("mysql://");
6065

6166
return (
6267
<div>
@@ -68,6 +73,8 @@ export default function ImportConnectionStringRoute() {
6873
<div className="flex flex-col gap-4 p-4">
6974
<Textarea
7075
rows={5}
76+
autoFocus
77+
spellCheck={false}
7178
className="resize-none p-4 font-mono"
7279
placeholder="Connection String. Eg: mysql://root:123456@localhost:3306/database_name"
7380
value={connectionString}
@@ -76,7 +83,40 @@ export default function ImportConnectionStringRoute() {
7683
}}
7784
/>
7885

79-
<div>
86+
{isMySQL && (
87+
<div className="flex gap-2">
88+
<button
89+
className={cn(
90+
"flex items-center gap-2 rounded border-2 p-2 px-4 text-sm font-semibold",
91+
mysqlConnectionType === "mysql"
92+
? "border-blue-500 bg-blue-200"
93+
: "",
94+
)}
95+
onClick={() => {
96+
setMySQLConnectionType("mysql");
97+
}}
98+
>
99+
<MySQLIcon className="h-6 w-6" />
100+
<span>MySQL</span>
101+
</button>
102+
<button
103+
className={cn(
104+
"flex items-center gap-2 rounded border-2 p-2 px-4 text-sm font-semibold",
105+
mysqlConnectionType === "dolt"
106+
? "border-green-500 bg-green-200"
107+
: "hover:border-green-500",
108+
)}
109+
onClick={() => {
110+
setMySQLConnectionType("dolt");
111+
}}
112+
>
113+
<DoltIcon className="h-6 w-6" />
114+
<span>Dolt</span>
115+
</button>
116+
</div>
117+
)}
118+
119+
<div className="mt-4">
80120
<Button onClick={onImportClick}>Import</Button>
81121
</div>
82122
</div>

0 commit comments

Comments
 (0)