Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rerun button of Actions #22798

Merged
merged 6 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<SvgIcon name="octicon-meter" class="ui text yellow" class-name="job-status-rotate" v-else-if="job.status === 'running'"/>
<SvgIcon name="octicon-x-circle-fill" class="red" v-else/>
{{ job.name }}
<button class="job-brief-rerun" @click="rerunJob(index)" v-if="job.canRerun">
<!-- TODO: it will be a better idea to move "button" out from "a", and the ".prevent" will not be needed. But it needs some work with CSS -->
<button class="job-brief-rerun" @click.prevent="rerunJob(index)" v-if="job.canRerun">
zeripath marked this conversation as resolved.
Show resolved Hide resolved
<SvgIcon name="octicon-sync" class="ui text black"/>
</button>
</a>
Expand Down Expand Up @@ -162,12 +163,14 @@ const sfc = {
}
},
// rerun a job
rerunJob(idx) {
this.fetch(`${this.run.link}/jobs/${idx}/rerun`);
async rerunJob(idx) {
const jobLink = `${this.run.link}/jobs/${idx}`;
await this.fetchPost(`${jobLink}/rerun`);
window.location.href = jobLink;
},
// cancel a run
cancelRun() {
this.fetch(`${this.run.link}/cancel`);
this.fetchPost(`${this.run.link}/cancel`);
},

createLogLine(line) {
Expand Down Expand Up @@ -205,7 +208,7 @@ const sfc = {
// for example: make cursor=null means the first time to fetch logs, cursor=eof means no more logs, etc
return {step: idx, cursor: it.cursor, expanded: it.expanded};
});
const resp = await this.fetch(
const resp = await this.fetchPost(
`${this.actionsURL}/runs/${this.runIndex}/jobs/${this.jobIndex}`,
JSON.stringify({logCursors}),
);
Expand Down Expand Up @@ -245,7 +248,7 @@ const sfc = {
}
},

fetch(url, body) {
fetchPost(url, body) {
return fetch(url, {
method: 'POST',
headers: {
Expand Down