feat: benchmark detail actions
This commit is contained in:
@@ -3,7 +3,6 @@ import SealSelect from '@/components/seal-form/seal-select';
|
||||
import { PageAction } from '@/config';
|
||||
import useAppUtils from '@/hooks/use-app-utils';
|
||||
import { ClusterStatusValueMap } from '@/pages/cluster-management/config';
|
||||
import { useQueryClusterList } from '@/pages/cluster-management/services/use-query-cluster-list';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
@@ -15,13 +14,7 @@ const BasicForm: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const form = Form.useFormInstance();
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const { action, open } = useFormContext();
|
||||
const {
|
||||
loading: clusterLoading,
|
||||
fetchClusterList,
|
||||
cancelRequest: cancelClusterRequest,
|
||||
clusterList
|
||||
} = useQueryClusterList();
|
||||
const { action, open, clusterList } = useFormContext();
|
||||
|
||||
useEffect(() => {
|
||||
const initClusterId = (list: any[]) => {
|
||||
@@ -37,18 +30,14 @@ const BasicForm: React.FC = () => {
|
||||
|
||||
return cluster_id;
|
||||
};
|
||||
fetchClusterList({ page: -1 }).then((list) => {
|
||||
if (list.length > 0 && action === PageAction.CREATE) {
|
||||
form.setFieldValue('cluster_id', initClusterId(list));
|
||||
}
|
||||
});
|
||||
}, [form, action]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
cancelClusterRequest();
|
||||
if (
|
||||
clusterList &&
|
||||
clusterList?.length > 0 &&
|
||||
action === PageAction.CREATE
|
||||
) {
|
||||
form.setFieldValue('cluster_id', initClusterId(clusterList));
|
||||
}
|
||||
}, [open]);
|
||||
}, [form, action, clusterList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -78,7 +67,6 @@ const BasicForm: React.FC = () => {
|
||||
>
|
||||
<SealSelect
|
||||
disabled={action === PageAction.EDIT}
|
||||
loading={clusterLoading}
|
||||
options={clusterList}
|
||||
label={intl.formatMessage({ id: 'clusters.title' })}
|
||||
required
|
||||
|
||||
Reference in New Issue
Block a user