You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2023/01/04 08:05:16 UTC

[incubator-devlake] branch main updated: fix: fix the bug in upgrade (#4097)

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

warren 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 1d1e4b6ad fix: fix the bug in upgrade (#4097)
1d1e4b6ad is described below

commit 1d1e4b6add430f16c27bf02fa2734c98041a7a0f
Author: Likyh <ya...@meri.co>
AuthorDate: Wed Jan 4 16:05:12 2023 +0800

    fix: fix the bug in upgrade (#4097)
    
    * fix: fix the bug in upgrade
    
    * fix: fix for review
---
 .../src/error/components/bp-upgrade/use-bp-upgrade.ts    | 16 ++++++++--------
 config-ui/src/utils/operator.ts                          |  1 +
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/config-ui/src/error/components/bp-upgrade/use-bp-upgrade.ts b/config-ui/src/error/components/bp-upgrade/use-bp-upgrade.ts
index 6daf1c4ed..0424be954 100644
--- a/config-ui/src/error/components/bp-upgrade/use-bp-upgrade.ts
+++ b/config-ui/src/error/components/bp-upgrade/use-bp-upgrade.ts
@@ -49,7 +49,7 @@ export const useBPUpgrade = ({ id, onResetError }: UseBPUpgradeProps) => {
       return {
         connectionId,
         githubId: res.id,
-        name: `${res.owner.login}/${it.name}`,
+        name: `${res.owner.login}/${res.name}`,
         ownerId: res.owner.id,
         language: res.language,
         description: res.description,
@@ -90,11 +90,11 @@ export const useBPUpgrade = ({ id, onResetError }: UseBPUpgradeProps) => {
   };
 
   const upgradeScope = async (plugin: string, connectionId: ID, scope: any) => {
-    let transfromationRule;
+    let transformationRule;
 
     if (scope.transformation) {
       // create transfromation template
-      transfromationRule = await API.createTransformation(plugin, {
+      transformationRule = await API.createTransformation(plugin, {
         ...scope.transformation,
         name: `upgrade-${plugin}-${connectionId}-${new Date().getTime()}`,
       });
@@ -104,13 +104,13 @@ export const useBPUpgrade = ({ id, onResetError }: UseBPUpgradeProps) => {
     const scopeDetail = await getScopeDetail(plugin, connectionId, scope.options);
 
     // put data scope
-    const res = await API.updateDataScope(plugin, connectionId, getScopeId(plugin, scopeDetail), {
+    await API.updateDataScope(plugin, connectionId, getScopeId(plugin, scopeDetail), {
       ...scopeDetail,
-      transformationRuleId: transfromationRule?.id,
+      transformationRuleId: transformationRule?.id,
     });
 
     return {
-      id: res.id,
+      id: `${getScopeId(plugin, scopeDetail)}`,
       entities: scope.entities,
     };
   };
@@ -118,11 +118,11 @@ export const useBPUpgrade = ({ id, onResetError }: UseBPUpgradeProps) => {
   const upgradeConnection = async (connection: any) => {
     const { plugin, connectionId } = connection;
 
-    const scope = await Promise.all(connection.scope.map((sc: any) => upgradeScope(plugin, connectionId, sc)));
+    const scopeList = await Promise.all(connection.scope.map((sc: any) => upgradeScope(plugin, connectionId, sc)));
     return {
       plugin,
       connectionId,
-      scope,
+      scopes: scopeList,
     };
   };
 
diff --git a/config-ui/src/utils/operator.ts b/config-ui/src/utils/operator.ts
index 5bcc8ea6f..4bc4eb507 100644
--- a/config-ui/src/utils/operator.ts
+++ b/config-ui/src/utils/operator.ts
@@ -49,6 +49,7 @@ export const operator = async <T>(request: () => Promise<T>, config?: OperateCon
     });
     return [true, res];
   } catch (err) {
+    console.error('Operation failed.', err)
     const reason = formatReason?.(err) ?? 'Operation failed.';
     Toast.show({
       intent: Intent.DANGER,