增加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 || '',
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() || '',
// 应用信息

View File

@ -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[];

View File

@ -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<TeamApplicationDialogProps> = ({
// 表单状态
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<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
}
// 源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<TeamApplicationDialogProps> = ({
});
return;
}
if (!formData.branch) {
if (!formData.sourceBranch) {
toast({
variant: 'destructive',
title: '请选择源分支',
@ -441,12 +441,12 @@ const TeamApplicationDialog: React.FC<TeamApplicationDialogProps> = ({
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<TeamApplicationDialogProps> = ({
<GitConfigSelector
label="源"
gitSystems={gitSystems}
selectedSystemId={formData.codeSourceSystemId}
selectedSystemId={formData.sourceGitSystemId}
onSystemChange={handleCodeSourceSystemChange}
repoProjects={repoProjects}
loadingRepoProjects={loadingRepoProjects}
selectedProjectId={formData.codeSourceProjectId}
selectedProjectId={formData.sourceGitProjectId}
onProjectChange={handleCodeSourceProjectChange}
branches={branches}
loadingBranches={loadingBranches}
selectedBranch={formData.branch}
onBranchChange={(branch) => setFormData({ ...formData, branch })}
selectedBranch={formData.sourceBranch}
onBranchChange={(sourceBranch) => setFormData({ ...formData, sourceBranch })}
/>
{/* 🆕 目标Git配置仅当启用Git同步检测时显示 */}

View File

@ -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 (
<div className="flex items-center gap-2 text-sm">
<span className="font-medium truncate">
{app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'}
{app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'}
</span>
{app.branch && (
<span className="text-xs text-muted-foreground">({app.branch})</span>
{app.sourceBranch && (
<span className="text-xs text-muted-foreground">({app.sourceBranch})</span>
)}
</div>
);
@ -247,10 +247,10 @@ export const TeamApplicationManageDialog: React.FC<
<div className="text-sm">
<span className="text-muted-foreground"></span>
<span className="font-medium">
{app.codeSourceSystemName || '-'} / {app.codeSourceProjectName || '-'}
{app.sourceGitSystemName || '-'} / {app.sourceGitProjectName || '-'}
</span>
{app.branch && (
<span className="text-muted-foreground">({app.branch})</span>
{app.sourceBranch && (
<span className="text-muted-foreground">({app.sourceBranch})</span>
)}
</div>
{/* 同步标识 - 居中 */}
@ -274,9 +274,9 @@ export const TeamApplicationManageDialog: React.FC<
<div>
<div className="font-semibold mb-1">Git</div>
<div className="text-muted-foreground">
<div>: {app.codeSourceSystemName}</div>
<div>: {app.codeSourceProjectName}</div>
<div>: {app.branch || '-'}</div>
<div>: {app.sourceGitSystemName}</div>
<div>: {app.sourceGitProjectName}</div>
<div>: {app.sourceBranch || '-'}</div>
</div>
</div>
<div className="border-t pt-2">

View File

@ -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; // 目标分支名称
}