Move build-status helpers to the html-utils module
This commit is contained in:
parent
e078b9611d
commit
716eb3c3b6
4 changed files with 34 additions and 31 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
(define-module (guix-data-service web build html)
|
(define-module (guix-data-service web build html)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (guix-data-service web query-parameters)
|
#:use-module (guix-data-service web query-parameters)
|
||||||
|
#:use-module (guix-data-service web html-utils)
|
||||||
#:use-module (guix-data-service web view html)
|
#:use-module (guix-data-service web view html)
|
||||||
#:export (view-builds))
|
#:export (view-builds))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,10 @@
|
||||||
|
|
||||||
(define-module (guix-data-service web html-utils)
|
(define-module (guix-data-service web html-utils)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:export (sexp-div))
|
#:export (sexp-div
|
||||||
|
|
||||||
|
build-status-value->display-string
|
||||||
|
build-status-span))
|
||||||
|
|
||||||
(define (sexp-div sexp)
|
(define (sexp-div sexp)
|
||||||
(match sexp
|
(match sexp
|
||||||
|
|
@ -33,3 +36,31 @@
|
||||||
,hash))
|
,hash))
|
||||||
((and string val)
|
((and string val)
|
||||||
val)))
|
val)))
|
||||||
|
|
||||||
|
(define (build-status-value->display-string value)
|
||||||
|
(assoc-ref
|
||||||
|
'(("scheduled" . "Scheduled")
|
||||||
|
("started" . "Started")
|
||||||
|
("succeeded" . "Succeeded")
|
||||||
|
("failed" . "Failed")
|
||||||
|
("failed-dependency" . "Failed (dependency)")
|
||||||
|
("failed-other" . "Failed (other)")
|
||||||
|
("canceled" . "Canceled")
|
||||||
|
("" . "Unknown"))
|
||||||
|
value))
|
||||||
|
|
||||||
|
(define (build-status-span status)
|
||||||
|
`(span (@ (class ,(string-append
|
||||||
|
"label label-"
|
||||||
|
(assoc-ref
|
||||||
|
'(("scheduled" . "info")
|
||||||
|
("started" . "primary")
|
||||||
|
("succeeded" . "success")
|
||||||
|
("failed" . "danger")
|
||||||
|
("failed-dependency" . "warning")
|
||||||
|
("failed-other" . "danger")
|
||||||
|
("canceled" . "default")
|
||||||
|
("" . "default"))
|
||||||
|
status)))
|
||||||
|
(style "display: inline-block; font-size: 1.2em; margin-top: 0.4em;"))
|
||||||
|
,(build-status-value->display-string status)))
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#:use-module (texinfo html)
|
#:use-module (texinfo html)
|
||||||
#:use-module (json)
|
#:use-module (json)
|
||||||
#:use-module (guix-data-service web util)
|
#:use-module (guix-data-service web util)
|
||||||
|
#:use-module (guix-data-service web html-utils)
|
||||||
#:use-module (guix-data-service web query-parameters)
|
#:use-module (guix-data-service web query-parameters)
|
||||||
#:use-module (guix-data-service web view html)
|
#:use-module (guix-data-service web view html)
|
||||||
#:export (view-revision-news
|
#:export (view-revision-news
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@
|
||||||
display-possible-store-item
|
display-possible-store-item
|
||||||
display-store-item
|
display-store-item
|
||||||
display-store-item-short
|
display-store-item-short
|
||||||
build-status-value->display-string
|
|
||||||
build-status-span
|
|
||||||
|
|
||||||
table/branches-with-most-recent-commits
|
table/branches-with-most-recent-commits
|
||||||
|
|
||||||
|
|
@ -359,34 +357,6 @@
|
||||||
"No information yet")))))))))
|
"No information yet")))))))))
|
||||||
branches-with-most-recent-commits))))
|
branches-with-most-recent-commits))))
|
||||||
|
|
||||||
(define (build-status-value->display-string value)
|
|
||||||
(assoc-ref
|
|
||||||
'(("scheduled" . "Scheduled")
|
|
||||||
("started" . "Started")
|
|
||||||
("succeeded" . "Succeeded")
|
|
||||||
("failed" . "Failed")
|
|
||||||
("failed-dependency" . "Failed (dependency)")
|
|
||||||
("failed-other" . "Failed (other)")
|
|
||||||
("canceled" . "Canceled")
|
|
||||||
("" . "Unknown"))
|
|
||||||
value))
|
|
||||||
|
|
||||||
(define (build-status-span status)
|
|
||||||
`(span (@ (class ,(string-append
|
|
||||||
"label label-"
|
|
||||||
(assoc-ref
|
|
||||||
'(("scheduled" . "info")
|
|
||||||
("started" . "primary")
|
|
||||||
("succeeded" . "success")
|
|
||||||
("failed" . "danger")
|
|
||||||
("failed-dependency" . "warning")
|
|
||||||
("failed-other" . "danger")
|
|
||||||
("canceled" . "default")
|
|
||||||
("" . "default"))
|
|
||||||
status)))
|
|
||||||
(style "display: inline-block; font-size: 1.2em; margin-top: 0.4em;"))
|
|
||||||
,(build-status-value->display-string status)))
|
|
||||||
|
|
||||||
(define (display-possible-store-item value)
|
(define (display-possible-store-item value)
|
||||||
(match (string-split value #\/)
|
(match (string-split value #\/)
|
||||||
(("" "gnu" "store" item)
|
(("" "gnu" "store" item)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue