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

healchow 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 603009d1b [INLONG-5234][Dashboard] Some fields are missing when 
creating a new stream (#5236)
603009d1b is described below

commit 603009d1b3319c9abe7bce132efd957164abca91
Author: Daniel <[email protected]>
AuthorDate: Wed Jul 27 16:45:26 2022 +0800

    [INLONG-5234][Dashboard] Some fields are missing when creating a new stream 
(#5236)
---
 .../AccessDetail/DataStream/StreamItemModal.tsx    |   2 +-
 .../src/pages/AccessDetail/DataStream/config.tsx   | 125 +++++++++++----------
 2 files changed, 67 insertions(+), 60 deletions(-)

diff --git 
a/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx 
b/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
index cce7e998c..6e8b63779 100644
--- a/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
+++ b/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
@@ -84,7 +84,7 @@ export const genFormContent = (currentValues, inlongGroupId, 
mqType) => {
   ].map(item => {
     const obj = { ...item };
 
-    if (obj.name === 'inlongStreamId' || obj.name === 'dataSourceType' || 
obj.name === 'dataType') {
+    if (obj.name === 'inlongStreamId' || obj.name === 'dataType') {
       obj.type = 'text';
     }
 
diff --git a/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx 
b/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
index ef4f3c24c..af74d1760 100644
--- a/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
+++ b/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
@@ -17,8 +17,10 @@
  * under the License.
  */
 
+import React from 'react';
+import { Divider } from 'antd';
 import i18n from '@/i18n';
-import { genDataFields } from '@/components/AccessHelper';
+import { genBusinessFields, genDataFields } from '@/components/AccessHelper';
 
 export const getFilterFormContent = (defaultValues = {} as any) => [
   {
@@ -73,16 +75,18 @@ export const genFormContent = (editingId, currentValues, 
inlongGroupId, readonly
     readonly,
   };
 
+  const isCreate = editingId === true;
+
   return [
     ...genDataFields(
       [
-        // {
-        //   type: (
-        //     <Divider orientation="left">
-        //       {i18n.t('pages.AccessCreate.DataStream.config.Basic')}
-        //     </Divider>
-        //   ),
-        // },
+        isCreate && {
+          type: (
+            <Divider orientation="left">
+              {i18n.t('pages.AccessCreate.DataStream.config.Basic')}
+            </Divider>
+          ),
+        },
         'inlongStreamId',
         {
           label: 'Topic Name',
@@ -92,35 +96,36 @@ export const genFormContent = (editingId, currentValues, 
inlongGroupId, readonly
         },
         'name',
         'description',
-        // {
-        //   type: (
-        //     <Divider orientation="left">
-        //       {i18n.t('pages.AccessCreate.DataStream.config.DataInfo')}
-        //     </Divider>
-        //   ),
-        // },
-        // 'dataType',
-        // 'dataEncoding',
-        // 'dataSeparator',
-        // 'rowTypeFields',
-        // {
-        //   type: (
-        //     <Divider orientation="left">
-        //       {i18n.t('pages.AccessCreate.Business.config.AccessScale')}
-        //     </Divider>
-        //   ),
-        //   visible: mqType === 'PULSAR',
-        // },
+        isCreate && {
+          type: (
+            <Divider orientation="left">
+              {i18n.t('pages.AccessCreate.DataStream.config.DataInfo')}
+            </Divider>
+          ),
+        },
+        isCreate && 'dataType',
+        isCreate && 'dataEncoding',
+        isCreate && 'dataSeparator',
+        isCreate && 'rowTypeFields',
+        isCreate && {
+          type: (
+            <Divider orientation="left">
+              {i18n.t('pages.AccessCreate.Business.config.AccessScale')}
+            </Divider>
+          ),
+          visible: mqType === 'PULSAR',
+        },
       ],
       currentValues,
       extraParams,
     ),
-    // ...genBusinessFields(['dailyRecords', 'dailyStorage', 'peakRecords', 
'maxLength']).map(
-    //   item => ({
-    //     ...item,
-    //     visible: mqType === 'PULSAR',
-    //   }),
-    // ),
+    ...genBusinessFields(['dailyRecords', 'dailyStorage', 'peakRecords', 
'maxLength']).map(
+      item =>
+        isCreate && {
+          ...item,
+          visible: mqType === 'PULSAR',
+        },
+    ),
     // ...genDataFields(
     //   [
     //     {
@@ -136,35 +141,37 @@ export const genFormContent = (editingId, currentValues, 
inlongGroupId, readonly
     //   currentValues,
     //   extraParams,
     // ),
-  ].map(item => {
-    if (
-      (editingId === true && currentValues?.id === undefined) ||
-      (item.name === 'streamSink' && !readonly)
-    ) {
-      return item;
-    }
+  ]
+    .filter(Boolean)
+    .map(item => {
+      if (
+        (editingId === true && currentValues?.id === undefined) ||
+        (item.name === 'streamSink' && !readonly)
+      ) {
+        return item;
+      }
 
-    const obj = { ...item };
+      const obj = { ...item };
 
-    if (!editingId || editingId !== currentValues?.id) {
-      // Nothing is being edited, or the current line is not being edited
-      delete obj.extra;
-      delete obj.rules;
-      if (typeof obj.type === 'string') {
-        obj.type = 'text';
-        obj.props = { options: obj.props?.options };
-      }
+      if (!editingId || editingId !== currentValues?.id) {
+        // Nothing is being edited, or the current line is not being edited
+        delete obj.extra;
+        delete obj.rules;
+        if (typeof obj.type === 'string') {
+          obj.type = 'text';
+          obj.props = { options: obj.props?.options };
+        }
 
-      if ((obj.suffix as any)?.type) {
-        (obj.suffix as any).type = 'text';
-      }
-    } else {
-      // Current edit line
-      if (['inlongStreamId', 'dataSourceType', 'dataType'].includes(obj.name 
as string)) {
-        obj.type = 'text';
+        if ((obj.suffix as any)?.type) {
+          (obj.suffix as any).type = 'text';
+        }
+      } else {
+        // Current edit line
+        if (['inlongStreamId', 'dataSourceType', 'dataType'].includes(obj.name 
as string)) {
+          obj.type = 'text';
+        }
       }
-    }
 
-    return obj;
-  });
+      return obj;
+    });
 };

Reply via email to