run: unify run status and classes logic
This commit is contained in:
parent
26d5247846
commit
fd24f02780
|
@ -131,8 +131,8 @@
|
|||
import vClickOutside from "v-click-outside";
|
||||
|
||||
import { cancelRun, stopRun, restartRun } from "@/util/data.js";
|
||||
|
||||
import { userLocalRunLink, projectRunLink } from "@/util/link.js";
|
||||
import { runStatus, runResultClass } from "@/util/run.js";
|
||||
|
||||
export default {
|
||||
name: "RunDetail",
|
||||
|
@ -154,6 +154,8 @@ export default {
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
runStatus: runStatus,
|
||||
runResultClass: runResultClass,
|
||||
resetErrors() {
|
||||
this.stopRunError = null;
|
||||
this.cancelRunError = null;
|
||||
|
@ -162,26 +164,6 @@ export default {
|
|||
stillRunning(run) {
|
||||
return run.result != "unknown" && run.phase == "running";
|
||||
},
|
||||
runStatus(run) {
|
||||
if (run.phase != "finished") return run.phase;
|
||||
if (run.result != "unknown") return run.result;
|
||||
if (run.stopping) return "stopping";
|
||||
|
||||
return run.result;
|
||||
},
|
||||
runResultClass(run) {
|
||||
let status = this.runStatus(run);
|
||||
|
||||
if (status == "setuperror") return "setuperror";
|
||||
if (status == "queued") return "unknown";
|
||||
if (status == "cancelled") return "failed";
|
||||
if (status == "running") return "running";
|
||||
if (status == "stopping") return "failed";
|
||||
if (status == "stopped") return "failed";
|
||||
if (status == "success") return "success";
|
||||
if (status == "failed") return "failed";
|
||||
return "unknown";
|
||||
},
|
||||
taskClass(task) {
|
||||
if (task.status == "success") return "success";
|
||||
if (task.status == "failed") return "failed";
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<script>
|
||||
import { fetchUser, fetchProject, fetchRuns } from "@/util/data.js";
|
||||
import { userLocalRunLink, projectRunLink } from "@/util/link.js";
|
||||
import { runResultClass } from "@/util/run.js";
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
|
@ -109,24 +110,13 @@ export default {
|
|||
methods: {
|
||||
projectRunLink: projectRunLink,
|
||||
userLocalRunLink: userLocalRunLink,
|
||||
runResultClass: runResultClass,
|
||||
stillRunning(run) {
|
||||
return run.result != "unknown" && run.phase == "running";
|
||||
},
|
||||
waitingApproval(run) {
|
||||
return run.tasks_waiting_approval.length > 0;
|
||||
},
|
||||
runResultClass(run) {
|
||||
if (run.result == "unknown") {
|
||||
if (run.phase == "setuperror") return "setuperror";
|
||||
if (run.phase == "queued") return "unknown";
|
||||
if (run.phase == "cancelled") return "failed";
|
||||
if (run.phase == "running") return "running";
|
||||
}
|
||||
if (run.result == "success") return "success";
|
||||
if (run.result == "failed") return "failed";
|
||||
if (run.result == "stopped") return "failed";
|
||||
return "unknown";
|
||||
},
|
||||
update() {
|
||||
clearInterval(this.polling);
|
||||
if (this.projectref !== undefined) {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
export function runStatus(run) {
|
||||
// * if the run has a result then return the result
|
||||
// * if stopping return "stopping"
|
||||
// * return the phase
|
||||
if (run.result != "unknown") return run.result;
|
||||
if (run.stopping) return "stopping";
|
||||
if (run.phase != "finished") return run.phase;
|
||||
|
||||
return run.result;
|
||||
}
|
||||
|
||||
export function runResultClass(run) {
|
||||
let status = runStatus(run);
|
||||
|
||||
if (status == "setuperror") return "setuperror";
|
||||
if (status == "queued") return "unknown";
|
||||
if (status == "cancelled") return "failed";
|
||||
if (status == "running") return "running";
|
||||
if (status == "stopping") return "failed";
|
||||
if (status == "stopped") return "failed";
|
||||
if (status == "success") return "success";
|
||||
if (status == "failed") return "failed";
|
||||
return "unknown";
|
||||
}
|
Loading…
Reference in New Issue