From 909337044fa84bc071a17ab874317b7fc4614719 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Thu, 4 Dec 2025 18:35:15 +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 --- .../Dashboard/components/ApplicationCard.tsx | 4 +-- .../components/DeploymentFormModal.tsx | 30 +++++++++---------- frontend/src/pages/Dashboard/types.ts | 23 +++++++------- .../Design/nodes/GitSyncCheckNode.tsx | 29 +++++++++--------- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/frontend/src/pages/Dashboard/components/ApplicationCard.tsx b/frontend/src/pages/Dashboard/components/ApplicationCard.tsx index ff9a32ed..bdc29a90 100644 --- a/frontend/src/pages/Dashboard/components/ApplicationCard.tsx +++ b/frontend/src/pages/Dashboard/components/ApplicationCard.tsx @@ -104,8 +104,8 @@ export const ApplicationCard: React.FC = ({ {/* 分支 */}
- {app.branch ? ( - {app.branch} + {app.sourceBranch ? ( + {app.sourceBranch} ) : ( 未配置分支 )} diff --git a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx index 6d3ab70d..f3046171 100644 --- a/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx +++ b/frontend/src/pages/Dashboard/components/DeploymentFormModal.tsx @@ -43,7 +43,7 @@ const DeploymentFormModal: React.FC = ({ // 获取当前登录用户 const currentUser = useSelector((state: RootState) => state.user.userInfo); - // ✅ 使用 useMemo 缓存预填充数据,避免每次渲染都创建新对象 + // 使用 useMemo 缓存预填充数据,避免每次渲染都创建新对象 const prefillData = React.useMemo(() => { return { // 构建类型 @@ -52,19 +52,19 @@ const DeploymentFormModal: React.FC = ({ jenkins: app.buildType === 'JENKINS' ? { serverId: app.deploySystemId?.toString() || '', jobName: app.deployJob || '', - branch: app.branch || 'master', + branch: app.sourceBranch, } : undefined, - // 🆕 源Git仓库配置 + // 源Git仓库配置 sourceRepository: app.sourceGitSystemId ? { systemId: app.sourceGitSystemId, projectId: app.sourceGitProjectId, - branch: app.sourceBranch || '', + branch: app.sourceBranch, } : undefined, - // 🆕 目标Git仓库配置 + // 目标Git仓库配置 targetRepository: app.targetGitSystemId ? { systemId: app.targetGitSystemId, projectId: app.targetGitProjectId, - branch: app.targetBranch || '', + branch: app.targetBranch, } : undefined, // 团队信息 teamId: teamId?.toString() || '', @@ -98,7 +98,7 @@ const DeploymentFormModal: React.FC = ({ }; }, [app, environment, teamId, currentUser]); // 只在这些依赖变化时重新生成 - // 🎯 1. 加载表单定义 (ID=2) + // 1. 加载表单定义 (ID=2) useEffect(() => { if (open) { loadFormSchema(); @@ -119,7 +119,7 @@ const DeploymentFormModal: React.FC = ({ }; - // 🎯 2. beforeSubmit 钩子:合并预填充数据 + // 2. beforeSubmit 钩子:合并预填充数据 const handleBeforeSubmit = async (userInputData: Record) => { // 合并数据:用户输入优先级更高 const finalData = { @@ -130,10 +130,10 @@ const DeploymentFormModal: React.FC = ({ return finalData; }; - // 🎯 3. 提交到后端 + // 3. 提交到后端 const handleSubmit = async (formData: Record) => { try { - // 🔍 开发环境下打印完整数据用于调试 + // 开发环境下打印完整数据用于调试 if (import.meta.env.DEV) { console.group('🚀 部署请求数据'); console.log('完整数据结构:', JSON.stringify(formData, null, 2)); @@ -141,7 +141,7 @@ const DeploymentFormModal: React.FC = ({ console.groupEnd(); } - // ✅ 使用完整的表单数据提交到后端 + // 使用完整的表单数据提交到后端 await startDeployment(formData); message.success( @@ -152,12 +152,12 @@ const DeploymentFormModal: React.FC = ({ return {success: true}; } catch (error: any) { - // ✅ 直接抛出原始错误,让 request.ts 拦截器统一处理错误提示 + // 直接抛出原始错误,让 request.ts 拦截器统一处理错误提示 throw error; } }; - // 🎯 4. 提交成功后的处理 + // 4. 提交成功后的处理 const handleAfterSubmit = async () => { onClose(); if (onSuccess) { @@ -165,9 +165,9 @@ const DeploymentFormModal: React.FC = ({ } }; - // 🎯 5. 错误处理 + // 5. 错误处理 const handleError = async (error: any) => { - // ✅ 不再显示错误提示,因为 request.ts 拦截器已经统一处理了 + // 不再显示错误提示,因为 request.ts 拦截器已经统一处理了 // 这里只做日志记录,避免重复提示 console.error('部署失败:', error); }; diff --git a/frontend/src/pages/Dashboard/types.ts b/frontend/src/pages/Dashboard/types.ts index ee2487bd..2a525fdb 100644 --- a/frontend/src/pages/Dashboard/types.ts +++ b/frontend/src/pages/Dashboard/types.ts @@ -50,22 +50,20 @@ export interface ApplicationConfig { applicationDesc?: string; language?: DevelopmentLanguageTypeEnum; // 开发语言 buildType?: BuildType; // 构建类型 - branch: string; - deployBranch?: string; // 🆕 部署分支 deploySystemId?: number; deploySystemName?: string; deployJob?: string; workflowDefinitionId?: number; - workflowDefinitionFormId?: number; // 🆕 工作流表单ID + workflowDefinitionFormId?: number; workflowDefinitionName?: string; workflowDefinitionKey?: string; - // 🆕 源Git配置 + // 源Git配置 sourceGitSystemId?: number; sourceGitSystemName?: string; sourceGitProjectId?: number; sourceGitProjectName?: string; sourceBranch?: string; - // 🆕 目标Git配置 + // 目标Git配置 targetGitSystemId?: number; targetGitSystemName?: string; targetGitProjectId?: number; @@ -94,10 +92,10 @@ export interface DeployEnvironment { sort: number; requiresApproval: boolean; approvers: Approver[]; - notificationConfig?: NotificationConfig; // 🆕 通知配置 - requireCodeReview: boolean; // 🆕 是否需要代码审查 - canDeploy: boolean; // 🆕 当前用户是否可以发起部署 - canApprove: boolean; // 🆕 当前用户是否可以审批部署 + notificationConfig?: NotificationConfig; + requireCodeReview: boolean; + canDeploy: boolean; + canApprove: boolean; applications: ApplicationConfig[]; } @@ -113,13 +111,12 @@ export interface DeployTeam { teamCode: string; teamName: string; description?: string; - ownerId: number; // 🆕 团队负责人ID - ownerName: string; // 🆕 团队负责人名称 - members: TeamMember[]; // 🆕 团队成员列表 + ownerId: number; + ownerName: string; + members: TeamMember[]; environments: DeployEnvironment[]; } -// ✅ 新接口直接返回 teams 数组 export type DeployEnvironmentsResponse = DeployTeam[]; export interface StartDeploymentRequest { diff --git a/frontend/src/pages/Workflow/Design/nodes/GitSyncCheckNode.tsx b/frontend/src/pages/Workflow/Design/nodes/GitSyncCheckNode.tsx index 8aa216fe..f99c9812 100644 --- a/frontend/src/pages/Workflow/Design/nodes/GitSyncCheckNode.tsx +++ b/frontend/src/pages/Workflow/Design/nodes/GitSyncCheckNode.tsx @@ -1,5 +1,4 @@ import {ConfigurableNodeDefinition, NodeType, NodeCategory, defineNodeOutputs} from './types'; -import {DataSourceType} from '@/domain/dataSource'; /** * Git同步检测节点定义(纯配置) @@ -51,35 +50,35 @@ export const GitSyncCheckNodeDefinition: ConfigurableNodeDefinition = { default: true }, sourceGitSystemId: { - type: "number", + type: "string", title: "源Git系统", - description: "内网Git系统(数据源或变量)", - "x-dataSource": DataSourceType.GIT_REPOSITORIES, - "x-allow-variable": true + description: "源Git系统ID(输入变量,如 ${teamApplication.sourceGitSystemId})", + "x-allow-variable": true, + "x-placeholder": "${teamApplication.sourceGitSystemId}" }, sourceGitProjectId: { - type: "number", + type: "string", title: "源Git项目", - description: "源仓库项目ID(输入变量,如 ${teamApplication.codeSourceProjectId})", + description: "源仓库项目ID(输入变量,如 ${teamApplication.sourceGitProjectId})", "x-allow-variable": true, - "x-placeholder": "${teamApplication.codeSourceProjectId}" + "x-placeholder": "${teamApplication.sourceGitProjectId}" }, sourceBranch: { type: "string", title: "源分支", - description: "源分支名称(输入变量,如 ${teamApplication.branch})", + description: "源分支名称(输入变量,如 ${teamApplication.sourceBranch})", "x-allow-variable": true, - "x-placeholder": "${teamApplication.branch}" + "x-placeholder": "${teamApplication.sourceBranch}" }, targetGitSystemId: { - type: "number", + type: "string", title: "目标Git系统", - description: "客户Git系统(数据源或变量)", - "x-dataSource": DataSourceType.GIT_REPOSITORIES, - "x-allow-variable": true + description: "目标Git系统ID(输入变量,如 ${teamApplication.targetGitSystemId})", + "x-allow-variable": true, + "x-placeholder": "${teamApplication.targetGitSystemId}" }, targetGitProjectId: { - type: "number", + type: "string", title: "目标Git项目", description: "目标仓库项目ID(输入变量,如 ${teamApplication.targetGitProjectId})", "x-allow-variable": true,