refactor: disable change type when edit monitor
This commit is contained in:
parent
108b4acc81
commit
64f33dd802
@ -29,6 +29,8 @@ export const MonitorInfoEditor: React.FC<MonitorInfoEditorProps> = React.memo(
|
|||||||
(props) => {
|
(props) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const typeValue = Form.useWatch('type', form);
|
const typeValue = Form.useWatch('type', form);
|
||||||
|
const initialValues = props.initialValues ?? defaultValues;
|
||||||
|
const isEdit = Boolean(initialValues.id);
|
||||||
|
|
||||||
const formEl = useMemo(() => {
|
const formEl = useMemo(() => {
|
||||||
const provider = getMonitorProvider(typeValue);
|
const provider = getMonitorProvider(typeValue);
|
||||||
@ -55,13 +57,13 @@ export const MonitorInfoEditor: React.FC<MonitorInfoEditorProps> = React.memo(
|
|||||||
preserve={false}
|
preserve={false}
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={props.initialValues ?? defaultValues}
|
initialValues={initialValues}
|
||||||
onFinish={handleSubmit}
|
onFinish={handleSubmit}
|
||||||
>
|
>
|
||||||
<Form.Item hidden name="id" />
|
<Form.Item hidden name="id" />
|
||||||
|
|
||||||
<Form.Item label="Monitor Type" name="type">
|
<Form.Item label="Monitor Type" name="type">
|
||||||
<Select>
|
<Select disabled={isEdit}>
|
||||||
{monitorProviders.map((m) => (
|
{monitorProviders.map((m) => (
|
||||||
<Select.Option key={m.name} value={m.name}>
|
<Select.Option key={m.name} value={m.name}>
|
||||||
{m.label}
|
{m.label}
|
||||||
|
Loading…
Reference in New Issue
Block a user