diff options
author | Robert Vollmert <rob@vllmrt.net> | 2019-07-31 16:48:50 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2019-08-07 16:19:20 +0200 |
commit | 1aeea2f97f36ffe3274f8684ba3ae0c932f1f8ff (patch) | |
tree | 3c44f7b978e433501c3274f05fd596e2c50385e2 /src | |
parent | fed15b83b0b54d17057733935eb53e94e1a2c926 (diff) | |
download | cuirass-1aeea2f97f36ffe3274f8684ba3ae0c932f1f8ff.tar cuirass-1aeea2f97f36ffe3274f8684ba3ae0c932f1f8ff.tar.gz |
Fix templates to handle all statuses.
* src/cuirass/templates.scm: Factor out class and title helpers
for build statuses, and handle all the statuses.
Diffstat (limited to 'src')
-rw-r--r-- | src/cuirass/templates.scm | 109 |
1 files changed, 33 insertions, 76 deletions
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm index ab1b85c..84097f0 100644 --- a/src/cuirass/templates.scm +++ b/src/cuirass/templates.scm @@ -103,6 +103,28 @@ ,body (hr))))) +(define (status-class status) + (cond + ((= (build-status scheduled) status) "oi oi-clock text-warning") + ((= (build-status started) status) "oi oi-reload text-warning") + ((= (build-status succeeded) status) "oi oi-check text-success") + ((= (build-status failed) status) "oi oi-x text-danger") + ((= (build-status failed-dependency) status) "oi oi-warning text-danger") + ((= (build-status failed-other) status) "oi oi-warning text-danger") + ((= (build-status canceled) status) "oi oi-question-mark text-warning") + (else "oi oi-warning text-danger"))) + +(define (status-title status) + (cond + ((= (build-status scheduled) status) "Scheduled") + ((= (build-status started) status) "Started") + ((= (build-status succeeded) status) "Succeeded") + ((= (build-status failed) status) "Failed") + ((= (build-status failed-dependency) status) "Failed (dependency)") + ((= (build-status failed-other) status) "Failed (other)") + ((= (build-status canceled) status) "Canceled") + (else "Invalid status"))) + (define (specifications-table specs) "Return HTML for the SPECS table." `((p (@ (class "lead")) "Specifications") @@ -128,29 +150,6 @@ (define (build-details build) "Return HTML showing details for the BUILD." (define status (assq-ref build #:status)) - (define display-status - (cond - ((= (build-status succeeded) status) - `(span (@ (class "oi oi-check text-success") - (title "Succeeded")) - " Success")) - ((= (build-status scheduled) status) - `(span (@ (class "oi oi-clock text-warning") - (title "Scheduled") - (aria-hidden "true")) - " Scheduled")) - ((= (build-status canceled) status) - `(span (@ (class "oi oi-question-mark text-warning") - (title "Canceled")) - " Canceled")) - ((= (build-status failed-dependency) status) - `(span (@ (class "oi oi-warning text-danger") - (title "Dependency failed")) - " Dependency failed")) - (else - `(span (@ (class "oi oi-x text-danger") - (title "Failed")) - " Failed")))) (define blocking-outputs (or (and-let* (((= (build-status failed-dependency) status)) (drv (false-if-exception @@ -172,7 +171,9 @@ (tr (th "Build ID") (td ,(assq-ref build #:id))) (tr (th "Status") - (td ,display-status + (td (span (@ (class ,(status-class status)) + (title ,(status-title status))) + ,(string-append " " (status-title status))) ,@(map (lambda (output) `((br) (a (@ (href ,(string-append "/log/" (basename output)))) @@ -361,32 +362,10 @@ and BUILD-MAX are global minimal and maximal (stoptime, rowid) pairs." (= (build-status failed) status))) `(tr - (td ,(cond - ((= (build-status succeeded) status) - `(span (@ (class "oi oi-check text-success") - (title "Succeeded") - (aria-hidden "true")) - "")) - ((= (build-status scheduled) status) - `(span (@ (class "oi oi-clock text-warning") - (title "Scheduled") - (aria-hidden "true")) - "")) - ((= (build-status canceled) status) - `(span (@ (class "oi oi-question-mark text-warning") - (title "Canceled") - (aria-hidden "true")) - "")) - ((= (build-status failed-dependency) status) - `(span (@ (class "oi oi-warning text-danger") - (title "Dependency failed") - (aria-hidden "true")) - "")) - (else - `(span (@ (class "oi oi-x text-danger") - (title "Failed") - (aria-hidden "true")) - "")))) + (td (span (@ (class ,(status-class status)) + (title ,(status-title status)) + (aria-hidden "true")) + "")) (th (@ (scope "row")) (a (@ (href "/build/" ,(assq-ref build #:id) "/details")) ,(assq-ref build #:id))) @@ -474,32 +453,10 @@ and BUILD-MAX are global minimal and maximal row identifiers." (= (build-status failed) status))) `(tr - (td ,(cond - ((= (build-status succeeded) status) - `(span (@ (class "oi oi-check text-success") - (title "Succeeded") - (aria-hidden "true")) - "")) - ((= (build-status scheduled) status) - `(span (@ (class "oi oi-clock text-warning") - (title "Scheduled") - (aria-hidden "true")) - "")) - ((= (build-status canceled) status) - `(span (@ (class "oi oi-question-mark text-warning") - (title "Canceled") - (aria-hidden "true")) - "")) - ((= (build-status failed-dependency) status) - `(span (@ (class "oi oi-warning text-danger") - (title "Dependency failed") - (aria-hidden "true")) - "")) - (else - `(span (@ (class "oi oi-x text-danger") - (title "Failed") - (aria-hidden "true")) - "")))) + (td (span (@ (class ,(status-class status)) + (title ,(status-title status)) + (aria-hidden "true")) + "")) (th (@ (scope "row")) (a (@ (href "/build/" ,(assq-ref build #:id) "/details")) ,(assq-ref build #:id))) |