Skip to content

Commit

Permalink
fix: incorrect current pipeline in onboard recollect (#7256)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet authored and abeizn committed Mar 29, 2024
1 parent ec4cab1 commit d27f5a5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config-ui/src/hooks/use-auto-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
36 changes: 30 additions & 6 deletions config-ui/src/routes/onboard/step-4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,18 @@ 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]);

const { data } = useAutoRefresh(
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));
Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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>.
Expand Down

0 comments on commit d27f5a5

Please sign in to comment.