From 931665f6e1df1d66b6c11f56ea0cb0d9383917a6 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 10 Jan 2025 15:04:20 +0800 Subject: [PATCH] 1 --- .../List/components/ApplicationModal.tsx | 79 ++++++------------- .../pages/Deploy/Application/List/schema.ts | 5 +- 2 files changed, 25 insertions(+), 59 deletions(-) diff --git a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx index 607debc9..4943d1e7 100644 --- a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx @@ -69,13 +69,13 @@ const ApplicationModal: React.FC = ({ appCode: "", appName: "", appDesc: "", - repoUrl: "", - language: undefined, + language: DevelopmentLanguageTypeEnum.JAVA, enabled: true, sort: 0, gitInstanceId: undefined, - repositoryGroupId: undefined, - repositoryProjectId: undefined, + repoGroupId: undefined, + repoProjectId: undefined, + projectGroupId: undefined, }, }); @@ -109,13 +109,13 @@ const ApplicationModal: React.FC = ({ appCode: initialValues.appCode, appName: initialValues.appName, appDesc: initialValues.appDesc || "", - repoUrl: initialValues.repoUrl, language: initialValues.language, enabled: initialValues.enabled, sort: initialValues.sort, gitInstanceId: initialValues.gitInstanceId, - repositoryGroupId: initialValues.repositoryGroupId, - repositoryProjectId: initialValues.repositoryProjectId, + repoGroupId: initialValues.repoGroupId, + repoProjectId: initialValues.repoProjectId, + projectGroupId: initialValues.projectGroupId, }); const gitInstance = gitInstances.find(instance => instance.id === initialValues.gitInstanceId); if (gitInstance) { @@ -126,8 +126,8 @@ const ApplicationModal: React.FC = ({ // 当选择Git实例时,获取对应的仓库组列表 const handleGitInstanceChange = (gitInstanceId: number) => { - form.setValue('repositoryGroupId', undefined); - form.setValue('repositoryProjectId', undefined); + form.setValue('repoGroupId', undefined); + form.setValue('repoProjectId', undefined); setRepositoryProjects([]); fetchRepositoryGroups(gitInstanceId); }; @@ -147,34 +147,20 @@ const ApplicationModal: React.FC = ({ if (isEdit) { await updateApplication({ ...values, - id: initialValues.id, - projectGroupId, + id: initialValues!.id, }); } else { - await createApplication({ - ...values, - projectGroupId, - }); + await createApplication(values); } - toast({ - title: `${isEdit ? '更新' : '创建'}成功`, - duration: 3000, - }); - form.reset(); - onSuccess(); - } catch (error) { - toast({ - variant: "destructive", - title: `${isEdit ? '更新' : '创建'}失败`, - description: error instanceof Error ? error.message : undefined, - duration: 3000, - }); + onSuccess?.(); + } catch (e) { + console.error(e); } }; return ( !open && onCancel()}> - + {isEdit ? '编辑' : '新建'}应用 @@ -281,7 +267,7 @@ const ApplicationModal: React.FC = ({ { const [searchValue, setSearchValue] = React.useState(""); const [open, setOpen] = React.useState(false); @@ -341,8 +327,8 @@ const ApplicationModal: React.FC = ({ group.id === field.value && "bg-accent text-accent-foreground" )} onClick={() => { - form.setValue("repositoryGroupId", group.id); - form.setValue("repositoryProjectId", undefined); + form.setValue("repoGroupId", group.id); + form.setValue("repoProjectId", undefined); setRepositoryProjects([]); fetchRepositoryProjects(group.id); setSearchValue(""); @@ -380,7 +366,7 @@ const ApplicationModal: React.FC = ({ { const [searchValue, setSearchValue] = React.useState(""); const [open, setOpen] = React.useState(false); @@ -397,7 +383,7 @@ const ApplicationModal: React.FC = ({