From cc0e33802b51221a09c18ab59d639d06623fee22 Mon Sep 17 00:00:00 2001 From: shanhexi Date: Sun, 9 Jul 2023 15:19:12 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:driver=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=AC=AC=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Driver/index.tsx | 18 ++++++++++++------ .../CreateConnection/config/dataSource.ts | 3 ++- .../CreateConnection/config/types.ts | 2 ++ .../src/components/CreateConnection/index.tsx | 4 +++- chat2db-client/src/utils/localStorage.ts | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/chat2db-client/src/components/CreateConnection/components/Driver/index.tsx b/chat2db-client/src/components/CreateConnection/components/Driver/index.tsx index cceef6d2..fb91152a 100644 --- a/chat2db-client/src/components/CreateConnection/components/Driver/index.tsx +++ b/chat2db-client/src/components/CreateConnection/components/Driver/index.tsx @@ -25,7 +25,7 @@ enum DownloadStatus { export default memo(function Driver(props) { const { className, backfillData, onChange } = props; const [downloadStatus, setDownloadStatus] = useState(); - const [driveForm] = Form.useForm(); + const [driverForm] = Form.useForm(); const [driverObj, setDriverObj] = useState(); const [uploadDriverModal, setUploadDriverModal] = useState(false); const [driverSaved, setDriverSaved] = useState({}); @@ -38,7 +38,7 @@ export default memo(function Driver(props) { useEffect(() => { if (backfillData) { - driveForm.setFieldsValue({ + driverForm.setFieldsValue({ jdbcDriverClass: backfillData?.driverConfig?.jdbcDriverClass, jdbcDriver: backfillData?.driverConfig?.jdbcDriver }) @@ -48,6 +48,12 @@ export default memo(function Driver(props) { function getDriverList() { connectionService.getDriverList({ dbType: backfillData.type }).then(res => { setDriverObj(res) + if (res.driverConfigList?.length) { + driverForm.setFieldsValue({ + jdbcDriverClass: res.driverConfigList[0].jdbcDriverClass, + jdbcDriver: res.driverConfigList[0].jdbcDriver + }) + } }) } @@ -65,7 +71,7 @@ export default memo(function Driver(props) { function downloadDrive() { setDownloadStatus(DownloadStatus.Loading) connectionService.downloadDriver({ dbType: backfillData.type }).then(res => { - // setDownloadStatus(DownloadStatus.Success) + setDownloadStatus(DownloadStatus.Success); getDriverList(); }).catch(() => { setDownloadStatus(DownloadStatus.Error) @@ -74,7 +80,7 @@ export default memo(function Driver(props) { function onValuesChange(data: any) { const selected = driverObj?.driverConfigList.find(t => t.jdbcDriver === data.jdbcDriver); - driveForm.setFieldsValue({ + driverForm.setFieldsValue({ jdbcDriverClass: selected?.jdbcDriverClass }); onChange({ @@ -85,7 +91,7 @@ export default memo(function Driver(props) { return
@@ -124,7 +130,7 @@ export default memo(function Driver(props) { (downloadStatus === DownloadStatus.Success) &&
{i18n('connection.text.downloadSuccess')}
} -
:
+ :
}
React.ReactNode } = { @@ -417,7 +418,7 @@ function RenderForm(props: IRenderFormProps) { style={{ '--form-label-width': labelWidth } as any} labelAlign={labelAlign} > - + ), @@ -429,6 +430,7 @@ function RenderForm(props: IRenderFormProps) { labelAlign={labelAlign} >