Views.Job: Separated nested list-generation out into named functions

This commit is contained in:
rand00 2022-02-03 14:50:17 +01:00
parent f0632dff6f
commit 5a6ce19c33

View file

@ -299,26 +299,20 @@ end
module Job = struct module Job = struct
let make ~failed ~job_name ~platform ~readme builds = let make_header ~job_name ~platform ~readme =
layout H.h1 [txtf "Job %s %a" job_name pp_platform platform]
~nav:(`Job (job_name, platform)) :: (
~title:(Fmt.str "Job %s %a" job_name pp_platform platform) match readme with
(
(H.h1 [txtf "Job %s %a" job_name pp_platform platform] ::
(match readme with
| None -> [] | None -> []
| Some data -> | Some data ->
[ [
H.h2 ~a:H.[a_id "readme"] [H.txt "README"]; H.h2 ~a:H.[a_id "readme"] [H.txt "README"];
H.a ~a:H.[a_href "#builds"] [H.txt "Skip to builds"]; H.a ~a:H.[a_href "#builds"] [H.txt "Skip to builds"];
H.Unsafe.data (Utils.Omd.html_of_string data) H.Unsafe.data (Utils.Omd.html_of_string data)
]) ]
) )
@ [
H.h2 ~a:H.[a_id "builds"] [H.txt "Builds"]; let make_build ~job_name (build, main_binary) =
H.a ~a:H.[a_href "#readme"] [H.txt "Back to readme"];
H.ul (
builds |> List.map (fun (build, main_binary) ->
H.li ( H.li (
[ [
check_icon build.Builder_db.Build.result; check_icon build.Builder_db.Build.result;
@ -341,8 +335,14 @@ module Job = struct
~file:main_binary ~file:main_binary
| None -> | None ->
[ txtf "Build failure: %a" Builder.pp_execution_result [ 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 if failed then
H.p [ H.p [
H.txt "Excluding failed builds " ; H.txt "Excluding failed builds " ;
@ -353,7 +353,17 @@ module Job = struct
H.txt "Including failed builds " ; H.txt "Including failed builds " ;
H.a ~a:H.[a_href "failed/"] [H.txt "here"] ; H.a ~a:H.[a_href "failed/"] [H.txt "here"] ;
H.txt "." ] 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 end