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 148763a75 fix(config-ui): updated bp transformation not refresh (#4010)
148763a75 is described below

commit 148763a759da9a68ac8b1b08b882b320cae92881
Author: 青湛 <[email protected]>
AuthorDate: Thu Dec 22 11:08:39 2022 +0800

    fix(config-ui): updated bp transformation not refresh (#4010)
---
 .../src/pages/blueprint/detail/blueprint-detail.tsx   |  8 +++++---
 .../components/update-transformation-dialog/index.tsx | 14 ++++++++++++--
 .../pages/blueprint/detail/panel/configuration.tsx    | 19 ++++++++++---------
 config-ui/src/pages/blueprint/detail/use-detail.ts    |  3 ++-
 4 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/config-ui/src/pages/blueprint/detail/blueprint-detail.tsx 
b/config-ui/src/pages/blueprint/detail/blueprint-detail.tsx
index 91eb1061a..76b589e88 100644
--- a/config-ui/src/pages/blueprint/detail/blueprint-detail.tsx
+++ b/config-ui/src/pages/blueprint/detail/blueprint-detail.tsx
@@ -34,9 +34,10 @@ interface Props extends UseDetailProps {}
 export const BlueprintDetail = ({ id }: Props) => {
   const [activeTab, setActiveTab] = useState<TabId>('status')
 
-  const { loading, blueprint, connections, saving, onUpdate } = useDetail({
-    id
-  })
+  const { loading, blueprint, connections, saving, onUpdate, onRefresh } =
+    useDetail({
+      id
+    })
 
   if (loading || !blueprint) {
     return <PageLoading />
@@ -54,6 +55,7 @@ export const BlueprintDetail = ({ id }: Props) => {
             connections={connections}
             saving={saving}
             onUpdate={onUpdate}
+            onRefresh={onRefresh}
           />
         }
       />
diff --git 
a/config-ui/src/pages/blueprint/detail/components/update-transformation-dialog/index.tsx
 
b/config-ui/src/pages/blueprint/detail/components/update-transformation-dialog/index.tsx
index fc16400bf..9b153513f 100644
--- 
a/config-ui/src/pages/blueprint/detail/components/update-transformation-dialog/index.tsx
+++ 
b/config-ui/src/pages/blueprint/detail/components/update-transformation-dialog/index.tsx
@@ -26,13 +26,23 @@ import type { ConnectionItemType } from '../../types'
 interface Props {
   connection?: ConnectionItemType
   onCancel: () => void
+  onRefresh: () => void
 }
 
-export const UpdateTransformationDialog = ({ connection, onCancel }: Props) => 
{
+export const UpdateTransformationDialog = ({
+  connection,
+  onCancel,
+  onRefresh
+}: Props) => {
   if (!connection) return null
 
   const { plugin, connectionId, scopeIds } = connection
 
+  const handleSaveAfter = () => {
+    onRefresh()
+    onCancel()
+  }
+
   return (
     <Dialog
       isOpen
@@ -46,7 +56,7 @@ export const UpdateTransformationDialog = ({ connection, 
onCancel }: Props) => {
         connectionId={connectionId}
         scopeIds={scopeIds}
         onCancel={onCancel}
-        onSave={onCancel}
+        onSave={handleSaveAfter}
       />
     </Dialog>
   )
diff --git a/config-ui/src/pages/blueprint/detail/panel/configuration.tsx 
b/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
index 4903fa9b4..bef2c1ffc 100644
--- a/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
+++ b/config-ui/src/pages/blueprint/detail/panel/configuration.tsx
@@ -42,14 +42,16 @@ interface Props {
   blueprint: BlueprintType
   connections: ConnectionItemType[]
   saving: boolean
-  onUpdate: (bp: any) => Promise<void>
+  onUpdate: (bp: any) => void
+  onRefresh: () => void
 }
 
 export const Configuration = ({
   blueprint,
   connections,
   saving,
-  onUpdate
+  onUpdate,
+  onRefresh
 }: Props) => {
   const [type, setType] = useState<Type>()
   const [curConnection, setCurConnection] = useState<ConnectionItemType>()
@@ -75,11 +77,11 @@ export const Configuration = ({
 
   const handleUpdatePolicy = async (policy: any) => {
     await onUpdate(policy)
-    handleCancel
+    handleCancel()
   }
 
-  const handleUpdateConnection = async (updated: any) => {
-    await onUpdate({
+  const handleUpdateConnection = (updated: any) =>
+    onUpdate({
       settings: {
         version: '2.0.0',
         connections: blueprint.settings.connections.map((cs) =>
@@ -90,15 +92,13 @@ export const Configuration = ({
         )
       }
     })
-  }
 
-  const handleUpdatePlan = async () => {
-    await onUpdate({
+  const handleUpdatePlan = () =>
+    onUpdate({
       plan: !validRawPlan(rawPlan)
         ? JSON.parse(rawPlan)
         : JSON.stringify([[]], null, '  ')
     })
-  }
 
   const columns = useMemo(
     () =>
@@ -263,6 +263,7 @@ export const Configuration = ({
         <UpdateTransformationDialog
           connection={curConnection}
           onCancel={handleCancel}
+          onRefresh={onRefresh}
         />
       )}
     </S.ConfigurationPanel>
diff --git a/config-ui/src/pages/blueprint/detail/use-detail.ts 
b/config-ui/src/pages/blueprint/detail/use-detail.ts
index 78189e1c7..26c24e101 100644
--- a/config-ui/src/pages/blueprint/detail/use-detail.ts
+++ b/config-ui/src/pages/blueprint/detail/use-detail.ts
@@ -99,7 +99,8 @@ export const useDetail = ({ id }: UseDetailProps) => {
       saving,
       blueprint,
       connections,
-      onUpdate: handleUpdate
+      onUpdate: handleUpdate,
+      onRefresh: getBlueprint
     }),
     [loading, saving, blueprint, connections]
   )

Reply via email to