1
This commit is contained in:
parent
578e375f10
commit
cf045fc38b
@ -1,6 +1,6 @@
|
||||
import React, {useEffect, useState, useCallback} from 'react';
|
||||
import {Modal, Form, Select, message, Switch, InputNumber, Input} from 'antd';
|
||||
import type {DeploymentConfig, DeployConfigTemplate} from '../types';
|
||||
import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigRequest} from '../types';
|
||||
import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service';
|
||||
import {getApplicationList} from '../../../Application/List/service';
|
||||
import type {Application} from '../../../Application/List/types';
|
||||
@ -118,12 +118,12 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
}
|
||||
|
||||
// 构建提交数据
|
||||
const submitData = {
|
||||
const submitData: CreateDeploymentConfigRequest = {
|
||||
environmentId: envId,
|
||||
applicationId: values.applicationId,
|
||||
buildType: template.buildType,
|
||||
languageType: selectedApp.language,
|
||||
buildVariables, // 动态表单的值都在这里
|
||||
buildVariables,
|
||||
enabled: values.enabled
|
||||
};
|
||||
|
||||
@ -149,6 +149,22 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 处理富文本编辑器的值变化
|
||||
const handleEditorChange = (key: string, value: string | undefined) => {
|
||||
setBuildVariables(prev => ({
|
||||
...prev,
|
||||
[key]: value || ''
|
||||
}));
|
||||
};
|
||||
|
||||
// 处理普通输入框的值变化
|
||||
const handleInputChange = (key: string, value: string) => {
|
||||
setBuildVariables(prev => ({
|
||||
...prev,
|
||||
[key]: value
|
||||
}));
|
||||
};
|
||||
|
||||
// 渲染表单项
|
||||
const renderFormItems = () => {
|
||||
if (!selectedTemplate?.buildVariablesSchema?.properties) return null;
|
||||
@ -171,10 +187,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
defaultLanguage={property.editorConfig.language || 'shell'}
|
||||
theme={property.editorConfig.theme || 'vs-dark'}
|
||||
value={buildVariables[key] || property.default || ''}
|
||||
onChange={(value) => setBuildVariables(prev => ({
|
||||
...prev,
|
||||
[key]: value
|
||||
}))}
|
||||
onChange={(value) => handleEditorChange(key, value)}
|
||||
options={{
|
||||
minimap: { enabled: property.editorConfig.minimap ?? false },
|
||||
fontSize: property.editorConfig.fontSize || 14,
|
||||
@ -215,10 +228,7 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
||||
>
|
||||
<Input
|
||||
value={buildVariables[key] || property.default || ''}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setBuildVariables(prev => ({
|
||||
...prev,
|
||||
[key]: e.target.value
|
||||
}))}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange(key, e.target.value)}
|
||||
placeholder={`请输入${property.title || key}`}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user