refactor: disable change type when edit monitor

This commit is contained in:
moonrailgun 2023-10-29 01:25:09 +08:00
parent 108b4acc81
commit 64f33dd802

View File

@ -29,6 +29,8 @@ export const MonitorInfoEditor: React.FC<MonitorInfoEditorProps> = React.memo(
(props) => {
const [form] = Form.useForm();
const typeValue = Form.useWatch('type', form);
const initialValues = props.initialValues ?? defaultValues;
const isEdit = Boolean(initialValues.id);
const formEl = useMemo(() => {
const provider = getMonitorProvider(typeValue);
@ -55,13 +57,13 @@ export const MonitorInfoEditor: React.FC<MonitorInfoEditorProps> = React.memo(
preserve={false}
form={form}
layout="vertical"
initialValues={props.initialValues ?? defaultValues}
initialValues={initialValues}
onFinish={handleSubmit}
>
<Form.Item hidden name="id" />
<Form.Item label="Monitor Type" name="type">
<Select>
<Select disabled={isEdit}>
{monitorProviders.map((m) => (
<Select.Option key={m.name} value={m.name}>
{m.label}