Skip to content

Commit d27f5a5

Browse files
mintsweetabeizn
authored andcommitted
fix: incorrect current pipeline in onboard recollect (#7256)
1 parent ec4cab1 commit d27f5a5

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

config-ui/src/hooks/use-auto-refresh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const useAutoRefresh = <T>(
5757
});
5858
}, option?.interval ?? 5000);
5959
return () => clearInterval(timer.current);
60-
}, []);
60+
}, [...deps]);
6161

6262
useEffect(() => {
6363
if (option?.cancel?.(data) || (option?.retryLimit && option?.retryLimit <= retryCount.current)) {

config-ui/src/routes/onboard/step-4.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,18 @@ const getStatus = (data: any) => {
103103

104104
export const Step4 = () => {
105105
const [operating, setOperating] = useState(false);
106-
const [version, setVersion] = useState(0);
107106

108107
const navigate = useNavigate();
109108

110-
const { step, records, projectName, plugin } = useContext(Context);
109+
const { step, records, done, projectName, plugin, setRecords } = useContext(Context);
111110

112111
const record = useMemo(() => records.find((it) => it.plugin === plugin), [plugin, records]);
113112

114113
const { data } = useAutoRefresh(
115114
async () => {
116115
return await API.pipeline.subTasks(record?.pipelineId as string);
117116
},
118-
[version],
117+
[record],
119118
{
120119
cancel: (data) => {
121120
return !!(data && ['TASK_COMPLETED', 'TASK_PARTIAL', 'TASK_FAILED'].includes(data.status));
@@ -199,14 +198,39 @@ export const Step4 = () => {
199198
}
200199

201200
const [success] = await operator(
202-
() => API.blueprint.trigger(record.blueprintId, { skipCollectors: false, fullSync: false }),
201+
async () => {
202+
// 1. re trigger this bulueprint
203+
await API.blueprint.trigger(record.blueprintId, { skipCollectors: false, fullSync: false });
204+
205+
// 2. get current run pipeline
206+
const pipeline = await API.blueprint.pipelines(record.blueprintId);
207+
208+
const newRecords = records.map((it) =>
209+
it.plugin !== plugin
210+
? it
211+
: {
212+
...it,
213+
pipelineId: pipeline.pipelines[0].id,
214+
},
215+
);
216+
217+
setRecords(newRecords);
218+
219+
// 3. update store
220+
await API.store.set('onboard', {
221+
step: 4,
222+
records: newRecords,
223+
done,
224+
projectName,
225+
plugin,
226+
});
227+
},
203228
{
204229
setOperating,
205230
},
206231
);
207232

208233
if (success) {
209-
setVersion(version + 1);
210234
}
211235
};
212236

@@ -264,7 +288,7 @@ export const Step4 = () => {
264288
{status === 'failed' && (
265289
<div className="top">
266290
<div className="info">Something went wrong with the collection process.</div>
267-
<div className="tips">
291+
<div className="tip">
268292
Please verify your network connection and ensure your token's rate limits have not been exceeded, then
269293
attempt to collect the data again. Alternatively, you may report the issue by filing a bug on{' '}
270294
<ExternalLink link="https://github.com/apache/incubator-devlake/issues/new/choose">GitHub</ExternalLink>.

0 commit comments

Comments
 (0)