From ba1486e6f1292cb214dcd396b9b8558a4957560b Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Mon, 9 Oct 2023 10:30:16 +0800 Subject: [PATCH] [fix]: Fix missing Promise return causing button not disabled during request --- .../SqlAuditRecord/Create/SQLInfoForm.tsx | 10 ++++++---- src/page/SqlAuditRecord/Create/index.tsx | 19 ++++++++++++------- src/page/SqlAuditRecord/Create/index.type.ts | 6 +++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx b/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx index d10d6404..67a74266 100644 --- a/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx +++ b/src/page/SqlAuditRecord/Create/SQLInfoForm.tsx @@ -171,7 +171,7 @@ const SQLInfoForm: React.ForwardRefRenderFunction< }; } else if (type === UploadTypeEnum.git) { return { - name: 'git_http_url', + name: 'gitHttpUrl', label: t('sqlAudit.create.SQLInfo.uploadLabelEnum.gitUrl'), rules: [{ required: uploadType === UploadTypeEnum.git }], tooltip: t('sqlAudit.create.SQLInfo.uploadLabelEnum.gitUrlTips'), @@ -193,7 +193,9 @@ const SQLInfoForm: React.ForwardRefRenderFunction< 'sqlFile', 'mybatisFile', 'zipFile', - 'gitRepository', + 'gitHttpUrl', + 'gitUserName', + 'gitUserPassword', ]); }; @@ -427,7 +429,7 @@ const SQLInfoForm: React.ForwardRefRenderFunction< - + - + { instance_name: values.instanceName, instance_schema: values.instanceSchema, db_type: values.dbType, - git_http_url: values.git_http_url, - git_user_name: values.git_user_name, - git_user_password: values.git_user_password, + git_http_url: values.gitHttpUrl, + git_user_name: values.gitUserName, + git_user_password: values.gitUserPassword, }; - sql_audit_record.CreateSQLAuditRecordV1(params).then((res) => { - if (res.data.code === ResponseCode.SUCCESS) { - res.data.data && updateTags(res.data.data, baseValues); + return sql_audit_record.CreateSQLAuditRecordV1(params).then((res) => { + if (res.data.code === ResponseCode.SUCCESS && res.data.data) { + if ((baseValues.tags?.length ?? 0) > 0) { + return updateTags(res.data.data, baseValues); + } else { + setTask(res.data.data.task); + message.success(t('sqlAudit.create.SQLInfo.successTips')); + } } }); }; @@ -60,7 +65,7 @@ const SQLAuditCreate: React.FC = () => { record: ISQLAuditRecordResData, values: BaseInfoFormFields ) => { - sql_audit_record + return sql_audit_record .updateSQLAuditRecordV1({ tags: values.tags, sql_audit_record_id: record.sql_audit_record_id ?? '', diff --git a/src/page/SqlAuditRecord/Create/index.type.ts b/src/page/SqlAuditRecord/Create/index.type.ts index 8dd5be63..b65781cf 100644 --- a/src/page/SqlAuditRecord/Create/index.type.ts +++ b/src/page/SqlAuditRecord/Create/index.type.ts @@ -27,9 +27,9 @@ export type SQLInfoFormFields = { instanceName: string; instanceSchema: string; dbType: string; - git_http_url: string; - git_user_name: string; - git_user_password: string; + gitHttpUrl: string; + gitUserName: string; + gitUserPassword: string; }; export type SQLInfoFormProps = {