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

dockerzhang 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 8d9c23489 [INLONG-5213][Dashboard] Adapt to the new data structure of 
the stream list API (#5218)
8d9c23489 is described below

commit 8d9c2348926f1885dcb1470d8cc254f043024c1d
Author: Daniel <[email protected]>
AuthorDate: Tue Jul 26 17:23:04 2022 +0800

    [INLONG-5213][Dashboard] Adapt to the new data structure of the stream list 
API (#5218)
---
 .../src/components/StaffSelect/index.tsx           |  4 +-
 .../AccessDetail/DataStream/StreamItemModal.tsx    | 27 +++++++--
 .../src/pages/AccessDetail/DataStream/config.tsx   | 68 +++++++++++-----------
 inlong-dashboard/src/pages/Login/index.tsx         |  2 +-
 4 files changed, 58 insertions(+), 43 deletions(-)

diff --git a/inlong-dashboard/src/components/StaffSelect/index.tsx 
b/inlong-dashboard/src/components/StaffSelect/index.tsx
index 30b7559f9..81c5d08c0 100644
--- a/inlong-dashboard/src/components/StaffSelect/index.tsx
+++ b/inlong-dashboard/src/components/StaffSelect/index.tsx
@@ -105,10 +105,10 @@ const StaffSelect: React.FC<StaffSelectProps> = ({
   };
 
   const { data: staffList, loading, run: getStaffList } = useRequest(
-    (userName = '') => ({
+    (username = '') => ({
       url: '/user/listAll',
       params: {
-        userName,
+        username,
       },
     }),
     {
diff --git 
a/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx 
b/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
index bc8c3b5bf..cce7e998c 100644
--- a/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
+++ b/inlong-dashboard/src/pages/AccessDetail/DataStream/StreamItemModal.tsx
@@ -21,11 +21,11 @@ import React from 'react';
 import { Divider, Modal, message } from 'antd';
 import { ModalProps } from 'antd/es/modal';
 import FormGenerator, { useForm } from '@/components/FormGenerator';
-import { useUpdateEffect } from '@/hooks';
+import { useUpdateEffect, useRequest } from '@/hooks';
 import i18n from '@/i18n';
 import { genBusinessFields, genDataFields } from '@/components/AccessHelper';
 import request from '@/utils/request';
-import { valuesToData } from './helper';
+import { dataToValues, valuesToData } from './helper';
 import { pickObject } from '@/utils';
 
 export interface Props extends ModalProps {
@@ -60,6 +60,8 @@ export const genFormContent = (currentValues, inlongGroupId, 
mqType) => {
           ),
         },
         'dataType',
+        'dataEncoding',
+        'dataSeparator',
         'rowTypeFields',
         {
           type: (
@@ -92,6 +94,21 @@ export const genFormContent = (currentValues, inlongGroupId, 
mqType) => {
 
 const Comp: React.FC<Props> = ({ inlongGroupId, record, mqType, ...modalProps 
}) => {
   const [form] = useForm();
+
+  const { run: getStreamData } = useRequest(
+    {
+      url: '/stream/get',
+      params: {
+        groupId: inlongGroupId,
+        streamId: record.inlongStreamId,
+      },
+    },
+    {
+      manual: true,
+      onSuccess: result => form.setFieldsValue(dataToValues([result])?.[0]),
+    },
+  );
+
   const onOk = async () => {
     const values = {
       ...pickObject(['id', 'inlongGroupId', 'inlongStreamId', 'version'], 
record),
@@ -112,9 +129,9 @@ const Comp: React.FC<Props> = ({ inlongGroupId, record, 
mqType, ...modalProps })
     if (modalProps.visible) {
       // open
       form.resetFields(); // Note that it will cause the form to remount to 
initiate a select request
-    }
-    if (Object.keys(record || {})?.length) {
-      form.setFieldsValue(record);
+      if (Object.keys(record || {})?.length) {
+        getStreamData();
+      }
     }
   }, [modalProps.visible]);
 
diff --git a/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx 
b/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
index b0ae03a4e..ef4f3c24c 100644
--- a/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
+++ b/inlong-dashboard/src/pages/AccessDetail/DataStream/config.tsx
@@ -17,10 +17,8 @@
  * under the License.
  */
 
-import React from 'react';
-import { Divider } from 'antd';
 import i18n from '@/i18n';
-import { genBusinessFields, genDataFields } from '@/components/AccessHelper';
+import { genDataFields } from '@/components/AccessHelper';
 
 export const getFilterFormContent = (defaultValues = {} as any) => [
   {
@@ -78,13 +76,13 @@ export const genFormContent = (editingId, currentValues, 
inlongGroupId, readonly
   return [
     ...genDataFields(
       [
-        {
-          type: (
-            <Divider orientation="left">
-              {i18n.t('pages.AccessCreate.DataStream.config.Basic')}
-            </Divider>
-          ),
-        },
+        // {
+        //   type: (
+        //     <Divider orientation="left">
+        //       {i18n.t('pages.AccessCreate.DataStream.config.Basic')}
+        //     </Divider>
+        //   ),
+        // },
         'inlongStreamId',
         {
           label: 'Topic Name',
@@ -94,35 +92,35 @@ 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',
-        },
+        // {
+        //   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',
+        // },
       ],
       currentValues,
       extraParams,
     ),
-    ...genBusinessFields(['dailyRecords', 'dailyStorage', 'peakRecords', 
'maxLength']).map(
-      item => ({
-        ...item,
-        visible: mqType === 'PULSAR',
-      }),
-    ),
+    // ...genBusinessFields(['dailyRecords', 'dailyStorage', 'peakRecords', 
'maxLength']).map(
+    //   item => ({
+    //     ...item,
+    //     visible: mqType === 'PULSAR',
+    //   }),
+    // ),
     // ...genDataFields(
     //   [
     //     {
diff --git a/inlong-dashboard/src/pages/Login/index.tsx 
b/inlong-dashboard/src/pages/Login/index.tsx
index 07af19aaf..694e89f00 100644
--- a/inlong-dashboard/src/pages/Login/index.tsx
+++ b/inlong-dashboard/src/pages/Login/index.tsx
@@ -60,7 +60,7 @@ const Comp: React.FC = () => {
         dispatch({
           type: 'setUser',
           payload: {
-            userName: data === 'success' ? changedValues.username : null,
+            userName: data ? changedValues.username : null,
           },
         });
         localStorage.setItem('userName', changedValues.username + '');

Reply via email to