1
This commit is contained in:
parent
78ea6f49d3
commit
d9cbbe93f1
@ -10,6 +10,7 @@ import DeploymentConfigModal from './components/DeploymentConfigModal';
|
||||
import {ProTable} from '@ant-design/pro-components';
|
||||
import type {ProColumns, ActionType} from '@ant-design/pro-components';
|
||||
import {Editor} from '@/components/Editor';
|
||||
import type {WorkflowDefinition} from '@/pages/Workflow/Definition/types';
|
||||
|
||||
const {Option} = Select;
|
||||
|
||||
@ -79,22 +80,28 @@ const DeploymentConfigList: React.FC = () => {
|
||||
const [templates, setTemplates] = useState<DeployConfigTemplate[]>([]);
|
||||
const [codePreviewVisible, setCodePreviewVisible] = useState(false);
|
||||
const [previewCode, setPreviewCode] = useState<{ code: string; language?: string }>({code: ''});
|
||||
const [loading, setLoading] = useState(true);
|
||||
const actionRef = React.useRef<ActionType>();
|
||||
|
||||
// 获取环境列表
|
||||
const fetchEnvironments = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await getEnvironmentList();
|
||||
setEnvironments(data);
|
||||
if (data.length > 0 && !selectedEnvId) {
|
||||
if (data.length > 0) {
|
||||
setSelectedEnvId(data[0].id);
|
||||
// 手动触发表格刷新
|
||||
actionRef.current?.reload();
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取环境列表失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取配置模板
|
||||
// 获取<EFBFBD><EFBFBD>置模板
|
||||
const fetchTemplates = async () => {
|
||||
try {
|
||||
const data = await getDeployConfigTemplates();
|
||||
@ -104,6 +111,7 @@ const DeploymentConfigList: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化数据
|
||||
useEffect(() => {
|
||||
fetchEnvironments();
|
||||
fetchTemplates();
|
||||
@ -240,13 +248,28 @@ const DeploymentConfigList: React.FC = () => {
|
||||
width: 150,
|
||||
copyable: true,
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: '应用名称',
|
||||
dataIndex: ['application', 'appName'],
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
title: '工作流',
|
||||
dataIndex: ['publishedWorkflowDefinition', 'name'],
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
render: (_, record) => {
|
||||
const workflow = record.publishedWorkflowDefinition;
|
||||
if (!workflow) return '-';
|
||||
return (
|
||||
<Tooltip title={`${workflow.name} (${workflow.key})`}>
|
||||
<span>{workflow.name}</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '构建配置',
|
||||
@ -309,6 +332,7 @@ const DeploymentConfigList: React.FC = () => {
|
||||
onChange={handleEnvChange}
|
||||
style={{width: 200}}
|
||||
placeholder="请选择环境"
|
||||
loading={loading}
|
||||
>
|
||||
{environments.map((env) => (
|
||||
<Option key={env.id} value={env.id}>
|
||||
@ -350,7 +374,7 @@ const DeploymentConfigList: React.FC = () => {
|
||||
showQuickJumper: true,
|
||||
}}
|
||||
request={async (params) => {
|
||||
if (!selectedEnvId) {
|
||||
if (!selectedEnvId || loading) {
|
||||
return {
|
||||
data: [],
|
||||
success: true,
|
||||
@ -363,6 +387,7 @@ const DeploymentConfigList: React.FC = () => {
|
||||
pageNum: params.current,
|
||||
environmentId: selectedEnvId,
|
||||
enabled: params.enabled as boolean,
|
||||
workflowDefinitionId: params.workflowDefinitionId as number
|
||||
};
|
||||
const data = await getDeploymentConfigPage(queryParams);
|
||||
return {
|
||||
|
||||
@ -4,6 +4,7 @@ import {Application} from '../../Application/List/types';
|
||||
import {DevelopmentLanguageTypeEnum} from '../../Application/List/types';
|
||||
import {BuildTypeEnum} from '../../Environment/List/types';
|
||||
import type {JsonNode} from '@/types/common';
|
||||
import type {WorkflowDefinition} from '@/pages/Workflow/Definition/types';
|
||||
|
||||
// 部署配置模板
|
||||
export interface DeployConfigTemplate {
|
||||
@ -23,6 +24,7 @@ export interface DeploymentConfig extends BaseResponse {
|
||||
buildType: BuildTypeEnum;
|
||||
languageType: DevelopmentLanguageTypeEnum;
|
||||
workflowDefinitionId: number;
|
||||
publishedWorkflowDefinition?: WorkflowDefinition;
|
||||
buildVariables: JsonNode;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user