diff --git a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx index 27104a66..fe2a2468 100644 --- a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx @@ -1,7 +1,7 @@ import React, {useEffect, useState} from 'react'; -import type {Application, RepositoryGroup, RepositoryProject} from '../types'; +import type {Application, RepositoryProject} from '../types'; import {DevelopmentLanguageTypeEnum} from '../types'; -import {createApplication, updateApplication, getRepositoryGroupList, getRepositoryProjects} from '../service'; +import {createApplication, updateApplication, getRepositoryProjectsBySystem} from '../service'; import type {ExternalSystemResponse} from '@/pages/Deploy/External/types'; import {SystemType} from '@/pages/Deploy/External/types'; import {getExternalSystems} from '@/pages/Deploy/External/service'; @@ -63,7 +63,6 @@ const ApplicationModal: React.FC = ({ }) => { const [categories, setCategories] = useState([]); const [externalSystems, setExternalSystems] = useState([]); - const [repositoryGroups, setRepositoryGroups] = useState([]); const [repositoryProjects, setRepositoryProjects] = useState([]); const {toast} = useToast(); const isEdit = !!initialValues?.id; @@ -79,7 +78,6 @@ const ApplicationModal: React.FC = ({ enabled: true, sort: 0, externalSystemId: undefined, - repoGroupId: undefined, repoProjectId: undefined, }, }); @@ -136,41 +134,28 @@ const ApplicationModal: React.FC = ({ enabled: initialValues.enabled, sort: initialValues.sort, externalSystemId: initialValues.externalSystemId, - repoGroupId: initialValues.repoGroupId, repoProjectId: initialValues.repoProjectId }); - // 如果有外部系统ID,加载仓库组 + // 如果有外部系统ID,加载仓库项目 if (initialValues.externalSystemId) { - fetchRepositoryGroups(initialValues.externalSystemId); - } - - // 如果有仓库组ID,加载仓库项目 - if (initialValues.repoGroupId) { - fetchRepositoryProjects(initialValues.repoGroupId); + fetchRepositoryProjects(initialValues.externalSystemId); } } }, [initialValues]); - // 当选择外部系统时,获取对应的仓库组列表 + // 当选择外部系统时,获取对应的仓库项目列表 const handleExternalSystemChange = (externalSystemId: number | undefined) => { - form.setValue('repoGroupId', undefined); form.setValue('repoProjectId', undefined); setRepositoryProjects([]); if (externalSystemId) { - fetchRepositoryGroups(externalSystemId); + fetchRepositoryProjects(externalSystemId); } }; - const fetchRepositoryGroups = async (externalSystemId: number | undefined) => { + const fetchRepositoryProjects = async (externalSystemId: number | undefined) => { if (!externalSystemId) return; - const response = await getRepositoryGroupList(externalSystemId); - setRepositoryGroups(response || []); - }; - - const fetchRepositoryProjects = async (repoGroupId: number | undefined) => { - if (!repoGroupId) return; - const response = await getRepositoryProjects(repoGroupId); + const response = await getRepositoryProjectsBySystem(externalSystemId); setRepositoryProjects(response || []); }; @@ -352,106 +337,6 @@ const ApplicationModal: React.FC = ({ )} /> - { - const [searchValue, setSearchValue] = React.useState(""); - const [open, setOpen] = React.useState(false); - const filteredGroups = repositoryGroups.filter(group => - group.name.toLowerCase().includes(searchValue.toLowerCase()) - ); - - return ( - - 代码仓库组 - - - - - - - -
- - setSearchValue(e.target.value)} - /> -
-
- -
- {filteredGroups.length === 0 ? ( -
- 未找到代码仓库组 -
- ) : ( - filteredGroups.map((group) => ( -
{ - const groupId = group.repoGroupId; - form.setValue("repoGroupId", groupId); - form.setValue("repoProjectId", undefined as any); - setRepositoryProjects([]); - fetchRepositoryProjects(groupId); - setSearchValue(""); - setOpen(false); - }} - onWheel={(e) => { - const scrollArea = e.currentTarget.closest('[data-radix-scroll-area-viewport]'); - if (scrollArea) { - scrollArea.scrollTop += e.deltaY; - } - }} - > -
- {group.fullName} - - {group.fullPath} - -
- {group.repoGroupId === field.value && ( - - )} -
- )) - )} -
-
-
-
-
- -
- ); - }} - /> - = ({ @@ -511,7 +396,7 @@ const ApplicationModal: React.FC = ({ key={project.repoProjectId} className={cn( "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-accent hover:text-accent-foreground", - project.id === field.value && "bg-accent text-accent-foreground" + project.repoProjectId === field.value && "bg-accent text-accent-foreground" )} onClick={() => { form.setValue("repoProjectId", project.repoProjectId); diff --git a/frontend/src/pages/Deploy/Application/List/index.tsx b/frontend/src/pages/Deploy/Application/List/index.tsx index 363fa37e..034f6df1 100644 --- a/frontend/src/pages/Deploy/Application/List/index.tsx +++ b/frontend/src/pages/Deploy/Application/List/index.tsx @@ -207,7 +207,7 @@ const ApplicationList: React.FC = () => { size: 120, cell: ({ row }) => (
- {row.original.category?.name || '-'} + {row.original.applicationCategory?.name || '-'}
), }, diff --git a/frontend/src/pages/Deploy/Application/List/schema.ts b/frontend/src/pages/Deploy/Application/List/schema.ts index 7a7a5f7f..e3b3bca9 100644 --- a/frontend/src/pages/Deploy/Application/List/schema.ts +++ b/frontend/src/pages/Deploy/Application/List/schema.ts @@ -17,7 +17,6 @@ export const applicationFormSchema = z.object({ invalid_type_error: '应用分类必须是数字', }), externalSystemId: z.number().optional(), - repoGroupId: z.number().optional(), repoProjectId: z.number().optional(), language: z.nativeEnum(DevelopmentLanguageTypeEnum, { required_error: "请选择开发语言", diff --git a/frontend/src/pages/Deploy/Application/List/service.ts b/frontend/src/pages/Deploy/Application/List/service.ts index 01d4838f..a58d6472 100644 --- a/frontend/src/pages/Deploy/Application/List/service.ts +++ b/frontend/src/pages/Deploy/Application/List/service.ts @@ -45,8 +45,14 @@ export const getRepositoryGroupList = (externalSystemId: number) => params: { externalSystemId }, }); -// 获取项目列表 +// 获取项目列表(根据仓库组) export const getRepositoryProjects = (repoGroupId: number) => request.get(`${REPOSITORY_PROJECT_URL}/list`, { params: { repoGroupId: repoGroupId }, }); + +// 获取项目列表(根据外部系统) +export const getRepositoryProjectsBySystem = (externalSystemId: number) => + request.get(`${REPOSITORY_PROJECT_URL}/list`, { + params: { externalSystemId }, + }); diff --git a/frontend/src/pages/Deploy/Application/List/types.ts b/frontend/src/pages/Deploy/Application/List/types.ts index f30dfecc..1fd7eefd 100644 --- a/frontend/src/pages/Deploy/Application/List/types.ts +++ b/frontend/src/pages/Deploy/Application/List/types.ts @@ -19,11 +19,9 @@ export interface Application extends BaseResponse { sort: number; teamCount?: number; applicationCategoryId: number; - category?: ApplicationCategoryResponse; + applicationCategory?: ApplicationCategoryResponse; externalSystemId?: number; externalSystem?: ExternalSystemResponse; - repoGroupId?: number; - repositoryGroup?: RepositoryGroup; repoProjectId?: number; repositoryProject?: RepositoryProject; }