From 69ed03416c8af21bfa4542b3ec970abf2bdc8017 Mon Sep 17 00:00:00 2001 From: shanhexi Date: Wed, 13 Dec 2023 11:50:26 +0800 Subject: [PATCH] fix:FileUploadModal --- .../src/blocks/CreateConnection/index.tsx | 106 +++++++++++------- .../src/components/ImportConnection/index.tsx | 2 +- chat2db-client/src/i18n/en-us/connection.ts | 1 + chat2db-client/src/i18n/zh-cn/connection.ts | 1 + .../src/pages/main/connection/index.tsx | 15 --- 5 files changed, 71 insertions(+), 54 deletions(-) diff --git a/chat2db-client/src/blocks/CreateConnection/index.tsx b/chat2db-client/src/blocks/CreateConnection/index.tsx index b49b58fa..ea5e846d 100644 --- a/chat2db-client/src/blocks/CreateConnection/index.tsx +++ b/chat2db-client/src/blocks/CreateConnection/index.tsx @@ -5,6 +5,9 @@ import { IConnectionDetails, IDatabase } from '@/typings'; import ConnectionEdit from '@/components/ConnectionEdit'; import { databaseTypeList } from '@/constants'; import Iconfont from '@/components/Iconfont'; +import i18n from '@/i18n'; +import FileUploadModal from '@/components/ImportConnection'; +import {getConnectionList} from '@/pages/main/store/connection'; // IConnectionDetails 全部信息代表修改 // null 展示因增列表 @@ -23,6 +26,8 @@ export default memo((props) => { const [connectionDetail, setConnectionDetail] = useState( externalConnectionDetail, ); + const [isFileUploadModalOpen, setIsFileUploadModalOpen] = useState(false); + useEffect(() => { setConnectionDetail(externalConnectionDetail); @@ -39,49 +44,74 @@ export default memo((props) => { // } return ( -
- {connectionDetail && ( -
- { - setConnectionDetail(null); - }} - connectionData={connectionDetail as any} - submit={onSubmit} - /> -
- )} - {connectionDetail === null && ( -
-
- {databaseTypeList.map((t) => { - return ( -
-
-
-
- + <> +
+ {connectionDetail && ( +
+ { + setConnectionDetail(null); + }} + connectionData={connectionDetail as any} + submit={onSubmit} + /> +
+ )} + {connectionDetail === null && ( +
+
+ {databaseTypeList.map((t) => { + return ( +
+
+
+
+ +
+ {t.name} +
+
+
- {t.name} -
-
-
+ ); + })} +
{setIsFileUploadModalOpen(true)}}> +
+
+
+ +
+ {i18n('connection.title.importConnection')} +
+
+ +
- ); - })} - {Array.from({ length: 20 }).map((t, index) => { - return
; - })} +
+ {Array.from({ length: 20 }).map((t, index) => { + return
; + })} +
-
- )} -
+ )} +
+ { + setIsFileUploadModalOpen(false); + }} + onConfirm={() => { + setIsFileUploadModalOpen(false); + getConnectionList() + }} + /> + ); }); diff --git a/chat2db-client/src/components/ImportConnection/index.tsx b/chat2db-client/src/components/ImportConnection/index.tsx index 34d273e2..851c7173 100644 --- a/chat2db-client/src/components/ImportConnection/index.tsx +++ b/chat2db-client/src/components/ImportConnection/index.tsx @@ -67,7 +67,7 @@ const ImportConnection: React.FC = ({ open, onClose, onC return ( { }); const volatileRef = useRef(); const [connectionActiveId, setConnectionActiveId] = useState(null); - const [isFileUploadModalOpen, setIsFileUploadModalOpen] = useState(false); const [connectionDetail, setConnectionDetail] = useState(null); // 处理列表单击事件 @@ -174,20 +172,7 @@ const ConnectionsPage = () => { > - {/*
- -
*/}
- - { - setIsFileUploadModalOpen(false); - }} - onConfirm={() => { - setIsFileUploadModalOpen(false); - }} - /> ); };