fix Hide bottom nav before sign-in

Render mobile navigation only for authenticated trainees.

Commit
8ce5f7157c31d9e2f7e0b517ee4e3c62f96526b3
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/web/pages.ml
index b91af358..482e910a 100644..100644
@@ -60,6 +60,23 @@
60 60 if workout_in_progress then nav_link Routes.workout "Current Workout"
61 61 else nav_link Routes.routine "Routine"
62 62 in
63 Added: let bottom_nav =
64 Added: match (trainee, request) with
65 Added: | Some _, Some _ ->
66 Added: [
67 Added: tag "nav"
68 Added: [
69 Added: class_ "bottom-nav";
70 Added: Dream_html.string_attr "aria-label" "Mobile navigation";
71 Added: ]
72 Added: [
73 Added: nav_link Routes.home "Home";
74 Added: mobile_middle;
75 Added: nav_link Routes.history "Log Book";
76 Added: ];
77 Added: ]
78 Added: | _ -> []
79 Added: in
63 80 tag "html" []
64 81 [
65 82 tag "head" []
@@ -76,40 +93,31 @@
76 93 ];
77 94 tag "body"
78 95 [ Dream_html.string_attr "class" "hito-app page-%s" active ]
79 Removed: [
80 Removed: tag "div"
81 Removed: [ class_ "app-shell" ]
82 Removed: [
83 Removed: tag "header"
84 Removed: [ class_ "masthead" ]
85 Removed: ([
86 Removed: tag "a"
87 Removed: [ class_ "brand"; href Routes.home ]
88 Removed: [
89 Removed: tag "span" [ class_ "brand-mark" ] [ txt "HD" ];
90 Removed: tag "span"
91 Removed: [ class_ "brand-copy" ]
92 Removed: [
93 Removed: tag "strong" [] [ txt "hito" ];
94 Removed: tag "small" []
95 Removed: [ txt "High Intensity Tracker Online" ];
96 Removed: ];
97 Removed: ];
98 Removed: ]
99 Removed: @ primary_nav @ account_area);
100 Removed: tag "main" [] [ tag "div" [ class_ "page-surface" ] content ];
101 Removed: ];
102 Removed: tag "nav"
103 Removed: [
104 Removed: class_ "bottom-nav";
105 Removed: Dream_html.string_attr "aria-label" "Mobile navigation";
106 Removed: ]
107 Removed: [
108 Removed: nav_link Routes.home "Home";
109 Removed: mobile_middle;
110 Removed: nav_link Routes.history "Log Book";
111 Removed: ];
112 Removed: ];
96 Added: ([
97 Added: tag "div"
98 Added: [ class_ "app-shell" ]
99 Added: [
100 Added: tag "header"
101 Added: [ class_ "masthead" ]
102 Added: ([
103 Added: tag "a"
104 Added: [ class_ "brand"; href Routes.home ]
105 Added: [
106 Added: tag "span" [ class_ "brand-mark" ] [ txt "HD" ];
107 Added: tag "span"
108 Added: [ class_ "brand-copy" ]
109 Added: [
110 Added: tag "strong" [] [ txt "hito" ];
111 Added: tag "small" []
112 Added: [ txt "High Intensity Tracker Online" ];
113 Added: ];
114 Added: ];
115 Added: ]
116 Added: @ primary_nav @ account_area);
117 Added: tag "main" [] [ tag "div" [ class_ "page-surface" ] content ];
118 Added: ];
119 Added: ]
120 Added: @ bottom_nav);
113 121 ]
114 122
115 123 let problem ~title ~detail =
test/test_web.ml
index db38fe43..fb5071d6 100644..100644
@@ -157,7 +157,10 @@
157 157 (contains ~substring:"lifter" (body overview));
158 158 Alcotest.(check bool)
159 159 "shows primary navigation" true
160 Removed: (contains ~substring:"primary-nav" (body overview)) );
160 Added: (contains ~substring:"primary-nav" (body overview));
161 Added: Alcotest.(check bool)
162 Added: "shows bottom navigation" true
163 Added: (contains ~substring:"bottom-nav" (body overview)) );
161 164 ( "the sign-in page renders a username field",
162 165 `Quick,
163 166 fun () ->
@@ -166,14 +169,17 @@
166 169 Alcotest.(check bool)
167 170 "has a username field" true
168 171 (contains ~substring:"name=\"username\"" page) );
169 Removed: ( "auth pages omit the primary navigation",
172 Added: ( "auth pages omit navigation",
170 173 `Quick,
171 174 fun () ->
172 175 let c = client () in
173 176 let page = body (get c "/register") in
174 177 Alcotest.(check bool)
175 178 "no primary navigation" false
176 Removed: (contains ~substring:"primary-nav" page) );
179 Added: (contains ~substring:"primary-nav" page);
180 Added: Alcotest.(check bool)
181 Added: "no bottom navigation" false
182 Added: (contains ~substring:"bottom-nav" page) );
177 183 ( "a form post without a CSRF token is refused",
178 184 `Quick,
179 185 fun () ->