@@ -5,7 +5,10 @@ use leptos_icons::*;
55use leptos_toaster:: { Toast , ToastId , ToastVariant , Toasts } ;
66
77use super :: { driver:: Pgsql , schema:: Schema } ;
8- use crate :: store:: { projects:: ProjectsStore , tabs:: TabsStore } ;
8+ use crate :: {
9+ modals:: add_pgsql_connection:: AddPgsqlConnection ,
10+ store:: { projects:: ProjectsStore , tabs:: TabsStore } ,
11+ } ;
912use common:: enums:: ProjectConnectionStatus ;
1013
1114#[ component]
@@ -14,29 +17,18 @@ pub fn Pgsql(project_id: String) -> impl IntoView {
1417 let tabs_store = expect_context :: < TabsStore > ( ) ;
1518 let projects_store = expect_context :: < ProjectsStore > ( ) ;
1619 let project_details = projects_store. select_project_by_name ( & project_id) . unwrap ( ) ;
17- let connection_params = project_details
18- . split ( ':' )
19- . map ( String :: from)
20- . collect :: < Vec < String > > ( ) ;
21- let connection_params = connection_params
22- . into_iter ( )
23- . skip ( 1 )
24- . map ( |s| {
25- let kv = s. split ( '=' ) . collect :: < Vec < & str > > ( ) ;
26- kv[ 1 ] . to_owned ( )
27- } )
28- . collect :: < Vec < String > > ( ) ;
29- let connection_params = Box :: leak ( connection_params. into_boxed_slice ( ) ) ;
20+ let project_details = Box :: leak ( Box :: new ( project_details) ) ;
3021 // [user, password, host, port]
3122 let mut pgsql = Pgsql :: new ( project_id. clone ( ) . to_string ( ) ) ;
3223 {
3324 pgsql. load_connection_details (
34- & connection_params [ 0 ] ,
35- & connection_params [ 1 ] ,
36- & connection_params [ 2 ] ,
37- & connection_params [ 3 ] ,
25+ & project_details [ 1 ] ,
26+ & project_details [ 2 ] ,
27+ & project_details [ 3 ] ,
28+ & project_details [ 4 ] ,
3829 ) ;
3930 }
31+ let show = create_rw_signal ( false ) ;
4032 let toast_context = expect_context :: < Toasts > ( ) ;
4133 let create_toast = move |variant : ToastVariant , title : String | {
4234 let toast_id = ToastId :: new ( ) ;
@@ -80,6 +72,7 @@ pub fn Pgsql(project_id: String) -> impl IntoView {
8072
8173 view ! {
8274 <Provider value=pgsql>
75+ <AddPgsqlConnection show=show/>
8376 <div class="pl-1 text-xs" >
8477 <div class="flex flex-row justify-between items-center" >
8578 <button
@@ -131,6 +124,16 @@ pub fn Pgsql(project_id: String) -> impl IntoView {
131124
132125 <Icon icon=icondata:: HiCircleStackOutlineLg width="12" height="12" />
133126 </button>
127+ <button
128+ class="p-1 rounded-full hover:bg-gray-200"
129+ on: click=move |_| {
130+ pgsql. edit_connection_details( ) ;
131+ show. set( true ) ;
132+ }
133+ >
134+
135+ <Icon icon=icondata:: HiPencilSquareOutlineLg width="12" height="12" />
136+ </button>
134137 <button
135138 class="p-1 rounded-full hover:bg-gray-200"
136139 on: click={
0 commit comments