重构前端逻辑

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
? repositoryProjects.find(
(project) => project.repoProjectId === field.value
)?.name
? (() => {
const project = repositoryProjects.find(
(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')
? "请先选择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 && (
<Check className="ml-auto h-4 w-4" />
<Check className="ml-auto h-4 w-4 flex-shrink-0" />
)}
</div>
))

View File

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

View File

@ -7,6 +7,7 @@ import {
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
DialogBody,
} from '@/components/ui/dialog';
@ -313,6 +314,11 @@ export const TeamEnvironmentConfigDialog: React.FC<
<DialogTitle>
{editEnvironmentId ? '编辑环境配置' : '配置环境'}
</DialogTitle>
<DialogDescription>
{editEnvironmentId
? '修改环境的审批流程、通知设置等配置信息'
: '为环境配置审批流程、通知设置等信息'}
</DialogDescription>
</DialogHeader>
{loading ? (
@ -408,11 +414,13 @@ export const TeamEnvironmentConfigDialog: React.FC<
className="mr-1"
>
{user.realName || user.username}
<button
type="button"
className="ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
<span
role="button"
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) => {
if (e.key === "Enter") {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
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" />
</button>
</span>
</Badge>
))}
</div>

View File

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