Skip to content

Commit fa6c3c1

Browse files
committed
fix: refresh page after rerun
1 parent f8c1e14 commit fa6c3c1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

web_src/js/components/RepoActionView.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
2121
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
2222
{{ job.name }}
23-
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
23+
<button class="job-brief-rerun" @click.prevent="rerunJob(index)" v-if="job.canRerun">
2424
<SvgIcon name="octicon-sync" class="ui text black"/>
2525
</button>
2626
</a>
@@ -163,7 +163,13 @@ const sfc = {
163163
},
164164
// rerun a job
165165
rerunJob(idx) {
166-
this.fetch(`${this.run.link}/jobs/${idx}/rerun`);
166+
const jobLink = `${this.run.link}/jobs/${idx}`;
167+
this.fetch(`${jobLink}/rerun`, null, () => {
168+
// The button to rerun job is under "a" tag, so the browser will refresh the page and cancel fetching "rerun".
169+
// However, it should refresh the page because the logs have been reset, or it's another job which has been clicked.
170+
// So we prevent the default behavior and refresh the page after the fetching is done.
171+
window.location.href = jobLink;
172+
});
167173
},
168174
// cancel a run
169175
cancelRun() {
@@ -245,14 +251,18 @@ const sfc = {
245251
}
246252
},
247253
248-
fetch(url, body) {
254+
fetch(url, body, callback) {
249255
return fetch(url, {
250256
method: 'POST',
251257
headers: {
252258
'Content-Type': 'application/json',
253259
'X-Csrf-Token': csrfToken,
254260
},
255261
body,
262+
}).finally(() => {
263+
if (callback) {
264+
callback();
265+
}
256266
});
257267
},
258268
},

0 commit comments

Comments
 (0)