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

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit d27f5a54f9f019a3ea19130fdf813958ef7e63aa
Author: 青湛 <[email protected]>
AuthorDate: Fri Mar 29 21:21:06 2024 +1300

    fix: incorrect current pipeline in onboard recollect (#7256)
---
 config-ui/src/hooks/use-auto-refresh.ts |  2 +-
 config-ui/src/routes/onboard/step-4.tsx | 36 +++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/config-ui/src/hooks/use-auto-refresh.ts 
b/config-ui/src/hooks/use-auto-refresh.ts
index b7e524097..fb49156e2 100644
--- a/config-ui/src/hooks/use-auto-refresh.ts
+++ b/config-ui/src/hooks/use-auto-refresh.ts
@@ -57,7 +57,7 @@ export const useAutoRefresh = <T>(
         });
     }, option?.interval ?? 5000);
     return () => clearInterval(timer.current);
-  }, []);
+  }, [...deps]);
 
   useEffect(() => {
     if (option?.cancel?.(data) || (option?.retryLimit && option?.retryLimit <= 
retryCount.current)) {
diff --git a/config-ui/src/routes/onboard/step-4.tsx 
b/config-ui/src/routes/onboard/step-4.tsx
index d54d3d105..556dbe3ca 100644
--- a/config-ui/src/routes/onboard/step-4.tsx
+++ b/config-ui/src/routes/onboard/step-4.tsx
@@ -103,11 +103,10 @@ const getStatus = (data: any) => {
 
 export const Step4 = () => {
   const [operating, setOperating] = useState(false);
-  const [version, setVersion] = useState(0);
 
   const navigate = useNavigate();
 
-  const { step, records, projectName, plugin } = useContext(Context);
+  const { step, records, done, projectName, plugin, setRecords } = 
useContext(Context);
 
   const record = useMemo(() => records.find((it) => it.plugin === plugin), 
[plugin, records]);
 
@@ -115,7 +114,7 @@ export const Step4 = () => {
     async () => {
       return await API.pipeline.subTasks(record?.pipelineId as string);
     },
-    [version],
+    [record],
     {
       cancel: (data) => {
         return !!(data && ['TASK_COMPLETED', 'TASK_PARTIAL', 
'TASK_FAILED'].includes(data.status));
@@ -199,14 +198,39 @@ export const Step4 = () => {
     }
 
     const [success] = await operator(
-      () => API.blueprint.trigger(record.blueprintId, { skipCollectors: false, 
fullSync: false }),
+      async () => {
+        // 1. re trigger this bulueprint
+        await API.blueprint.trigger(record.blueprintId, { skipCollectors: 
false, fullSync: false });
+
+        // 2. get current run pipeline
+        const pipeline = await API.blueprint.pipelines(record.blueprintId);
+
+        const newRecords = records.map((it) =>
+          it.plugin !== plugin
+            ? it
+            : {
+                ...it,
+                pipelineId: pipeline.pipelines[0].id,
+              },
+        );
+
+        setRecords(newRecords);
+
+        // 3. update store
+        await API.store.set('onboard', {
+          step: 4,
+          records: newRecords,
+          done,
+          projectName,
+          plugin,
+        });
+      },
       {
         setOperating,
       },
     );
 
     if (success) {
-      setVersion(version + 1);
     }
   };
 
@@ -264,7 +288,7 @@ export const Step4 = () => {
       {status === 'failed' && (
         <div className="top">
           <div className="info">Something went wrong with the collection 
process.</div>
-          <div className="tips">
+          <div className="tip">
             Please verify your network connection and ensure your token's rate 
limits have not been exceeded, then
             attempt to collect the data again. Alternatively, you may report 
the issue by filing a bug on{' '}
             <ExternalLink 
link="https://github.com/apache/incubator-devlake/issues/new/choose";>GitHub</ExternalLink>.

Reply via email to