Skip to content

Commit 0d99de3

Browse files
committed
fix: rename to fetchPost and remove callback
1 parent 0fd90b4 commit 0d99de3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

web_src/js/components/RepoActionView.vue

+9-14
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,17 @@ const sfc = {
162162
}
163163
},
164164
// rerun a job
165-
rerunJob(idx) {
165+
async rerunJob(idx) {
166166
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+
await this.fetchPost(`${jobLink}/rerun`);
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;
173172
},
174173
// cancel a run
175174
cancelRun() {
176-
this.fetch(`${this.run.link}/cancel`);
175+
this.fetchPost(`${this.run.link}/cancel`);
177176
},
178177
179178
createLogLine(line) {
@@ -211,7 +210,7 @@ const sfc = {
211210
// for example: make cursor=null means the first time to fetch logs, cursor=eof means no more logs, etc
212211
return {step: idx, cursor: it.cursor, expanded: it.expanded};
213212
});
214-
const resp = await this.fetch(
213+
const resp = await this.fetchPost(
215214
`${this.actionsURL}/runs/${this.runIndex}/jobs/${this.jobIndex}`,
216215
JSON.stringify({logCursors}),
217216
);
@@ -251,18 +250,14 @@ const sfc = {
251250
}
252251
},
253252
254-
fetch(url, body, callback) {
253+
fetchPost(url, body) {
255254
return fetch(url, {
256255
method: 'POST',
257256
headers: {
258257
'Content-Type': 'application/json',
259258
'X-Csrf-Token': csrfToken,
260259
},
261260
body,
262-
}).finally(() => {
263-
if (callback) {
264-
callback();
265-
}
266261
});
267262
},
268263
},

0 commit comments

Comments
 (0)