增加GIT代码检测节点

This commit is contained in:
dengqichen 2025-12-04 17:39:04 +08:00
parent e03671c5de
commit 6b83597d47
5 changed files with 94 additions and 70 deletions

View File

@ -54,6 +54,18 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
jobName: app.deployJob || '', jobName: app.deployJob || '',
branch: app.branch || 'master', branch: app.branch || 'master',
} : undefined, } : undefined,
// 🆕 源Git仓库配置
sourceRepository: app.sourceGitSystemId ? {
systemId: app.sourceGitSystemId,
projectId: app.sourceGitProjectId,
branch: app.sourceBranch || '',
} : undefined,
// 🆕 目标Git仓库配置
targetRepository: app.targetGitSystemId ? {
systemId: app.targetGitSystemId,
projectId: app.targetGitProjectId,
branch: app.targetBranch || '',
} : undefined,
// 团队信息 // 团队信息
teamId: teamId?.toString() || '', teamId: teamId?.toString() || '',
// 应用信息 // 应用信息

View File

@ -59,6 +59,18 @@ export interface ApplicationConfig {
workflowDefinitionFormId?: number; // 🆕 工作流表单ID workflowDefinitionFormId?: number; // 🆕 工作流表单ID
workflowDefinitionName?: string; workflowDefinitionName?: string;
workflowDefinitionKey?: string; workflowDefinitionKey?: string;
// 🆕 源Git配置
sourceGitSystemId?: number;
sourceGitSystemName?: string;
sourceGitProjectId?: number;
sourceGitProjectName?: string;
sourceBranch?: string;
// 🆕 目标Git配置
targetGitSystemId?: number;
targetGitSystemName?: string;
targetGitProjectId?: number;
targetGitProjectName?: string;
targetBranch?: string;
deployStatistics?: DeployStatistics; deployStatistics?: DeployStatistics;
isDeploying?: boolean; isDeploying?: boolean;
recentDeployRecords?: DeployRecord[]; recentDeployRecords?: DeployRecord[];

View File

@ -51,12 +51,12 @@ interface TeamApplicationDialogProps {
id?: number; id?: number;
appId: number; appId: number;
buildType: BuildType | null; buildType: BuildType | null;
branch: string; sourceBranch: string;
deploySystemId: number | null; deploySystemId: number | null;
deployJob: string; deployJob: string;
workflowDefinitionId: number | null; workflowDefinitionId: number | null;
codeSourceSystemId: number | null; sourceGitSystemId: number | null;
codeSourceProjectId: number | null; sourceGitProjectId: number | null;
targetGitSystemId: number | null; // 🆕 目标Git系统ID targetGitSystemId: number | null; // 🆕 目标Git系统ID
targetGitProjectId: number | null; // 🆕 目标Git项目ID targetGitProjectId: number | null; // 🆕 目标Git项目ID
targetBranch: string; // 🆕 目标分支 targetBranch: string; // 🆕 目标分支
@ -86,17 +86,17 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
// 表单状态 // 表单状态
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
appId: null as number | null, appId: 0,
buildType: 'JENKINS' as BuildType | null, buildType: 'JENKINS' as 'JENKINS' | 'NATIVE' | null,
branch: '', sourceBranch: '', // 源分支名称
deploySystemId: null as number | null, deploySystemId: null as number | null,
deployJob: '', deployJob: '',
workflowDefinitionId: null as number | null, workflowDefinitionId: null as number | null,
codeSourceSystemId: null as number | null, // 源代码系统ID sourceGitSystemId: null as number | null, // 源Git系统ID
codeSourceProjectId: null as number | null, // 源仓库项目ID sourceGitProjectId: null as number | null, // 源Git项目ID
targetGitSystemId: null as number | null, // 🆕 目标Git系统ID targetGitSystemId: null as number | null, // 目标Git系统ID
targetGitProjectId: null as number | null, // 🆕 目标Git项目ID targetGitProjectId: null as number | null, // 目标Git项目ID
targetBranch: '', // 🆕 目标分支 targetBranch: '', // 目标分支名称
}); });
// 加载状态 // 加载状态
@ -128,26 +128,26 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
setFormData({ setFormData({
appId: application.applicationId, appId: application.applicationId,
buildType: application.buildType || 'JENKINS', buildType: application.buildType || 'JENKINS',
branch: application.branch || '', sourceBranch: application.sourceBranch || '',
deploySystemId: application.deploySystemId || null, deploySystemId: application.deploySystemId || null,
deployJob: application.deployJob || '', deployJob: application.deployJob || '',
workflowDefinitionId: application.workflowDefinitionId || null, workflowDefinitionId: application.workflowDefinitionId || null,
codeSourceSystemId: application.codeSourceSystemId || null, sourceGitSystemId: application.sourceGitSystemId || null,
codeSourceProjectId: application.codeSourceProjectId || null, sourceGitProjectId: application.sourceGitProjectId || null,
targetGitSystemId: application.targetGitSystemId || null, targetGitSystemId: application.targetGitSystemId || null,
targetGitProjectId: application.targetGitProjectId || null, targetGitProjectId: application.targetGitProjectId || null,
targetBranch: application.targetBranch || '', targetBranch: application.targetBranch || '',
}); });
// 加载源仓库项目 // 加载源仓库项目
if (application.codeSourceSystemId) { if (application.sourceGitSystemId) {
loadRepoProjects(application.codeSourceSystemId); loadRepoProjects(application.sourceGitSystemId);
} }
// 加载源分支(优先使用代码源信息,向后兼容旧数据) // 加载源分支(优先使用代码源信息,向后兼容旧数据)
if (application.codeSourceSystemId && application.codeSourceProjectId) { if (application.sourceGitSystemId && application.sourceGitProjectId) {
// 使用代码源信息加载分支 // 使用代码源信息加载分支
loadBranchesFromCodeSource(application.codeSourceSystemId, application.codeSourceProjectId); loadBranchesFromCodeSource(application.sourceGitSystemId, application.sourceGitProjectId);
} else { } else {
// 向后兼容:使用应用信息加载分支 // 向后兼容:使用应用信息加载分支
const app = applications.find(a => a.id === application.applicationId); const app = applications.find(a => a.id === application.applicationId);
@ -175,12 +175,12 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
setFormData({ setFormData({
appId: null, appId: null,
buildType: 'JENKINS', buildType: 'JENKINS',
branch: '', sourceBranch: '',
deploySystemId: null, deploySystemId: null,
deployJob: '', deployJob: '',
workflowDefinitionId: null, workflowDefinitionId: null,
codeSourceSystemId: null, sourceGitSystemId: null,
codeSourceProjectId: null, sourceGitProjectId: null,
targetGitSystemId: null, targetGitSystemId: null,
targetGitProjectId: null, targetGitProjectId: null,
targetBranch: '', targetBranch: '',
@ -270,12 +270,12 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
setFormData({ setFormData({
appId: appId, appId: appId,
buildType: formData.buildType, buildType: formData.buildType,
branch: '', sourceBranch: '',
deploySystemId: null, deploySystemId: null,
deployJob: '', deployJob: '',
workflowDefinitionId: null, workflowDefinitionId: null,
codeSourceSystemId: null, sourceGitSystemId: null,
codeSourceProjectId: null, sourceGitProjectId: null,
targetGitSystemId: null, targetGitSystemId: null,
targetGitProjectId: null, targetGitProjectId: null,
targetBranch: '', targetBranch: '',
@ -338,9 +338,9 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
const handleCodeSourceSystemChange = (systemId: number) => { const handleCodeSourceSystemChange = (systemId: number) => {
setFormData({ setFormData({
...formData, ...formData,
codeSourceSystemId: systemId, sourceGitSystemId: systemId,
codeSourceProjectId: null, sourceGitProjectId: null,
branch: '', // 清空分支 sourceBranch: '', // 清空分支
}); });
setBranches([]); // 清空分支列表 setBranches([]); // 清空分支列表
loadRepoProjects(systemId); loadRepoProjects(systemId);
@ -350,12 +350,12 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
const handleCodeSourceProjectChange = (projectId: number) => { const handleCodeSourceProjectChange = (projectId: number) => {
setFormData({ setFormData({
...formData, ...formData,
codeSourceProjectId: projectId, sourceGitProjectId: projectId,
branch: '', // 清空分支 sourceBranch: '', // 清空分支
}); });
// 加载该项目的分支 // 加载该项目的分支
if (formData.codeSourceSystemId) { if (formData.sourceGitSystemId) {
loadBranchesFromCodeSource(formData.codeSourceSystemId, projectId); loadBranchesFromCodeSource(formData.sourceGitSystemId, projectId);
} }
}; };
@ -396,8 +396,8 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
} }
// 源Git级联验证 // 源Git级联验证
if (formData.codeSourceSystemId) { if (formData.sourceGitSystemId) {
if (!formData.codeSourceProjectId) { if (!formData.sourceGitProjectId) {
toast({ toast({
variant: 'destructive', variant: 'destructive',
title: '请选择源仓库项目', title: '请选择源仓库项目',
@ -405,7 +405,7 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
}); });
return; return;
} }
if (!formData.branch) { if (!formData.sourceBranch) {
toast({ toast({
variant: 'destructive', variant: 'destructive',
title: '请选择源分支', title: '请选择源分支',
@ -441,12 +441,12 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
id: mode === 'edit' && application ? application.id : undefined, id: mode === 'edit' && application ? application.id : undefined,
appId: formData.appId, appId: formData.appId,
buildType: formData.buildType, buildType: formData.buildType,
branch: formData.branch, sourceBranch: formData.sourceBranch,
deploySystemId: formData.buildType === 'JENKINS' ? formData.deploySystemId : null, deploySystemId: formData.buildType === 'JENKINS' ? formData.deploySystemId : null,
deployJob: formData.buildType === 'JENKINS' ? formData.deployJob : '', deployJob: formData.buildType === 'JENKINS' ? formData.deployJob : '',
workflowDefinitionId: formData.workflowDefinitionId, workflowDefinitionId: formData.workflowDefinitionId,
codeSourceSystemId: formData.codeSourceSystemId, sourceGitSystemId: formData.sourceGitSystemId,
codeSourceProjectId: formData.codeSourceProjectId, sourceGitProjectId: formData.sourceGitProjectId,
targetGitSystemId: formData.targetGitSystemId, targetGitSystemId: formData.targetGitSystemId,
targetGitProjectId: formData.targetGitProjectId, targetGitProjectId: formData.targetGitProjectId,
targetBranch: formData.targetBranch, targetBranch: formData.targetBranch,
@ -723,16 +723,16 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
<GitConfigSelector <GitConfigSelector
label="源" label="源"
gitSystems={gitSystems} gitSystems={gitSystems}
selectedSystemId={formData.codeSourceSystemId} selectedSystemId={formData.sourceGitSystemId}
onSystemChange={handleCodeSourceSystemChange} onSystemChange={handleCodeSourceSystemChange}
repoProjects={repoProjects} repoProjects={repoProjects}
loadingRepoProjects={loadingRepoProjects} loadingRepoProjects={loadingRepoProjects}
selectedProjectId={formData.codeSourceProjectId} selectedProjectId={formData.sourceGitProjectId}
onProjectChange={handleCodeSourceProjectChange} onProjectChange={handleCodeSourceProjectChange}
branches={branches} branches={branches}
loadingBranches={loadingBranches} loadingBranches={loadingBranches}
selectedBranch={formData.branch} selectedBranch={formData.sourceBranch}
onBranchChange={(branch) => setFormData({ ...formData, branch })} onBranchChange={(sourceBranch) => setFormData({ ...formData, sourceBranch })}
/> />
{/* 🆕 目标Git配置仅当启用Git同步检测时显示 */} {/* 🆕 目标Git配置仅当启用Git同步检测时显示 */}

View File

@ -123,12 +123,12 @@ export const TeamApplicationManageDialog: React.FC<
id?: number; id?: number;
appId: number; appId: number;
buildType: 'JENKINS' | 'NATIVE' | null; buildType: 'JENKINS' | 'NATIVE' | null;
branch: string; sourceBranch: string;
deploySystemId: number | null; deploySystemId: number | null;
deployJob: string; deployJob: string;
workflowDefinitionId: number | null; workflowDefinitionId: number | null;
codeSourceSystemId: number | null; sourceGitSystemId: number | null;
codeSourceProjectId: number | null; sourceGitProjectId: number | null;
targetGitSystemId: number | null; // 🆕 目标Git系统ID targetGitSystemId: number | null; // 🆕 目标Git系统ID
targetGitProjectId: number | null; // 🆕 目标Git项目ID targetGitProjectId: number | null; // 🆕 目标Git项目ID
targetBranch: string; // 🆕 目标分支 targetBranch: string; // 🆕 目标分支
@ -140,13 +140,13 @@ export const TeamApplicationManageDialog: React.FC<
applicationId: data.appId, applicationId: data.appId,
environmentId: editingEnvironment.id, environmentId: editingEnvironment.id,
buildType: data.buildType || undefined, buildType: data.buildType || undefined,
branch: data.branch, sourceBranch: data.sourceBranch,
// 只有当 buildType 为 JENKINS 时才传递 Jenkins 相关字段 // 只有当 buildType 为 JENKINS 时才传递 Jenkins 相关字段
deploySystemId: data.buildType === 'JENKINS' ? (data.deploySystemId || undefined) : undefined, deploySystemId: data.buildType === 'JENKINS' ? (data.deploySystemId || undefined) : undefined,
deployJob: data.buildType === 'JENKINS' ? data.deployJob : '', deployJob: data.buildType === 'JENKINS' ? data.deployJob : '',
workflowDefinitionId: data.workflowDefinitionId || undefined, workflowDefinitionId: data.workflowDefinitionId || undefined,
codeSourceSystemId: data.codeSourceSystemId || undefined, sourceGitSystemId: data.sourceGitSystemId || undefined,
codeSourceProjectId: data.codeSourceProjectId || undefined, sourceGitProjectId: data.sourceGitProjectId || undefined,
// 🆕 目标Git相关字段 // 🆕 目标Git相关字段
targetGitSystemId: data.targetGitSystemId || undefined, targetGitSystemId: data.targetGitSystemId || undefined,
targetGitProjectId: data.targetGitProjectId || undefined, targetGitProjectId: data.targetGitProjectId || undefined,
@ -228,10 +228,10 @@ export const TeamApplicationManageDialog: React.FC<
return ( return (
<div className="flex items-center gap-2 text-sm"> <div className="flex items-center gap-2 text-sm">
<span className="font-medium truncate"> <span className="font-medium truncate">
{app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'} {app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'}
</span> </span>
{app.branch && ( {app.sourceBranch && (
<span className="text-xs text-muted-foreground">({app.branch})</span> <span className="text-xs text-muted-foreground">({app.sourceBranch})</span>
)} )}
</div> </div>
); );
@ -247,10 +247,10 @@ export const TeamApplicationManageDialog: React.FC<
<div className="text-sm"> <div className="text-sm">
<span className="text-muted-foreground"></span> <span className="text-muted-foreground"></span>
<span className="font-medium"> <span className="font-medium">
{app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'} {app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'}
</span> </span>
{app.branch && ( {app.sourceBranch && (
<span className="text-muted-foreground">({app.branch})</span> <span className="text-muted-foreground">({app.sourceBranch})</span>
)} )}
</div> </div>
{/* 同步标识 - 居中 */} {/* 同步标识 - 居中 */}
@ -274,9 +274,9 @@ export const TeamApplicationManageDialog: React.FC<
<div> <div>
<div className="font-semibold mb-1">Git</div> <div className="font-semibold mb-1">Git</div>
<div className="text-muted-foreground"> <div className="text-muted-foreground">
<div>: {app.codeSourceSystemName}</div> <div>: {app.sourceGitSystemName}</div>
<div>: {app.codeSourceProjectName}</div> <div>: {app.sourceGitProjectName}</div>
<div>: {app.branch || '-'}</div> <div>: {app.sourceBranch || '-'}</div>
</div> </div>
</div> </div>
<div className="border-t pt-2"> <div className="border-t pt-2">

View File

@ -180,14 +180,14 @@ export interface TeamApplication extends BaseResponse {
applicationId: number; applicationId: number;
environmentId: number; environmentId: number;
buildType?: BuildType; // 构建类型 buildType?: BuildType; // 构建类型
branch?: string; sourceBranch?: string; // 源分支名称
deploySystemId?: number; deploySystemId?: number;
deployJob?: string; deployJob?: string;
workflowDefinitionId?: number; workflowDefinitionId?: number;
codeSourceSystemId?: number; // 源代码系统ID sourceGitSystemId?: number; // 源Git系统ID
codeSourceProjectId?: number; // 源仓库项目ID sourceGitProjectId?: number; // 源Git项目ID
targetGitSystemId?: number; // 目标Git系统ID仅SYNC_MODE targetGitSystemId?: number; // 目标Git系统ID仅SYNC_MODE
targetGitProjectId?: number; // 目标Git项目ID targetGitProjectId?: number; // 目标Git项目ID
targetBranch?: string; // 目标分支名称 targetBranch?: string; // 目标分支名称
teamName?: string; teamName?: string;
applicationName?: string; applicationName?: string;
@ -195,10 +195,10 @@ export interface TeamApplication extends BaseResponse {
environmentName?: string; environmentName?: string;
deploySystemName?: string; deploySystemName?: string;
workflowDefinitionName?: string; workflowDefinitionName?: string;
codeSourceSystemName?: string; // 源代码系统名称 sourceGitSystemName?: string; // 源Git系统名称
codeSourceProjectName?: string; // 源仓库项目名称 sourceGitProjectName?: string; // 源Git项目名称
targetGitSystemName?: string; // 目标Git系统名称 targetGitSystemName?: string; // 目标Git系统名称
targetGitProjectName?: string; // 目标Git项目名称 targetGitProjectName?: string; // 目标Git项目名称
} }
/** /**
@ -209,14 +209,14 @@ export interface TeamApplicationRequest {
applicationId: number; applicationId: number;
environmentId: number; environmentId: number;
buildType?: BuildType; // 构建类型 buildType?: BuildType; // 构建类型
branch?: string; sourceBranch?: string; // 源分支名称
deploySystemId?: number; deploySystemId?: number;
deployJob?: string; deployJob?: string;
workflowDefinitionId?: number; workflowDefinitionId?: number;
codeSourceSystemId?: number; // 源代码系统ID sourceGitSystemId?: number; // 源Git系统ID
codeSourceProjectId?: number; // 源仓库项目ID sourceGitProjectId?: number; // 源Git项目ID
targetGitSystemId?: number; // 目标Git系统ID仅SYNC_MODE targetGitSystemId?: number; // 目标Git系统ID仅SYNC_MODE
targetGitProjectId?: number; // 目标Git项目ID targetGitProjectId?: number; // 目标Git项目ID
targetBranch?: string; // 目标分支名称 targetBranch?: string; // 目标分支名称
} }