This commit is contained in:
dengqichen 2025-01-13 15:59:11 +08:00
parent c705e0eef7
commit 52bc47cc2d
3 changed files with 13 additions and 12 deletions

View File

@ -144,8 +144,8 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
setRepositoryGroups(response || []);
};
const fetchRepositoryProjects = async (groupId: number) => {
const response = await getRepositoryProjects(groupId);
const fetchRepositoryProjects = async (repoGroupId: number) => {
const response = await getRepositoryProjects(repoGroupId);
setRepositoryProjects(response || []);
};
@ -320,7 +320,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
>
{field.value
? repositoryGroups.find(
(group) => group.id === field.value
(group) => group.repoGroupId === field.value
)?.fullName || "请选择代码仓库组"
: !form.watch('externalSystemId')
? "请先选择外部系统"
@ -349,16 +349,16 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
) : (
filteredGroups.map((group) => (
<div
key={group.id}
key={group.repoGroupId}
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",
group.id === field.value && "bg-accent text-accent-foreground"
group.repoGroupId === field.value && "bg-accent text-accent-foreground"
)}
onClick={() => {
form.setValue("repoGroupId", group.id);
form.setValue("repoGroupId", group.repoGroupId);
form.setValue("repoProjectId", undefined);
setRepositoryProjects([]);
fetchRepositoryProjects(group.id);
fetchRepositoryProjects(group.repoGroupId);
setSearchValue("");
setOpen(false);
}}
@ -375,7 +375,7 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
{group.fullPath}
</span>
</div>
{group.id === field.value && (
{group.repoGroupId === field.value && (
<Check className="ml-auto h-4 w-4" />
)}
</div>

View File

@ -46,7 +46,7 @@ export const getRepositoryGroupList = (externalSystemId: number) =>
});
// 获取项目列表
export const getRepositoryProjects = (groupId: number) =>
export const getRepositoryProjects = (repoGroupId: number) =>
request.get<RepositoryProject[]>(`${REPOSITORY_PROJECT_URL}/list`, {
params: { groupId },
params: { repoGroupId: repoGroupId },
});

View File

@ -30,7 +30,7 @@ export interface Application extends BaseResponse {
export interface RepositoryGroup extends BaseResponse {
name: string;
description?: string;
groupId: number;
repoGroupId: number;
parentId?: number;
path: string;
fullName: string;
@ -48,7 +48,6 @@ export interface RepositoryProject extends BaseResponse {
path: string;
description: string;
visibility: string;
groupId: number;
isDefaultBranch: string;
webUrl: string;
sshUrl: string;
@ -56,6 +55,8 @@ export interface RepositoryProject extends BaseResponse {
lastActivityAt: string;
externalSystemId: number;
projectId: number;
repoGroupId: number;
repoProjectId: number;
}
export type CreateApplicationRequest = Omit<Application, 'id' | keyof BaseResponse>;