1
This commit is contained in:
parent
0b40047fc6
commit
f1f9ef0aab
@ -1,4 +1,4 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@ -11,6 +11,8 @@ import { BetaSchemaForm } from '@ant-design/pro-form';
|
||||
import { convertJsonSchemaToColumns } from '@/utils/jsonSchemaUtils';
|
||||
import { message } from 'antd';
|
||||
import type { DeploymentConfig } from '@/pages/Deploy/Deployment/List/types';
|
||||
import { deployApp } from '../service';
|
||||
import { DeployAppBuildDTO } from '../types';
|
||||
|
||||
interface DeploymentFormModalProps {
|
||||
open: boolean;
|
||||
@ -25,10 +27,21 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
formSchema,
|
||||
deployConfig
|
||||
}) => {
|
||||
const formRef = useRef<any>();
|
||||
|
||||
const handleSubmit = async (values: any) => {
|
||||
try {
|
||||
console.log('Form values:', values);
|
||||
// TODO: 调用部署接口
|
||||
const deployData: DeployAppBuildDTO = {
|
||||
buildType: deployConfig.buildType,
|
||||
languageType: deployConfig.languageType,
|
||||
formVariables: values,
|
||||
buildVariables: deployConfig.buildVariables,
|
||||
environmentId: deployConfig.environmentId,
|
||||
applicationId: deployConfig.application.id,
|
||||
workflowDefinitionId: deployConfig.publishedWorkflowDefinition?.id || 0
|
||||
};
|
||||
|
||||
await deployApp(deployData);
|
||||
message.success('部署任务已提交');
|
||||
onClose();
|
||||
} catch (error) {
|
||||
@ -46,19 +59,18 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
</DialogHeader>
|
||||
<div className="py-4">
|
||||
<BetaSchemaForm
|
||||
formRef={formRef}
|
||||
layoutType="Form"
|
||||
columns={columns}
|
||||
onFinish={handleSubmit}
|
||||
submitter={{
|
||||
render: false
|
||||
}}
|
||||
submitter={false}
|
||||
/>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={onClose}>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="submit" form="pro-form">
|
||||
<Button onClick={() => formRef.current?.submit()}>
|
||||
确定
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@ -35,6 +35,7 @@ import type {DeploymentConfig} from '@/pages/Deploy/Deployment/List/types';
|
||||
import type {Page} from '@/types/base';
|
||||
import type { JsonNode } from '@/types/common';
|
||||
import DeploymentFormModal from './components/DeploymentFormModal';
|
||||
import {message} from "antd";
|
||||
|
||||
type EnvironmentStatus = 'success' | 'warning' | 'error';
|
||||
|
||||
@ -236,7 +237,7 @@ const Dashboard: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleDeploy = (config: DeploymentConfig) => {
|
||||
if (!config.publishedWorkflowDefinition?.formVariablesSchema) {
|
||||
if (!config?.formVariablesSchema) {
|
||||
message.error('工作流配置有误,请检查工作流定义');
|
||||
return;
|
||||
}
|
||||
@ -433,14 +434,14 @@ const Dashboard: React.FC = () => {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{selectedConfig && selectedConfig.publishedWorkflowDefinition && (
|
||||
{selectedConfig && selectedConfig.formVariablesSchema && (
|
||||
<DeploymentFormModal
|
||||
open={deployModalOpen}
|
||||
onClose={() => {
|
||||
setDeployModalOpen(false);
|
||||
setSelectedConfig(null);
|
||||
}}
|
||||
formSchema={selectedConfig.publishedWorkflowDefinition.formVariablesSchema}
|
||||
formSchema={selectedConfig.formVariablesSchema}
|
||||
deployConfig={selectedConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
9
frontend/src/pages/Dashboard/service.ts
Normal file
9
frontend/src/pages/Dashboard/service.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { DeployAppBuildDTO } from './types';
|
||||
import request from "@/utils/request.ts";
|
||||
|
||||
/**
|
||||
* 部署应用
|
||||
* @param data 部署参数
|
||||
*/
|
||||
export const deployApp = (data: DeployAppBuildDTO) =>
|
||||
request.post<void>('/api/v1/deploy-app-config/deploy', data);
|
||||
38
frontend/src/pages/Dashboard/types.ts
Normal file
38
frontend/src/pages/Dashboard/types.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { JsonNode } from '@/types/common';
|
||||
|
||||
export interface DeployAppBuildDTO {
|
||||
/**
|
||||
* 构建类型
|
||||
*/
|
||||
buildType: string;
|
||||
|
||||
/**
|
||||
* 应用语言
|
||||
*/
|
||||
languageType: string;
|
||||
|
||||
/**
|
||||
* 表单配置
|
||||
*/
|
||||
formVariables?: JsonNode;
|
||||
|
||||
/**
|
||||
* 构建配置
|
||||
*/
|
||||
buildVariables: JsonNode;
|
||||
|
||||
/**
|
||||
* 环境ID
|
||||
*/
|
||||
environmentId: number;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
applicationId: number;
|
||||
|
||||
/**
|
||||
* 已发布的流程定义ID
|
||||
*/
|
||||
workflowDefinitionId: number;
|
||||
}
|
||||
@ -26,6 +26,7 @@ export interface DeploymentConfig extends BaseResponse {
|
||||
workflowDefinitionId: number;
|
||||
publishedWorkflowDefinition?: WorkflowDefinition;
|
||||
buildVariables: JsonNode;
|
||||
formVariablesSchema: JsonNode,
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user