Skip to content

Commit 299b4b3

Browse files
committed
feat: Add property enableEditor
It is enabled by default: $ learn-ocaml build <=> $ learn-ocaml build --enable-editor unless we run the command line: $ learn-ocaml build --disable-editor
1 parent 828efb5 commit 299b4b3

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/app/learnocaml_config.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class type learnocaml_config = object
99
method enableTryocaml: bool Js.optdef_prop
1010
method enableLessons: bool Js.optdef_prop
1111
method enableExercises: bool Js.optdef_prop
12+
method enableEditor: bool Js.optdef_prop
1213
method enableToplevel: bool Js.optdef_prop
1314
method enablePlayground: bool Js.optdef_prop
1415
method txtLoginWelcome: Js.js_string Js.t Js.optdef_prop

src/app/learnocaml_config.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class type learnocaml_config = object
1313
method enableTryocaml: bool Js.optdef_prop
1414
method enableLessons: bool Js.optdef_prop
1515
method enableExercises: bool Js.optdef_prop
16+
method enableEditor: bool Js.optdef_prop
1617
method enableToplevel: bool Js.optdef_prop
1718
method enablePlayground: bool Js.optdef_prop
1819
method txtLoginWelcome: Js.js_string Js.t Js.optdef_prop

src/app/learnocaml_index_main.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,11 @@ let () =
694694
then [ "playground", ([%i"Playground"], playground_tab token) ] else []) @
695695
(match token with
696696
| Some t when Token.is_teacher t ->
697-
[ "teacher", ([%i"Teach"], teacher_tab t);
698-
"editor", ([%i"Editor"], editor_tab) ]
699-
| None ->
700-
(* FIXME: could be enabled only if desired at build time *)
697+
[ "teacher", ([%i"Teach"], teacher_tab t) ] @
698+
if get_opt config##.enableEditor then
699+
[ "editor", ([%i"Editor"], editor_tab) ]
700+
else []
701+
| None when get_opt config##.enableEditor ->
701702
[ "editor", ([%i"Editor"], editor_tab) ]
702703
| _ -> [])
703704
in

src/main/learnocaml_main.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ module Args = struct
173173
"the 'Lessons' tab (enabled by default if the repository contains a \
174174
$(i,lessons) directory)"
175175

176+
let editor = enable "editor"
177+
"the 'Editor' tab (enabled by default), for users connected with a \
178+
teacher token, or for all users if static deployment is used."
179+
176180
let exercises = enable "exercises"
177181
"the 'Exercises' tab (enabled by default if the repository contains an \
178182
$(i,exercises) directory)"
@@ -193,6 +197,7 @@ module Args = struct
193197
contents_dir: string;
194198
try_ocaml: bool option;
195199
lessons: bool option;
200+
editor: bool option;
196201
exercises: bool option;
197202
playground: bool option;
198203
toplevel: bool option;
@@ -201,10 +206,10 @@ module Args = struct
201206

202207
let builder_conf =
203208
let apply
204-
contents_dir try_ocaml lessons exercises playground toplevel base_url
205-
= { contents_dir; try_ocaml; lessons; exercises; playground; toplevel; base_url }
209+
contents_dir try_ocaml lessons editor exercises playground toplevel base_url
210+
= { contents_dir; try_ocaml; lessons; editor; exercises; playground; toplevel; base_url }
206211
in
207-
Term.(const apply $contents_dir $try_ocaml $lessons $exercises $playground $toplevel $base_url)
212+
Term.(const apply $contents_dir $try_ocaml $lessons $editor $exercises $playground $toplevel $base_url)
208213

209214
let repo_conf =
210215
let apply repo_dir exercises_filtered jobs =
@@ -372,13 +377,15 @@ let main o =
372377
\ enablePlayground: %b,\n\
373378
\ enableLessons: %b,\n\
374379
\ enableExercises: %b,\n\
380+
\ enableEditor: %b,\n\
375381
\ enableToplevel: %b,\n\
376382
\ baseUrl: \"%s\"\n\
377383
}\n"
378384
(tutorials_ret <> None)
379385
(playground_ret <> None)
380386
(lessons_ret <> None)
381387
(exercises_ret <> None)
388+
(o.builder.Builder.editor <> Some false)
382389
(o.builder.Builder.toplevel <> Some false)
383390
o.builder.Builder.base_url >>= fun () ->
384391
Lwt.return (tutorials_ret <> Some false && exercises_ret <> Some false)))

0 commit comments

Comments
 (0)