import React from "react";
|
import {
|
FormDataConsumer,
|
NumberInput,
|
SelectInput,
|
TextInput,
|
} from "react-admin";
|
import { Grid, Typography } from "@mui/material";
|
import StatusSelectInput from "@/page/components/StatusSelectInput";
|
|
const transportChoices = [
|
{ id: "SSE_HTTP", name: "SSE_HTTP" },
|
{ id: "STDIO", name: "STDIO" },
|
{ id: "BUILTIN", name: "BUILTIN" },
|
];
|
|
const AiMcpMountForm = ({ readOnly = false }) => (
|
<Grid container spacing={2} width={{ xs: "100%", xl: "80%" }}>
|
<Grid item xs={12}>
|
<Typography variant="h6">MCP 挂载配置</Typography>
|
</Grid>
|
<Grid item xs={12} md={6}>
|
<TextInput source="name" label="名称" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12} md={6}>
|
<SelectInput source="transportType" label="传输类型" choices={transportChoices} fullWidth disabled={readOnly} />
|
</Grid>
|
<FormDataConsumer>
|
{({ formData }) => (
|
<>
|
{formData.transportType === "BUILTIN" && (
|
<>
|
<Grid item xs={12}>
|
<SelectInput
|
source="builtinCode"
|
label="内置 MCP"
|
choices={[
|
{ id: "RSF_WMS", name: "RSF_WMS" },
|
{ id: "RSF_WMS_STOCK", name: "RSF_WMS_STOCK" },
|
{ id: "RSF_WMS_TASK", name: "RSF_WMS_TASK" },
|
{ id: "RSF_WMS_BASE", name: "RSF_WMS_BASE" },
|
]}
|
fullWidth
|
disabled={readOnly}
|
/>
|
</Grid>
|
</>
|
)}
|
{formData.transportType === "SSE_HTTP" && (
|
<>
|
<Grid item xs={12}>
|
<TextInput source="serverUrl" label="服务地址" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="endpoint" label="SSE Endpoint" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="headersJson" label="Headers JSON" fullWidth multiline minRows={4} disabled={readOnly} />
|
</Grid>
|
</>
|
)}
|
{formData.transportType === "STDIO" && (
|
<>
|
<Grid item xs={12}>
|
<TextInput source="command" label="命令" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="argsJson" label="Args JSON" fullWidth multiline minRows={4} disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="envJson" label="Env JSON" fullWidth multiline minRows={4} disabled={readOnly} />
|
</Grid>
|
</>
|
)}
|
</>
|
)}
|
</FormDataConsumer>
|
<Grid item xs={12} md={4}>
|
<NumberInput source="requestTimeoutMs" label="Timeout(ms)" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12} md={4}>
|
<NumberInput source="sort" label="排序" fullWidth disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12} md={4}>
|
<StatusSelectInput disabled={readOnly} />
|
</Grid>
|
<Grid item xs={12}>
|
<TextInput source="memo" label="备注" fullWidth multiline minRows={3} disabled={readOnly} />
|
</Grid>
|
</Grid>
|
);
|
|
export default AiMcpMountForm;
|