diff --git a/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx b/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx index 5d49954b..45d962de 100644 --- a/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx +++ b/frontend/src/pages/Deploy/Deployment/List/components/DeploymentConfigModal.tsx @@ -35,10 +35,12 @@ import {getExternalSystemList, getJenkinsViewList, getJenkinsJobList, createDepl import {getPublishedDefinitions} from '@/pages/Workflow/Definition/service'; import type {ExternalSystem} from '@/pages/Deploy/External/types'; import { Editor } from "@/components/Editor"; +import { message } from 'antd'; interface Application { id: number; appName: string; + language: string; } interface JenkinsView { @@ -90,10 +92,12 @@ type FormValues = z.infer; interface DeploymentConfigModalProps { open: boolean; onCancel: () => void; - onSuccess: () => void; + onSuccess?: () => void; + environmentId: number; + buildType: string; } -const DeploymentConfigModal: React.FC = ({open, onCancel, onSuccess}) => { +const DeploymentConfigModal: React.FC = ({open, onCancel, onSuccess, environmentId, buildType}) => { const [applications, setApplications] = useState([]); const [externalSystems, setExternalSystems] = useState([]); const [jenkinsViews, setJenkinsViews] = useState([]); @@ -101,6 +105,7 @@ const DeploymentConfigModal: React.FC = ({open, onCa const [workflows, setWorkflows] = useState([]); const [fullscreenEditor, setFullscreenEditor] = useState(false); const [isFullscreen, setIsFullscreen] = useState(false); + const [currentApp, setCurrentApp] = useState(null); const form = useForm({ resolver: zodResolver(formSchema), @@ -176,11 +181,22 @@ const DeploymentConfigModal: React.FC = ({open, onCa } }; + // 当选择应用时获取应用信息 + const handleApplicationChange = (applicationId: number) => { + const app = applications.find(app => app.id === applicationId); + setCurrentApp(app || null); + form.setValue('applicationId', applicationId); + }; + const handleSubmit = async (values: FormValues) => { try { + if (!environmentId) { + message.error('请选择环境'); + return; + } + // 将环境变量数组转换为Map格式 const envMap = values.envs.reduce((acc, {key, value}) => { - // 只有当key和value都不为空时才添加到map中 if (key && value) { acc[key] = value; } @@ -188,14 +204,26 @@ const DeploymentConfigModal: React.FC = ({open, onCa }, {} as Record); const params = { - ...values, - envs: envMap + environmentId, + applicationId: values.applicationId, + languageType: currentApp?.language, + workflowDefinitionId: values.workflowId, + buildType, + buildVariables: { + externalSystemId: values.externalSystemId, + viewId: values.jenkinsViewId, + jobId: values.jenkinsJobId, + envs: envMap, + script: values.script + } }; await createDeploymentConfig(params); + message.success('保存成功'); onSuccess?.(); } catch (error) { console.error('Failed to create deployment config:', error); + message.error('保存失败'); } }; @@ -218,7 +246,7 @@ const DeploymentConfigModal: React.FC = ({open, onCa 应用名称