From 6b83597d47d859cb0eade403a5d4b2c8d823c922 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Thu, 4 Dec 2025 17:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0GIT=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DeploymentFormModal.tsx | 12 +++ frontend/src/pages/Dashboard/types.ts | 12 +++ .../List/components/TeamApplicationDialog.tsx | 82 +++++++++---------- .../TeamApplicationManageDialog.tsx | 30 +++---- frontend/src/pages/Deploy/Team/List/types.ts | 28 +++---- 5 files changed, 94 insertions(+), 70 deletions(-) diff --git a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx index 95c52fdb..6d3ab70d 100644 --- a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx +++ b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx @@ -54,6 +54,18 @@ const DeploymentFormModal: React.FC = ({ jobName: app.deployJob || '', branch: app.branch || 'master', } : 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() || '', // 应用信息 diff --git a/frontend/src/pages/Dashboard/types.ts b/frontend/src/pages/Dashboard/types.ts index 80a79188..ee2487bd 100644 --- a/frontend/src/pages/Dashboard/types.ts +++ b/frontend/src/pages/Dashboard/types.ts @@ -59,6 +59,18 @@ export interface ApplicationConfig { workflowDefinitionFormId?: number; // 🆕 工作流表单ID workflowDefinitionName?: 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; isDeploying?: boolean; recentDeployRecords?: DeployRecord[]; diff --git a/frontend/src/pages/Deploy/Team/List/components/TeamApplicationDialog.tsx b/frontend/src/pages/Deploy/Team/List/components/TeamApplicationDialog.tsx index 8367eb6d..bca766ff 100644 --- a/frontend/src/pages/Deploy/Team/List/components/TeamApplicationDialog.tsx +++ b/frontend/src/pages/Deploy/Team/List/components/TeamApplicationDialog.tsx @@ -51,12 +51,12 @@ interface TeamApplicationDialogProps { id?: number; appId: number; buildType: BuildType | null; - branch: string; + sourceBranch: string; deploySystemId: number | null; deployJob: string; workflowDefinitionId: number | null; - codeSourceSystemId: number | null; - codeSourceProjectId: number | null; + sourceGitSystemId: number | null; + sourceGitProjectId: number | null; targetGitSystemId: number | null; // 🆕 目标Git系统ID targetGitProjectId: number | null; // 🆕 目标Git项目ID targetBranch: string; // 🆕 目标分支 @@ -86,17 +86,17 @@ const TeamApplicationDialog: React.FC = ({ // 表单状态 const [formData, setFormData] = useState({ - appId: null as number | null, - buildType: 'JENKINS' as BuildType | null, - branch: '', + appId: 0, + buildType: 'JENKINS' as 'JENKINS' | 'NATIVE' | null, + sourceBranch: '', // 源分支名称 deploySystemId: null as number | null, deployJob: '', workflowDefinitionId: null as number | null, - codeSourceSystemId: null as number | null, // 源代码系统ID - codeSourceProjectId: null as number | null, // 源仓库项目ID - targetGitSystemId: null as number | null, // 🆕 目标Git系统ID - targetGitProjectId: null as number | null, // 🆕 目标Git项目ID - targetBranch: '', // 🆕 目标分支 + sourceGitSystemId: null as number | null, // 源Git系统ID + sourceGitProjectId: null as number | null, // 源Git项目ID + targetGitSystemId: null as number | null, // 目标Git系统ID + targetGitProjectId: null as number | null, // 目标Git项目ID + targetBranch: '', // 目标分支名称 }); // 加载状态 @@ -128,26 +128,26 @@ const TeamApplicationDialog: React.FC = ({ setFormData({ appId: application.applicationId, buildType: application.buildType || 'JENKINS', - branch: application.branch || '', + sourceBranch: application.sourceBranch || '', deploySystemId: application.deploySystemId || null, deployJob: application.deployJob || '', workflowDefinitionId: application.workflowDefinitionId || null, - codeSourceSystemId: application.codeSourceSystemId || null, - codeSourceProjectId: application.codeSourceProjectId || null, + sourceGitSystemId: application.sourceGitSystemId || null, + sourceGitProjectId: application.sourceGitProjectId || null, targetGitSystemId: application.targetGitSystemId || null, targetGitProjectId: application.targetGitProjectId || null, targetBranch: application.targetBranch || '', }); // 加载源仓库项目 - if (application.codeSourceSystemId) { - loadRepoProjects(application.codeSourceSystemId); + if (application.sourceGitSystemId) { + loadRepoProjects(application.sourceGitSystemId); } // 加载源分支(优先使用代码源信息,向后兼容旧数据) - if (application.codeSourceSystemId && application.codeSourceProjectId) { + if (application.sourceGitSystemId && application.sourceGitProjectId) { // 使用代码源信息加载分支 - loadBranchesFromCodeSource(application.codeSourceSystemId, application.codeSourceProjectId); + loadBranchesFromCodeSource(application.sourceGitSystemId, application.sourceGitProjectId); } else { // 向后兼容:使用应用信息加载分支 const app = applications.find(a => a.id === application.applicationId); @@ -175,12 +175,12 @@ const TeamApplicationDialog: React.FC = ({ setFormData({ appId: null, buildType: 'JENKINS', - branch: '', + sourceBranch: '', deploySystemId: null, deployJob: '', workflowDefinitionId: null, - codeSourceSystemId: null, - codeSourceProjectId: null, + sourceGitSystemId: null, + sourceGitProjectId: null, targetGitSystemId: null, targetGitProjectId: null, targetBranch: '', @@ -270,12 +270,12 @@ const TeamApplicationDialog: React.FC = ({ setFormData({ appId: appId, buildType: formData.buildType, - branch: '', + sourceBranch: '', deploySystemId: null, deployJob: '', workflowDefinitionId: null, - codeSourceSystemId: null, - codeSourceProjectId: null, + sourceGitSystemId: null, + sourceGitProjectId: null, targetGitSystemId: null, targetGitProjectId: null, targetBranch: '', @@ -338,9 +338,9 @@ const TeamApplicationDialog: React.FC = ({ const handleCodeSourceSystemChange = (systemId: number) => { setFormData({ ...formData, - codeSourceSystemId: systemId, - codeSourceProjectId: null, - branch: '', // 清空分支 + sourceGitSystemId: systemId, + sourceGitProjectId: null, + sourceBranch: '', // 清空分支 }); setBranches([]); // 清空分支列表 loadRepoProjects(systemId); @@ -350,12 +350,12 @@ const TeamApplicationDialog: React.FC = ({ const handleCodeSourceProjectChange = (projectId: number) => { setFormData({ ...formData, - codeSourceProjectId: projectId, - branch: '', // 清空分支 + sourceGitProjectId: projectId, + sourceBranch: '', // 清空分支 }); // 加载该项目的分支 - if (formData.codeSourceSystemId) { - loadBranchesFromCodeSource(formData.codeSourceSystemId, projectId); + if (formData.sourceGitSystemId) { + loadBranchesFromCodeSource(formData.sourceGitSystemId, projectId); } }; @@ -396,8 +396,8 @@ const TeamApplicationDialog: React.FC = ({ } // 源Git级联验证 - if (formData.codeSourceSystemId) { - if (!formData.codeSourceProjectId) { + if (formData.sourceGitSystemId) { + if (!formData.sourceGitProjectId) { toast({ variant: 'destructive', title: '请选择源仓库项目', @@ -405,7 +405,7 @@ const TeamApplicationDialog: React.FC = ({ }); return; } - if (!formData.branch) { + if (!formData.sourceBranch) { toast({ variant: 'destructive', title: '请选择源分支', @@ -441,12 +441,12 @@ const TeamApplicationDialog: React.FC = ({ id: mode === 'edit' && application ? application.id : undefined, appId: formData.appId, buildType: formData.buildType, - branch: formData.branch, + sourceBranch: formData.sourceBranch, deploySystemId: formData.buildType === 'JENKINS' ? formData.deploySystemId : null, deployJob: formData.buildType === 'JENKINS' ? formData.deployJob : '', workflowDefinitionId: formData.workflowDefinitionId, - codeSourceSystemId: formData.codeSourceSystemId, - codeSourceProjectId: formData.codeSourceProjectId, + sourceGitSystemId: formData.sourceGitSystemId, + sourceGitProjectId: formData.sourceGitProjectId, targetGitSystemId: formData.targetGitSystemId, targetGitProjectId: formData.targetGitProjectId, targetBranch: formData.targetBranch, @@ -723,16 +723,16 @@ const TeamApplicationDialog: React.FC = ({ setFormData({ ...formData, branch })} + selectedBranch={formData.sourceBranch} + onBranchChange={(sourceBranch) => setFormData({ ...formData, sourceBranch })} /> {/* 🆕 目标Git配置(仅当启用Git同步检测时显示) */} diff --git a/frontend/src/pages/Deploy/Team/List/components/TeamApplicationManageDialog.tsx b/frontend/src/pages/Deploy/Team/List/components/TeamApplicationManageDialog.tsx index 3213e37b..fdf55f30 100644 --- a/frontend/src/pages/Deploy/Team/List/components/TeamApplicationManageDialog.tsx +++ b/frontend/src/pages/Deploy/Team/List/components/TeamApplicationManageDialog.tsx @@ -123,12 +123,12 @@ export const TeamApplicationManageDialog: React.FC< id?: number; appId: number; buildType: 'JENKINS' | 'NATIVE' | null; - branch: string; + sourceBranch: string; deploySystemId: number | null; deployJob: string; workflowDefinitionId: number | null; - codeSourceSystemId: number | null; - codeSourceProjectId: number | null; + sourceGitSystemId: number | null; + sourceGitProjectId: number | null; targetGitSystemId: number | null; // 🆕 目标Git系统ID targetGitProjectId: number | null; // 🆕 目标Git项目ID targetBranch: string; // 🆕 目标分支 @@ -140,13 +140,13 @@ export const TeamApplicationManageDialog: React.FC< applicationId: data.appId, environmentId: editingEnvironment.id, buildType: data.buildType || undefined, - branch: data.branch, + sourceBranch: data.sourceBranch, // 只有当 buildType 为 JENKINS 时才传递 Jenkins 相关字段 deploySystemId: data.buildType === 'JENKINS' ? (data.deploySystemId || undefined) : undefined, deployJob: data.buildType === 'JENKINS' ? data.deployJob : '', workflowDefinitionId: data.workflowDefinitionId || undefined, - codeSourceSystemId: data.codeSourceSystemId || undefined, - codeSourceProjectId: data.codeSourceProjectId || undefined, + sourceGitSystemId: data.sourceGitSystemId || undefined, + sourceGitProjectId: data.sourceGitProjectId || undefined, // 🆕 目标Git相关字段 targetGitSystemId: data.targetGitSystemId || undefined, targetGitProjectId: data.targetGitProjectId || undefined, @@ -228,10 +228,10 @@ export const TeamApplicationManageDialog: React.FC< return (
- {app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'} + {app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'} - {app.branch && ( - ({app.branch}) + {app.sourceBranch && ( + ({app.sourceBranch}) )}
); @@ -247,10 +247,10 @@ export const TeamApplicationManageDialog: React.FC<
源: - {app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'} + {app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'} - {app.branch && ( - ({app.branch}) + {app.sourceBranch && ( + ({app.sourceBranch}) )}
{/* 同步标识 - 居中 */} @@ -274,9 +274,9 @@ export const TeamApplicationManageDialog: React.FC<
源Git
-
系统: {app.codeSourceSystemName}
-
项目: {app.codeSourceProjectName}
-
分支: {app.branch || '-'}
+
系统: {app.sourceGitSystemName}
+
项目: {app.sourceGitProjectName}
+
分支: {app.sourceBranch || '-'}
diff --git a/frontend/src/pages/Deploy/Team/List/types.ts b/frontend/src/pages/Deploy/Team/List/types.ts index 744a9cd6..c478d3bf 100644 --- a/frontend/src/pages/Deploy/Team/List/types.ts +++ b/frontend/src/pages/Deploy/Team/List/types.ts @@ -180,14 +180,14 @@ export interface TeamApplication extends BaseResponse { applicationId: number; environmentId: number; buildType?: BuildType; // 构建类型 - branch?: string; + sourceBranch?: string; // 源分支名称 deploySystemId?: number; deployJob?: string; workflowDefinitionId?: number; - codeSourceSystemId?: number; // 源代码系统ID - codeSourceProjectId?: number; // 源仓库项目ID - targetGitSystemId?: number; // 目标Git系统ID(仅SYNC_MODE) - targetGitProjectId?: number; // 目标Git项目ID + sourceGitSystemId?: number; // 源Git系统ID + sourceGitProjectId?: number; // 源Git项目ID + targetGitSystemId?: number; // 目标Git系统ID(仅SYNC_MODE) + targetGitProjectId?: number; // 目标Git项目ID targetBranch?: string; // 目标分支名称 teamName?: string; applicationName?: string; @@ -195,10 +195,10 @@ export interface TeamApplication extends BaseResponse { environmentName?: string; deploySystemName?: string; workflowDefinitionName?: string; - codeSourceSystemName?: string; // 源代码系统名称 - codeSourceProjectName?: string; // 源仓库项目名称 - targetGitSystemName?: string; // 目标Git系统名称 - targetGitProjectName?: string; // 目标Git项目名称 + sourceGitSystemName?: string; // 源Git系统名称 + sourceGitProjectName?: string; // 源Git项目名称 + targetGitSystemName?: string; // 目标Git系统名称 + targetGitProjectName?: string; // 目标Git项目名称 } /** @@ -209,14 +209,14 @@ export interface TeamApplicationRequest { applicationId: number; environmentId: number; buildType?: BuildType; // 构建类型 - branch?: string; + sourceBranch?: string; // 源分支名称 deploySystemId?: number; deployJob?: string; workflowDefinitionId?: number; - codeSourceSystemId?: number; // 源代码系统ID - codeSourceProjectId?: number; // 源仓库项目ID - targetGitSystemId?: number; // 目标Git系统ID(仅SYNC_MODE) - targetGitProjectId?: number; // 目标Git项目ID + sourceGitSystemId?: number; // 源Git系统ID + sourceGitProjectId?: number; // 源Git项目ID + targetGitSystemId?: number; // 目标Git系统ID(仅SYNC_MODE) + targetGitProjectId?: number; // 目标Git项目ID targetBranch?: string; // 目标分支名称 }