File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 20
20
<SvgIcon name =" octicon-meter" class =" ui text yellow" class-name =" job-status-rotate" v-else-if =" job.status === 'running'" />
21
21
<SvgIcon name =" octicon-x-circle-fill" class =" red" v-else />
22
22
{{ 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" >
24
24
<SvgIcon name =" octicon-sync" class =" ui text black" />
25
25
</button >
26
26
</a >
@@ -163,7 +163,13 @@ const sfc = {
163
163
},
164
164
// rerun a job
165
165
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
+ });
167
173
},
168
174
// cancel a run
169
175
cancelRun () {
@@ -245,14 +251,18 @@ const sfc = {
245
251
}
246
252
},
247
253
248
- fetch (url , body ) {
254
+ fetch (url , body , callback ) {
249
255
return fetch (url, {
250
256
method: ' POST' ,
251
257
headers: {
252
258
' Content-Type' : ' application/json' ,
253
259
' X-Csrf-Token' : csrfToken,
254
260
},
255
261
body,
262
+ }).finally (() => {
263
+ if (callback) {
264
+ callback ();
265
+ }
256
266
});
257
267
},
258
268
},
You can’t perform that action at this time.
0 commit comments