增加GIT代码检测节点

This commit is contained in:
dengqichen 2025-12-04 18:35:15 +08:00
parent f49c0915ec
commit 909337044f
4 changed files with 41 additions and 45 deletions

View File

@ -104,8 +104,8 @@ export const ApplicationCard: React.FC<ApplicationCardProps> = ({
{/* 分支 */} {/* 分支 */}
<div className="flex items-center gap-1.5"> <div className="flex items-center gap-1.5">
<GitBranch className="h-3 w-3 shrink-0" /> <GitBranch className="h-3 w-3 shrink-0" />
{app.branch ? ( {app.sourceBranch ? (
<code className="truncate font-mono">{app.branch}</code> <code className="truncate font-mono">{app.sourceBranch}</code>
) : ( ) : (
<span className="text-amber-600 italic font-medium"></span> <span className="text-amber-600 italic font-medium"></span>
)} )}

View File

@ -43,7 +43,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
// 获取当前登录用户 // 获取当前登录用户
const currentUser = useSelector((state: RootState) => state.user.userInfo); const currentUser = useSelector((state: RootState) => state.user.userInfo);
// 使用 useMemo 缓存预填充数据,避免每次渲染都创建新对象 // 使用 useMemo 缓存预填充数据,避免每次渲染都创建新对象
const prefillData = React.useMemo(() => { const prefillData = React.useMemo(() => {
return { return {
// 构建类型 // 构建类型
@ -52,19 +52,19 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
jenkins: app.buildType === 'JENKINS' ? { jenkins: app.buildType === 'JENKINS' ? {
serverId: app.deploySystemId?.toString() || '', serverId: app.deploySystemId?.toString() || '',
jobName: app.deployJob || '', jobName: app.deployJob || '',
branch: app.branch || 'master', branch: app.sourceBranch,
} : undefined, } : undefined,
// 🆕 源Git仓库配置 // 源Git仓库配置
sourceRepository: app.sourceGitSystemId ? { sourceRepository: app.sourceGitSystemId ? {
systemId: app.sourceGitSystemId, systemId: app.sourceGitSystemId,
projectId: app.sourceGitProjectId, projectId: app.sourceGitProjectId,
branch: app.sourceBranch || '', branch: app.sourceBranch,
} : undefined, } : undefined,
// 🆕 目标Git仓库配置 // 目标Git仓库配置
targetRepository: app.targetGitSystemId ? { targetRepository: app.targetGitSystemId ? {
systemId: app.targetGitSystemId, systemId: app.targetGitSystemId,
projectId: app.targetGitProjectId, projectId: app.targetGitProjectId,
branch: app.targetBranch || '', branch: app.targetBranch,
} : undefined, } : undefined,
// 团队信息 // 团队信息
teamId: teamId?.toString() || '', teamId: teamId?.toString() || '',
@ -98,7 +98,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
}; };
}, [app, environment, teamId, currentUser]); // 只在这些依赖变化时重新生成 }, [app, environment, teamId, currentUser]); // 只在这些依赖变化时重新生成
// 🎯 1. 加载表单定义 (ID=2) // 1. 加载表单定义 (ID=2)
useEffect(() => { useEffect(() => {
if (open) { if (open) {
loadFormSchema(); loadFormSchema();
@ -119,7 +119,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
}; };
// 🎯 2. beforeSubmit 钩子:合并预填充数据 // 2. beforeSubmit 钩子:合并预填充数据
const handleBeforeSubmit = async (userInputData: Record<string, any>) => { const handleBeforeSubmit = async (userInputData: Record<string, any>) => {
// 合并数据:用户输入优先级更高 // 合并数据:用户输入优先级更高
const finalData = { const finalData = {
@ -130,10 +130,10 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
return finalData; return finalData;
}; };
// 🎯 3. 提交到后端 // 3. 提交到后端
const handleSubmit = async (formData: Record<string, any>) => { const handleSubmit = async (formData: Record<string, any>) => {
try { try {
// 🔍 开发环境下打印完整数据用于调试 // 开发环境下打印完整数据用于调试
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
console.group('🚀 部署请求数据'); console.group('🚀 部署请求数据');
console.log('完整数据结构:', JSON.stringify(formData, null, 2)); console.log('完整数据结构:', JSON.stringify(formData, null, 2));
@ -141,7 +141,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
console.groupEnd(); console.groupEnd();
} }
// 使用完整的表单数据提交到后端 // 使用完整的表单数据提交到后端
await startDeployment(formData); await startDeployment(formData);
message.success( message.success(
@ -152,12 +152,12 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
return {success: true}; return {success: true};
} catch (error: any) { } catch (error: any) {
// 直接抛出原始错误,让 request.ts 拦截器统一处理错误提示 // 直接抛出原始错误,让 request.ts 拦截器统一处理错误提示
throw error; throw error;
} }
}; };
// 🎯 4. 提交成功后的处理 // 4. 提交成功后的处理
const handleAfterSubmit = async () => { const handleAfterSubmit = async () => {
onClose(); onClose();
if (onSuccess) { if (onSuccess) {
@ -165,9 +165,9 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
} }
}; };
// 🎯 5. 错误处理 // 5. 错误处理
const handleError = async (error: any) => { const handleError = async (error: any) => {
// 不再显示错误提示,因为 request.ts 拦截器已经统一处理了 // 不再显示错误提示,因为 request.ts 拦截器已经统一处理了
// 这里只做日志记录,避免重复提示 // 这里只做日志记录,避免重复提示
console.error('部署失败:', error); console.error('部署失败:', error);
}; };

View File

@ -50,22 +50,20 @@ export interface ApplicationConfig {
applicationDesc?: string; applicationDesc?: string;
language?: DevelopmentLanguageTypeEnum; // 开发语言 language?: DevelopmentLanguageTypeEnum; // 开发语言
buildType?: BuildType; // 构建类型 buildType?: BuildType; // 构建类型
branch: string;
deployBranch?: string; // 🆕 部署分支
deploySystemId?: number; deploySystemId?: number;
deploySystemName?: string; deploySystemName?: string;
deployJob?: string; deployJob?: string;
workflowDefinitionId?: number; workflowDefinitionId?: number;
workflowDefinitionFormId?: number; // 🆕 工作流表单ID workflowDefinitionFormId?: number;
workflowDefinitionName?: string; workflowDefinitionName?: string;
workflowDefinitionKey?: string; workflowDefinitionKey?: string;
// 🆕 源Git配置 // 源Git配置
sourceGitSystemId?: number; sourceGitSystemId?: number;
sourceGitSystemName?: string; sourceGitSystemName?: string;
sourceGitProjectId?: number; sourceGitProjectId?: number;
sourceGitProjectName?: string; sourceGitProjectName?: string;
sourceBranch?: string; sourceBranch?: string;
// 🆕 目标Git配置 // 目标Git配置
targetGitSystemId?: number; targetGitSystemId?: number;
targetGitSystemName?: string; targetGitSystemName?: string;
targetGitProjectId?: number; targetGitProjectId?: number;
@ -94,10 +92,10 @@ export interface DeployEnvironment {
sort: number; sort: number;
requiresApproval: boolean; requiresApproval: boolean;
approvers: Approver[]; approvers: Approver[];
notificationConfig?: NotificationConfig; // 🆕 通知配置 notificationConfig?: NotificationConfig;
requireCodeReview: boolean; // 🆕 是否需要代码审查 requireCodeReview: boolean;
canDeploy: boolean; // 🆕 当前用户是否可以发起部署 canDeploy: boolean;
canApprove: boolean; // 🆕 当前用户是否可以审批部署 canApprove: boolean;
applications: ApplicationConfig[]; applications: ApplicationConfig[];
} }
@ -113,13 +111,12 @@ export interface DeployTeam {
teamCode: string; teamCode: string;
teamName: string; teamName: string;
description?: string; description?: string;
ownerId: number; // 🆕 团队负责人ID ownerId: number;
ownerName: string; // 🆕 团队负责人名称 ownerName: string;
members: TeamMember[]; // 🆕 团队成员列表 members: TeamMember[];
environments: DeployEnvironment[]; environments: DeployEnvironment[];
} }
// ✅ 新接口直接返回 teams 数组
export type DeployEnvironmentsResponse = DeployTeam[]; export type DeployEnvironmentsResponse = DeployTeam[];
export interface StartDeploymentRequest { export interface StartDeploymentRequest {

View File

@ -1,5 +1,4 @@
import {ConfigurableNodeDefinition, NodeType, NodeCategory, defineNodeOutputs} from './types'; import {ConfigurableNodeDefinition, NodeType, NodeCategory, defineNodeOutputs} from './types';
import {DataSourceType} from '@/domain/dataSource';
/** /**
* Git同步检测节点定义 * Git同步检测节点定义
@ -51,35 +50,35 @@ export const GitSyncCheckNodeDefinition: ConfigurableNodeDefinition = {
default: true default: true
}, },
sourceGitSystemId: { sourceGitSystemId: {
type: "number", type: "string",
title: "源Git系统", title: "源Git系统",
description: "内网Git系统数据源或变量", description: "源Git系统ID输入变量如 ${teamApplication.sourceGitSystemId}",
"x-dataSource": DataSourceType.GIT_REPOSITORIES, "x-allow-variable": true,
"x-allow-variable": true "x-placeholder": "${teamApplication.sourceGitSystemId}"
}, },
sourceGitProjectId: { sourceGitProjectId: {
type: "number", type: "string",
title: "源Git项目", title: "源Git项目",
description: "源仓库项目ID输入变量如 ${teamApplication.codeSourceProjectId}", description: "源仓库项目ID输入变量如 ${teamApplication.sourceGitProjectId}",
"x-allow-variable": true, "x-allow-variable": true,
"x-placeholder": "${teamApplication.codeSourceProjectId}" "x-placeholder": "${teamApplication.sourceGitProjectId}"
}, },
sourceBranch: { sourceBranch: {
type: "string", type: "string",
title: "源分支", title: "源分支",
description: "源分支名称(输入变量,如 ${teamApplication.branch}", description: "源分支名称(输入变量,如 ${teamApplication.sourceBranch}",
"x-allow-variable": true, "x-allow-variable": true,
"x-placeholder": "${teamApplication.branch}" "x-placeholder": "${teamApplication.sourceBranch}"
}, },
targetGitSystemId: { targetGitSystemId: {
type: "number", type: "string",
title: "目标Git系统", title: "目标Git系统",
description: "客户Git系统数据源或变量", description: "目标Git系统ID输入变量如 ${teamApplication.targetGitSystemId}",
"x-dataSource": DataSourceType.GIT_REPOSITORIES, "x-allow-variable": true,
"x-allow-variable": true "x-placeholder": "${teamApplication.targetGitSystemId}"
}, },
targetGitProjectId: { targetGitProjectId: {
type: "number", type: "string",
title: "目标Git项目", title: "目标Git项目",
description: "目标仓库项目ID输入变量如 ${teamApplication.targetGitProjectId}", description: "目标仓库项目ID输入变量如 ${teamApplication.targetGitProjectId}",
"x-allow-variable": true, "x-allow-variable": true,