From fd24f02780afc3e52d7c59011d7e3be5c2f6c867 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Tue, 21 May 2019 18:05:34 +0200 Subject: [PATCH] run: unify run status and classes logic --- src/components/rundetail.vue | 24 +++--------------------- src/components/runs.vue | 14 ++------------ src/util/run.js | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 33 deletions(-) create mode 100644 src/util/run.js diff --git a/src/components/rundetail.vue b/src/components/rundetail.vue index 6981b6e..cb66783 100644 --- a/src/components/rundetail.vue +++ b/src/components/rundetail.vue @@ -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"; diff --git a/src/components/runs.vue b/src/components/runs.vue index bc0e892..4fd715c 100644 --- a/src/components/runs.vue +++ b/src/components/runs.vue @@ -81,6 +81,7 @@