@@ -23,6 +23,9 @@ import useClickAndDoubleClick from '@/hooks/useClickAndDoubleClick';
2323
2424// ----- store -----
2525import { useConnectionStore , getConnectionList } from '@/pages/main/store/connection' ;
26+ import { setMainPageActiveTab } from '@/pages/main/store/main' ;
27+ import { setCurrentConnectionDetails } from '@/pages/main/workspace/store/common' ;
28+
2629
2730import styles from './index.less' ;
2831
@@ -35,18 +38,19 @@ const ConnectionsPage = () => {
3538 const volatileRef = useRef < any > ( ) ;
3639 const [ connectionActiveId , setConnectionActiveId ] = useState < IConnectionListItem [ 'id' ] | null > ( null ) ;
3740 const [ isFileUploadModalOpen , setIsFileUploadModalOpen ] = useState ( false ) ;
38- const [ connectionDetail , setConnectionDetail ] = useState < IConnectionDetails | null > ( null ) ;
41+ const [ connectionDetail , setConnectionDetail ] = useState < IConnectionDetails | null | undefined > ( null ) ;
3942
4043 // 处理列表单击事件
4144 const handleMenuItemSingleClick = ( t : IConnectionListItem ) => {
4245 if ( connectionActiveId !== t . id ) {
4346 setConnectionActiveId ( t . id ) ;
4447 }
45- }
48+ } ;
4649
4750 // 处理列表双击事件
4851 const handleMenuItemDoubleClick = ( t : IConnectionListItem ) => {
49- setConnectionActiveId ( t . id ) ;
52+ setCurrentConnectionDetails ( t ) ;
53+ setMainPageActiveTab ( 'workspace' )
5054 } ;
5155
5256 // 处理列表单击和双击事件
@@ -57,7 +61,7 @@ const ConnectionsPage = () => {
5761 if ( ! connectionActiveId ) {
5862 return ;
5963 }
60- setConnectionDetail ( null ) ;
64+ setConnectionDetail ( undefined ) ;
6165 connectionService
6266 . getDetails ( { id : connectionActiveId } )
6367 . then ( ( res ) => {
@@ -68,8 +72,8 @@ const ConnectionsPage = () => {
6872 } ) ;
6973 } , [ connectionActiveId ] ) ;
7074
71- //
72- const createDropdownItems = ( t ) => {
75+ //
76+ const createDropdownItems = ( t ) => {
7377 const handelDelete = ( e ) => {
7478 // 禁止冒泡到menuItem
7579 e . domEvent ?. stopPropagation ?.( ) ;
@@ -79,12 +83,12 @@ const ConnectionsPage = () => {
7983 setConnectionActiveId ( null ) ;
8084 }
8185 } ) ;
82- }
86+ } ;
8387
8488 const enterWorkSpace = ( e ) => {
8589 e . domEvent ?. stopPropagation ?.( ) ;
8690 handleMenuItemDoubleClick ( t ) ;
87- }
91+ } ;
8892
8993 return [
9094 {
@@ -95,11 +99,11 @@ const ConnectionsPage = () => {
9599 {
96100 key : 'delete' ,
97101 label : < MenuLabel icon = "" label = { i18n ( 'connection.button.remove' ) } /> ,
98- onClick : handelDelete
102+ onClick : handelDelete ,
99103 } ,
100- ]
101- }
102-
104+ ] ;
105+ } ;
106+
103107 const renderConnectionMenuList = ( ) => {
104108 return connectionList ?. map ( ( t ) => {
105109 return (
@@ -114,7 +118,9 @@ const ConnectionsPage = () => {
114118 className = { classnames ( styles . menuItem , {
115119 [ styles . menuItemActive ] : connectionActiveId === t . id ,
116120 } ) }
117- onClick = { ( ) => { handleClickConnectionMenu ( t ) } }
121+ onClick = { ( ) => {
122+ handleClickConnectionMenu ( t ) ;
123+ } }
118124 >
119125 < div className = { classnames ( styles . menuItemsTitle ) } >
120126 < span className = { styles . envTag } style = { { background : t . environment . color . toLocaleLowerCase ( ) } } />
@@ -133,13 +139,15 @@ const ConnectionsPage = () => {
133139 } ;
134140
135141 const onSubmit = ( data ) => {
136- connectionService . save ( {
137- ...data ,
138- } ) . then ( ( res ) => {
139- getConnectionList ( ) ;
140- setConnectionActiveId ( res ) ;
141- } ) ;
142- }
142+ return connectionService
143+ . save ( {
144+ ...data ,
145+ } )
146+ . then ( ( res ) => {
147+ getConnectionList ( ) ;
148+ setConnectionActiveId ( res ) ;
149+ } ) ;
150+ } ;
143151
144152 return (
145153 < >
@@ -160,9 +168,15 @@ const ConnectionsPage = () => {
160168 </ Button >
161169 ) }
162170 </ div >
163- < LoadingContent className = { styles . layoutRight } isLoading = { ! connectionDetail && ! ! connectionActiveId } >
171+ < LoadingContent
172+ className = { styles . layoutRight }
173+ isLoading = { connectionDetail === undefined && ! ! connectionActiveId }
174+ >
164175 < CreateConnection connectionDetail = { connectionDetail } onSubmit = { onSubmit } />
165176 </ LoadingContent >
177+ { /* <div className={styles.layoutRight}>
178+ <CreateConnection connectionDetail={connectionDetail} onSubmit={onSubmit} />
179+ </div> */ }
166180 </ div >
167181
168182 < FileUploadModal
0 commit comments