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

likyh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new db2735c07 fix(config-ui): transformation type missed in plugin config 
(#4887)
db2735c07 is described below

commit db2735c077d1471e914eb32c93dd237b4e3357d2
Author: 青湛 <[email protected]>
AuthorDate: Tue Apr 11 00:07:58 2023 +0800

    fix(config-ui): transformation type missed in plugin config (#4887)
---
 .../blueprint/connection-add/components/step-1.tsx |  4 +++-
 .../pages/blueprint/create/components/step-1.tsx   | 26 +++++++++++++---------
 config-ui/src/plugins/types.ts                     |  2 +-
 config-ui/src/store/connections/types.ts           |  1 -
 .../src/store/connections/use-context-value.ts     |  4 +---
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/config-ui/src/pages/blueprint/connection-add/components/step-1.tsx 
b/config-ui/src/pages/blueprint/connection-add/components/step-1.tsx
index 3ab778a3c..2b92bfb6c 100644
--- a/config-ui/src/pages/blueprint/connection-add/components/step-1.tsx
+++ b/config-ui/src/pages/blueprint/connection-add/components/step-1.tsx
@@ -19,6 +19,7 @@
 import { Button, Intent } from '@blueprintjs/core';
 
 import { Table } from '@/components';
+import { getPluginConfig } from '@/plugins';
 import type { ConnectionItemType } from '@/store';
 import { ConnectionContextProvider, ConnectionContextConsumer } from '@/store';
 
@@ -44,6 +45,7 @@ export const Step1 = () => {
                 onChange: (selectedRowKeys) => {
                   const unique = selectedRowKeys[0];
                   const connection = connections.find((cs) => cs.unique === 
unique) as ConnectionItemType;
+                  const config = getPluginConfig(connection.plugin);
                   onChangeConnection({
                     unique: connection.unique,
                     plugin: connection.plugin,
@@ -52,7 +54,7 @@ export const Step1 = () => {
                     icon: connection.icon,
                     scope: [],
                     origin: [],
-                    transformationType: connection.transformationType,
+                    transformationType: config.transformationType,
                   });
                 },
               }}
diff --git a/config-ui/src/pages/blueprint/create/components/step-1.tsx 
b/config-ui/src/pages/blueprint/create/components/step-1.tsx
index 1533957a9..5234e56de 100644
--- a/config-ui/src/pages/blueprint/create/components/step-1.tsx
+++ b/config-ui/src/pages/blueprint/create/components/step-1.tsx
@@ -19,8 +19,9 @@
 import { useMemo } from 'react';
 import { InputGroup, Icon, Button, Intent } from '@blueprintjs/core';
 
-import { useConnection, ConnectionStatusEnum } from '@/store';
 import { Card, Divider, MultiSelector, Loading } from '@/components';
+import { getPluginConfig } from '@/plugins';
+import { useConnection, ConnectionStatusEnum } from '@/store';
 
 import { ModeEnum, FromEnum } from '../../types';
 import { AdvancedEditor } from '../../components';
@@ -91,16 +92,19 @@ export const Step1 = ({ from }: Props) => {
                   onTest(lastItem);
                 }
                 onChangeConnections(
-                  selectedItems.map((sc) => ({
-                    unique: sc.unique,
-                    plugin: sc.plugin,
-                    connectionId: sc.id,
-                    name: sc.name,
-                    icon: sc.icon,
-                    scope: [],
-                    origin: [],
-                    transformationType: sc.transformationType,
-                  })),
+                  selectedItems.map((sc) => {
+                    const config = getPluginConfig(sc.plugin);
+                    return {
+                      unique: sc.unique,
+                      plugin: sc.plugin,
+                      connectionId: sc.id,
+                      name: sc.name,
+                      icon: sc.icon,
+                      scope: [],
+                      origin: [],
+                      transformationType: config.transformationType,
+                    };
+                  }),
                 );
               }}
             />
diff --git a/config-ui/src/plugins/types.ts b/config-ui/src/plugins/types.ts
index 4b08014d3..7dfe2fd5e 100644
--- a/config-ui/src/plugins/types.ts
+++ b/config-ui/src/plugins/types.ts
@@ -35,6 +35,6 @@ export type PluginConfigType = {
     fields: any[];
   };
   entities: string[];
-  transformationType?: 'none' | 'for-connection' | 'for-scope';
   transformation: any;
+  transformationType?: 'none' | 'for-connection' | 'for-scope';
 };
diff --git a/config-ui/src/store/connections/types.ts 
b/config-ui/src/store/connections/types.ts
index b9a6a5b6b..f9c543b7d 100644
--- a/config-ui/src/store/connections/types.ts
+++ b/config-ui/src/store/connections/types.ts
@@ -31,7 +31,6 @@ export type ConnectionItemType = {
   name: string;
   icon: string;
   entities: string[];
-  transformationType: 'none' | 'for-connection' | 'for-scope';
   endpoint: string;
   proxy: string;
   token?: string;
diff --git a/config-ui/src/store/connections/use-context-value.ts 
b/config-ui/src/store/connections/use-context-value.ts
index 3301c7715..036790d54 100644
--- a/config-ui/src/store/connections/use-context-value.ts
+++ b/config-ui/src/store/connections/use-context-value.ts
@@ -57,14 +57,13 @@ export const useContextValue = ({ plugin, filterBeta = 
false, filter }: UseConte
 
     const resWithPlugin = res.map((cs, i) =>
       cs.map((it: any) => {
-        const { plugin, icon, entities, transformation, transformationType } = 
allConnections[i];
+        const { plugin, icon, entities } = allConnections[i];
 
         return {
           ...it,
           plugin,
           icon,
           entities,
-          transformationType: transformationType || (transformation ? 
'for-connection' : 'none'),
         };
       }),
     );
@@ -78,7 +77,6 @@ export const useContextValue = ({ plugin, filterBeta = false, 
filter }: UseConte
         name: it.name,
         icon: it.icon,
         entities: it.entities,
-        transformationType: it.transformationType,
         endpoint: it.endpoint,
         proxy: it.proxy,
         token: it.token,

Reply via email to