aboutsummaryrefslogtreecommitdiff
path: root/editor/actions/delete_page.ml
blob: 4730eeead87bda62ba5d2b2222c224d9878c310c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module App = Editor_app

module M = struct
  type t = unit

  let process : t -> State.t -> State.t =
   fun () state ->
    match state.page_id with
    | None -> state
    | Some page_id ->
        State.Storage.delete (fun () -> Some page_id);
        State.load_page None state
end

let create : unit -> App.event Note.event =
 fun () ->
  let title = Jstr.v "Confirmation"
  and message = Jstr.v "La page sera définitivement supprimée" in
  let ev =
    Elements.Popup.create ~title ~form:(Forms.Validation.create message) ()
  in
  Note.E.map (fun v -> App.dispatch (module M) v) (Note.E.Option.on_some ev)