重构前端逻辑

This commit is contained in:
dengqichen 2025-11-10 11:09:06 +08:00
parent d0f2e78ee7
commit ec7b0aa67c
4 changed files with 47 additions and 10 deletions

View File

@ -366,9 +366,23 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
)} )}
> >
{field.value {field.value
? repositoryProjects.find( ? (() => {
(project) => project.repoProjectId === field.value const project = repositoryProjects.find(
)?.name (p) => p.repoProjectId === field.value
);
if (!project) return '';
// 如果有组别名称,显示组别/项目名
if (project.repoGroupName) {
return (
<>
<span className="text-muted-foreground">{project.repoGroupName}/</span>
{project.name}
</>
);
}
return project.name;
})()
: !form.watch('externalSystemId') : !form.watch('externalSystemId')
? "请先选择Gitlab" ? "请先选择Gitlab"
: "请选择项目"} : "请选择项目"}
@ -413,9 +427,18 @@ const ApplicationModal: React.FC<ApplicationModalProps> = ({
} }
}} }}
> >
{project.name} <div className="flex-1 truncate">
{project.repoGroupName ? (
<>
<span className="text-muted-foreground">{project.repoGroupName}/</span>
{project.name}
</>
) : (
project.name
)}
</div>
{project.repoProjectId === field.value && ( {project.repoProjectId === field.value && (
<Check className="ml-auto h-4 w-4" /> <Check className="ml-auto h-4 w-4 flex-shrink-0" />
)} )}
</div> </div>
)) ))

View File

@ -54,7 +54,9 @@ export interface RepositoryProject extends BaseResponse {
externalSystemId: number; externalSystemId: number;
projectId: number; projectId: number;
repoGroupId: number; repoGroupId: number;
repoGroupName?: string; // 组别名称
repoProjectId: number; repoProjectId: number;
branchCount?: number;
} }
export type CreateApplicationRequest = Omit<Application, 'id' | keyof BaseResponse>; export type CreateApplicationRequest = Omit<Application, 'id' | keyof BaseResponse>;

View File

@ -7,6 +7,7 @@ import {
DialogContent, DialogContent,
DialogHeader, DialogHeader,
DialogTitle, DialogTitle,
DialogDescription,
DialogFooter, DialogFooter,
DialogBody, DialogBody,
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
@ -313,6 +314,11 @@ export const TeamEnvironmentConfigDialog: React.FC<
<DialogTitle> <DialogTitle>
{editEnvironmentId ? '编辑环境配置' : '配置环境'} {editEnvironmentId ? '编辑环境配置' : '配置环境'}
</DialogTitle> </DialogTitle>
<DialogDescription>
{editEnvironmentId
? '修改环境的审批流程、通知设置等配置信息'
: '为环境配置审批流程、通知设置等信息'}
</DialogDescription>
</DialogHeader> </DialogHeader>
{loading ? ( {loading ? (
@ -408,11 +414,13 @@ export const TeamEnvironmentConfigDialog: React.FC<
className="mr-1" className="mr-1"
> >
{user.realName || user.username} {user.realName || user.username}
<button <span
type="button" role="button"
className="ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2" tabIndex={0}
className="ml-1 cursor-pointer ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 hover:bg-muted"
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === "Enter") { if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
field.onChange(field.value?.filter(id => id !== user.id) || []); field.onChange(field.value?.filter(id => id !== user.id) || []);
} }
}} }}
@ -426,7 +434,7 @@ export const TeamEnvironmentConfigDialog: React.FC<
}} }}
> >
<X className="h-3 w-3 text-muted-foreground hover:text-foreground" /> <X className="h-3 w-3 text-muted-foreground hover:text-foreground" />
</button> </span>
</Badge> </Badge>
))} ))}
</div> </div>

View File

@ -4,6 +4,7 @@ import {
DialogContent, DialogContent,
DialogHeader, DialogHeader,
DialogTitle, DialogTitle,
DialogDescription,
DialogBody, DialogBody,
DialogFooter, DialogFooter,
} from '@/components/ui/dialog'; } from '@/components/ui/dialog';
@ -143,6 +144,9 @@ export const TeamEnvironmentManageDialog: React.FC<
<DialogContent className="max-w-6xl max-h-[90vh]"> <DialogContent className="max-w-6xl max-h-[90vh]">
<DialogHeader> <DialogHeader>
<DialogTitle> - {teamName}</DialogTitle> <DialogTitle> - {teamName}</DialogTitle>
<DialogDescription>
</DialogDescription>
</DialogHeader> </DialogHeader>
<DialogBody className="overflow-y-auto"> <DialogBody className="overflow-y-auto">