1
This commit is contained in:
parent
5e80f9de10
commit
cd650f56f5
@ -1,5 +1,5 @@
|
|||||||
import React, {useEffect, useState, useCallback} from 'react';
|
import React, {useEffect, useState, useCallback} from 'react';
|
||||||
import {Modal, Form, Select, message, Switch, InputNumber, Input, Space, Button} from 'antd';
|
import {Modal, Form, Select, message, Switch, Space, Button} from 'antd';
|
||||||
import {FullscreenOutlined} from '@ant-design/icons';
|
import {FullscreenOutlined} from '@ant-design/icons';
|
||||||
import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigRequest} from '../types';
|
import type {DeploymentConfig, DeployConfigTemplate, CreateDeploymentConfigRequest} from '../types';
|
||||||
import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service';
|
import {createDeploymentConfig, updateDeploymentConfig, getDeployConfigTemplates} from '../service';
|
||||||
@ -68,12 +68,11 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
|||||||
}
|
}
|
||||||
}, [open, fetchApplications, fetchTemplates]);
|
}, [open, fetchApplications, fetchTemplates]);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>始化表单数据
|
// 初始化表单数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
|
|
||||||
if (initialValues) {
|
if (initialValues) {
|
||||||
// 设置基础字段
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
applicationId: initialValues.applicationId,
|
applicationId: initialValues.applicationId,
|
||||||
enabled: initialValues.enabled
|
enabled: initialValues.enabled
|
||||||
@ -162,14 +161,6 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理普通输入框的值变化
|
|
||||||
const handleInputChange = (key: string, value: string) => {
|
|
||||||
setBuildVariables(prev => ({
|
|
||||||
...prev,
|
|
||||||
[key]: value
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@ -199,7 +190,6 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
|||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={{
|
initialValues={{
|
||||||
enabled: true,
|
enabled: true,
|
||||||
sort: 0,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* 应用选择 */}
|
{/* 应用选择 */}
|
||||||
@ -271,46 +261,54 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({
|
|||||||
suggestOnTriggerCharacters: property.editorConfig.autoComplete ?? true,
|
suggestOnTriggerCharacters: property.editorConfig.autoComplete ?? true,
|
||||||
renderWhitespace: 'boundary',
|
renderWhitespace: 'boundary',
|
||||||
}}
|
}}
|
||||||
loading={
|
|
||||||
<div style={{
|
|
||||||
padding: '8px',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: '300px',
|
|
||||||
background: '#1e1e1e',
|
|
||||||
color: '#fff'
|
|
||||||
}}>
|
|
||||||
编辑器加载中...
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* 普通字段 */}
|
{/* 普通字段 */}
|
||||||
{Object.entries(selectedTemplate.buildVariablesSchema.properties)
|
<BetaSchemaForm
|
||||||
.filter(([_, property]) => !property.editorConfig)
|
layoutType="Embed"
|
||||||
.map(([key, property]) => (
|
columns={convertJsonSchemaToColumns({
|
||||||
<Form.Item
|
type: 'object',
|
||||||
key={key}
|
properties: Object.fromEntries(
|
||||||
label={property.title || key}
|
Object.entries(selectedTemplate.buildVariablesSchema.properties)
|
||||||
required={selectedTemplate.buildVariablesSchema.required?.includes(key)}
|
.filter(([_, prop]) => !prop.editorConfig)
|
||||||
tooltip={property.description}
|
.map(([key, prop]) => [
|
||||||
>
|
key,
|
||||||
<Input
|
{
|
||||||
value={buildVariables[key] || property.default || ''}
|
type: prop.type || 'string',
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleInputChange(key, e.target.value)}
|
title: prop.title,
|
||||||
placeholder={`请输入${property.title || key}`}
|
description: prop.description,
|
||||||
/>
|
default: prop.default,
|
||||||
</Form.Item>
|
enum: prop.enum,
|
||||||
))
|
enumNames: prop.enumNames,
|
||||||
}
|
format: prop.format,
|
||||||
|
minimum: prop.minimum,
|
||||||
|
maximum: prop.maximum,
|
||||||
|
minLength: prop.minLength,
|
||||||
|
maxLength: prop.maxLength,
|
||||||
|
pattern: prop.pattern,
|
||||||
|
items: prop.items && {
|
||||||
|
type: prop.items.type || 'string',
|
||||||
|
enum: prop.items.enum,
|
||||||
|
enumNames: prop.items.enumNames
|
||||||
|
}
|
||||||
|
}
|
||||||
|
])
|
||||||
|
),
|
||||||
|
required: selectedTemplate.buildVariablesSchema.required || []
|
||||||
|
})}
|
||||||
|
initialValues={buildVariables}
|
||||||
|
onValuesChange={(_, values) => setBuildVariables(prev => ({
|
||||||
|
...prev,
|
||||||
|
...values
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 状态和排序 */}
|
{/* 状态 */}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="enabled"
|
name="enabled"
|
||||||
label="状态"
|
label="状态"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user