@@ -3,13 +3,16 @@ import { Button } from "@/components/ui/button";
33import { Textarea } from "@/components/ui/textarea" ;
44import { useToast } from "@/hooks/use-toast" ;
55import { ConnectionStoreItemConfig } from "@/lib/conn-manager-store" ;
6+ import { DoltIcon , MySQLIcon } from "@/lib/outerbase-icon" ;
7+ import { cn } from "@/lib/utils" ;
68import { useCallback , useState } from "react" ;
79import { useNavigate } from "react-router-dom" ;
810
911export 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