This is an automated email from the ASF dual-hosted git repository.

leezng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 3ad3e463d [INLONG-6694][Dashboard] Create with filter value first, if 
there is a filter plugin (#6696)
3ad3e463d is described below

commit 3ad3e463d8ad981a982bccaa55efb9fa23b2ca3d
Author: Daniel <[email protected]>
AuthorDate: Thu Dec 1 15:06:06 2022 +0800

    [INLONG-6694][Dashboard] Create with filter value first, if there is a 
filter plugin (#6696)
---
 inlong-dashboard/src/pages/Clusters/CreateModal.tsx           |  7 +++++--
 inlong-dashboard/src/pages/Clusters/index.tsx                 |  1 +
 .../src/pages/GroupDetail/DataSources/DetailModal.tsx         |  7 ++++---
 inlong-dashboard/src/pages/GroupDetail/DataSources/index.tsx  |  1 +
 .../src/pages/GroupDetail/DataStorage/DetailModal.tsx         | 11 +++++------
 inlong-dashboard/src/pages/GroupDetail/DataStorage/index.tsx  |  1 +
 inlong-dashboard/src/pages/Nodes/DetailModal.tsx              |  7 +++++--
 inlong-dashboard/src/pages/Nodes/index.tsx                    |  1 +
 8 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/inlong-dashboard/src/pages/Clusters/CreateModal.tsx 
b/inlong-dashboard/src/pages/Clusters/CreateModal.tsx
index 7d692fbd5..1c442ae82 100644
--- a/inlong-dashboard/src/pages/Clusters/CreateModal.tsx
+++ b/inlong-dashboard/src/pages/Clusters/CreateModal.tsx
@@ -29,9 +29,10 @@ import i18n from '@/i18n';
 export interface Props extends ModalProps {
   // Require when edit
   id?: string;
+  defaultType?: string;
 }
 
-const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
+const Comp: React.FC<Props> = ({ id, defaultType, ...modalProps }) => {
   const [form] = useForm();
 
   const { defaultValue } = useDefaultMeta('cluster');
@@ -81,10 +82,12 @@ const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
     if (modalProps.visible) {
       if (id) {
         getData(id);
+      } else {
+        setType(defaultType);
+        form.setFieldsValue({ type: defaultType });
       }
     } else {
       form.resetFields();
-      setType(defaultValue);
     }
   }, [modalProps.visible]);
 
diff --git a/inlong-dashboard/src/pages/Clusters/index.tsx 
b/inlong-dashboard/src/pages/Clusters/index.tsx
index a50c56498..d9ece45a1 100644
--- a/inlong-dashboard/src/pages/Clusters/index.tsx
+++ b/inlong-dashboard/src/pages/Clusters/index.tsx
@@ -190,6 +190,7 @@ const Comp: React.FC = () => {
 
       <CreateModal
         {...createModal}
+        defaultType={options.type}
         visible={createModal.visible as boolean}
         onOk={async () => {
           await getList();
diff --git a/inlong-dashboard/src/pages/GroupDetail/DataSources/DetailModal.tsx 
b/inlong-dashboard/src/pages/GroupDetail/DataSources/DetailModal.tsx
index 6d6df52d0..1ba545076 100644
--- a/inlong-dashboard/src/pages/GroupDetail/DataSources/DetailModal.tsx
+++ b/inlong-dashboard/src/pages/GroupDetail/DataSources/DetailModal.tsx
@@ -30,9 +30,10 @@ export interface Props extends ModalProps {
   // When editing, use the ID to call the interface for obtaining details
   id?: string;
   inlongGroupId?: string;
+  defaultType?: string;
 }
 
-const Comp: React.FC<Props> = ({ id, inlongGroupId, ...modalProps }) => {
+const Comp: React.FC<Props> = ({ id, inlongGroupId, defaultType, ...modalProps 
}) => {
   const [form] = useForm();
   const { t } = useTranslation();
 
@@ -82,11 +83,11 @@ const Comp: React.FC<Props> = ({ id, inlongGroupId, 
...modalProps }) => {
       if (id) {
         getData(id);
       } else {
-        form.setFieldsValue({ inlongGroupId });
+        setType(defaultType);
+        form.setFieldsValue({ inlongGroupId, sourceType: defaultType });
       }
     } else {
       form.resetFields();
-      setType(defaultValue);
     }
   }, [modalProps.visible]);
 
diff --git a/inlong-dashboard/src/pages/GroupDetail/DataSources/index.tsx 
b/inlong-dashboard/src/pages/GroupDetail/DataSources/index.tsx
index 640df7aea..3f66b76fe 100644
--- a/inlong-dashboard/src/pages/GroupDetail/DataSources/index.tsx
+++ b/inlong-dashboard/src/pages/GroupDetail/DataSources/index.tsx
@@ -187,6 +187,7 @@ const Comp = ({ inlongGroupId, readonly }: Props, ref) => {
 
       <DetailModal
         {...createModal}
+        defaultType={options.sourceType}
         inlongGroupId={inlongGroupId}
         visible={createModal.visible as boolean}
         onOk={async () => {
diff --git a/inlong-dashboard/src/pages/GroupDetail/DataStorage/DetailModal.tsx 
b/inlong-dashboard/src/pages/GroupDetail/DataStorage/DetailModal.tsx
index bdeac7d9b..5d47c9934 100644
--- a/inlong-dashboard/src/pages/GroupDetail/DataStorage/DetailModal.tsx
+++ b/inlong-dashboard/src/pages/GroupDetail/DataStorage/DetailModal.tsx
@@ -23,24 +23,23 @@ import { ModalProps } from 'antd/es/modal';
 import { useRequest, useUpdateEffect } from '@/hooks';
 import { useTranslation } from 'react-i18next';
 import FormGenerator, { useForm } from '@/components/FormGenerator';
-import { useDefaultMeta, useLoadMeta, SinkMetaType } from '@/metas';
+import { useLoadMeta, SinkMetaType } from '@/metas';
 import request from '@/utils/request';
 
 export interface DetailModalProps extends ModalProps {
   inlongGroupId: string;
+  defaultType?: string;
   // (True operation, save and adjust interface) Need to upload when editing
   id?: string;
   // others
   onOk?: (values) => void;
 }
 
-const Comp: React.FC<DetailModalProps> = ({ inlongGroupId, id, ...modalProps 
}) => {
+const Comp: React.FC<DetailModalProps> = ({ inlongGroupId, defaultType, id, 
...modalProps }) => {
   const [form] = useForm();
 
   const { t } = useTranslation();
 
-  const { defaultValue } = useDefaultMeta('sink');
-
   // Q: Why sinkType default = '' ?
   // A: Avoid the table of the fields triggering the monitoring of the column 
change.
   const [sinkType, setSinkType] = useState('');
@@ -78,8 +77,8 @@ const Comp: React.FC<DetailModalProps> = ({ inlongGroupId, 
id, ...modalProps })
       if (id) {
         getData(id);
       } else {
-        form.setFieldsValue({ inlongGroupId });
-        setSinkType(defaultValue);
+        form.setFieldsValue({ inlongGroupId, sinkType: defaultType });
+        setSinkType(defaultType);
       }
     } else {
       form.resetFields();
diff --git a/inlong-dashboard/src/pages/GroupDetail/DataStorage/index.tsx 
b/inlong-dashboard/src/pages/GroupDetail/DataStorage/index.tsx
index aa56b9b5c..b03fb1095 100644
--- a/inlong-dashboard/src/pages/GroupDetail/DataStorage/index.tsx
+++ b/inlong-dashboard/src/pages/GroupDetail/DataStorage/index.tsx
@@ -182,6 +182,7 @@ const Comp = ({ inlongGroupId, readonly }: Props, ref) => {
 
       <DetailModal
         {...createModal}
+        defaultType={options.sinkType}
         inlongGroupId={inlongGroupId}
         visible={createModal.visible as boolean}
         onOk={async () => {
diff --git a/inlong-dashboard/src/pages/Nodes/DetailModal.tsx 
b/inlong-dashboard/src/pages/Nodes/DetailModal.tsx
index d98b3dd6f..621157118 100644
--- a/inlong-dashboard/src/pages/Nodes/DetailModal.tsx
+++ b/inlong-dashboard/src/pages/Nodes/DetailModal.tsx
@@ -31,9 +31,10 @@ const { useFindNodeDao, useSaveNodeDao } = dao;
 export interface Props extends ModalProps {
   // Require when edit
   id?: string;
+  defaultType?: string;
 }
 
-const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
+const Comp: React.FC<Props> = ({ id, defaultType, ...modalProps }) => {
   const [form] = useForm();
 
   const { defaultValue } = useDefaultMeta('node');
@@ -67,10 +68,12 @@ const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
       // open
       if (id) {
         getData(id);
+      } else {
+        form.setFieldsValue({ type: defaultType });
+        setType(defaultType);
       }
     } else {
       form.resetFields();
-      setType(defaultValue);
     }
   }, [modalProps.visible]);
 
diff --git a/inlong-dashboard/src/pages/Nodes/index.tsx 
b/inlong-dashboard/src/pages/Nodes/index.tsx
index e50b01fd5..01b282b11 100644
--- a/inlong-dashboard/src/pages/Nodes/index.tsx
+++ b/inlong-dashboard/src/pages/Nodes/index.tsx
@@ -162,6 +162,7 @@ const Comp: React.FC = () => {
 
       <DetailModal
         {...detailModal}
+        defaultType={options.type}
         visible={detailModal.visible as boolean}
         onOk={async () => {
           await getList();

Reply via email to