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