Views.Job: Separated nested list-generation out into named functions
This commit is contained in:
parent
f0632dff6f
commit
5a6ce19c33
1 changed files with 64 additions and 54 deletions
42
lib/views.ml
42
lib/views.ml
|
@ -299,26 +299,20 @@ end
|
|||
|
||||
module Job = struct
|
||||
|
||||
let make ~failed ~job_name ~platform ~readme builds =
|
||||
layout
|
||||
~nav:(`Job (job_name, platform))
|
||||
~title:(Fmt.str "Job %s %a" job_name pp_platform platform)
|
||||
(
|
||||
(H.h1 [txtf "Job %s %a" job_name pp_platform platform] ::
|
||||
(match readme with
|
||||
let make_header ~job_name ~platform ~readme =
|
||||
H.h1 [txtf "Job %s %a" job_name pp_platform platform]
|
||||
:: (
|
||||
match readme with
|
||||
| None -> []
|
||||
| Some data ->
|
||||
[
|
||||
H.h2 ~a:H.[a_id "readme"] [H.txt "README"];
|
||||
H.a ~a:H.[a_href "#builds"] [H.txt "Skip to builds"];
|
||||
H.Unsafe.data (Utils.Omd.html_of_string data)
|
||||
])
|
||||
]
|
||||
)
|
||||
@ [
|
||||
H.h2 ~a:H.[a_id "builds"] [H.txt "Builds"];
|
||||
H.a ~a:H.[a_href "#readme"] [H.txt "Back to readme"];
|
||||
H.ul (
|
||||
builds |> List.map (fun (build, main_binary) ->
|
||||
|
||||
let make_build ~job_name (build, main_binary) =
|
||||
H.li (
|
||||
[
|
||||
check_icon build.Builder_db.Build.result;
|
||||
|
@ -341,8 +335,14 @@ module Job = struct
|
|||
~file:main_binary
|
||||
| None ->
|
||||
[ txtf "Build failure: %a" Builder.pp_execution_result
|
||||
build.Builder_db.Build.result ]))
|
||||
);
|
||||
build.Builder_db.Build.result ]
|
||||
)
|
||||
|
||||
let make_builds ~failed ~job_name builds =
|
||||
[
|
||||
H.h2 ~a:H.[a_id "builds"] [H.txt "Builds"];
|
||||
H.a ~a:H.[a_href "#readme"] [H.txt "Back to readme"];
|
||||
H.ul (builds |> List.map (make_build ~job_name));
|
||||
if failed then
|
||||
H.p [
|
||||
H.txt "Excluding failed builds " ;
|
||||
|
@ -353,7 +353,17 @@ module Job = struct
|
|||
H.txt "Including failed builds " ;
|
||||
H.a ~a:H.[a_href "failed/"] [H.txt "here"] ;
|
||||
H.txt "." ]
|
||||
])
|
||||
]
|
||||
|
||||
let make_body ~failed ~job_name ~platform ~readme builds =
|
||||
make_header ~job_name ~platform ~readme
|
||||
@ make_builds ~failed ~job_name builds
|
||||
|
||||
let make ~failed ~job_name ~platform ~readme builds =
|
||||
let nav = `Job (job_name, platform) in
|
||||
let title = Fmt.str "Job %s %a" job_name pp_platform platform in
|
||||
layout ~nav ~title @@ make_body ~failed ~job_name ~platform ~readme builds
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue