Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 78 additions & 25 deletions app/application.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1599,9 +1599,9 @@ end
let dismiss_toolbar ~test_id ~command dispatch body =
let close =
V.button
~role:Cancel
~style:Plain
~on_press:(bind_action dispatch command)
~child:(V.text "Close")
~child:(V.label ~title:(V.text "Close") ~icon:(V.symbol ~name:"xmark" ()) ())
()
|> V.with_test_id (Ui.Test_id.string test_id)
in
Expand Down Expand Up @@ -1810,6 +1810,7 @@ let media_label
?(detail = false)
state
dispatch
~title
~root
child
=
Expand All @@ -1818,6 +1819,7 @@ let media_label
~store
~on_region
~scope
~title
~root
~on_event:(fun event -> dispatch.send (Media (scope, event)))
child
Expand All @@ -1828,6 +1830,7 @@ let row_media_label
?(on_region = fun _ -> ())
state
dispatch
~title
~root
~image_children
child
Expand All @@ -1837,6 +1840,7 @@ let row_media_label
~store
~on_region
~scope
~title
~root
~image_children
~on_event:(fun event -> dispatch.send (Media (scope, event)))
Expand Down Expand Up @@ -2002,7 +2006,10 @@ let favorites_view
match favorite.target with
| Page id | Block id -> id
in
key, V.column ~key:(Ui.Key.string key) [ render_media ~root row ])
( key
, V.column
~key:(Ui.Key.string key)
[ render_media ~title:favorite.title ~root row ] ))
rows)
in
let footer =
Expand Down Expand Up @@ -2044,6 +2051,16 @@ type composer_assets =
; on_remove : string -> unit
}

let composer_can_submit ~capture ~saving ~enabled =
enabled
&& (not saving)
&& (Journal_capture.can_save capture
||
match Journal_capture.phase capture with
| Failed _ -> true
| _ -> false)
;;

let composer_content
~scope
~placeholder
Expand All @@ -2057,15 +2074,7 @@ let composer_content
~assets
=
let ignored = Ui.Event.Handler.create (fun _ -> ()) in
let can_submit =
enabled
&& (not saving)
&& (Journal_capture.can_save capture
||
match Journal_capture.phase capture with
| Failed _ -> true
| _ -> false)
in
let can_submit = composer_can_submit ~capture ~saving ~enabled in
let task_selected = Journal_capture.task_state capture = Journal_model.Todo in
let task =
(* Circular icon capsule matching the composer actions row — buttons has
Expand Down Expand Up @@ -2198,8 +2207,13 @@ let composer_page
~error
~assets
=
let can_submit = composer_can_submit ~capture ~saving ~enabled in
let close =
V.button ~role:Cancel ~on_press:on_close ~child:(V.text "Close") ()
V.button
~style:Plain
~on_press:on_close
~child:(V.label ~title:(V.text "Cancel") ~icon:(V.symbol ~name:"xmark" ()) ())
()
|> V.with_test_id (Ui.Test_id.string (scope ^ "-close"))
in
composer_content
Expand All @@ -2220,6 +2234,14 @@ let composer_page
~key:(Ui.Key.string "composer-close")
~placement:Cancellation_action
close
; V.Toolbar.item
~key:(Ui.Key.string "composer-submit")
~placement:Primary_action
(V.button
~enabled:can_submit
~on_press:on_save
~child:(V.text (if scope = "journal-append" then "Add" else "Send"))
())
]
;;

Expand Down Expand Up @@ -2592,7 +2614,8 @@ let diagnostics_page ~snapshot ~graph ~admission diagnostics dispatch =
Presentation.section
title
(List.map
(fun (label, value) -> Presentation.labeled label (V.text value))
(fun (label, value) ->
V.column ~spacing:4. ~alignment:Leading [ V.text label; V.text value ])
rows))
groups)
|> dismiss_toolbar
Expand Down Expand Up @@ -2819,6 +2842,7 @@ let detail_page
~detail:true
state
dispatch
~title:(Journal_model.source block)
~root:(Journal_model.id block))
(Journal_detail.rows detail)
in
Expand Down Expand Up @@ -2932,19 +2956,46 @@ let manager_page state dispatch =
"Diagnostics"
"stethoscope"
in
let toolbar title actions body =
let toolbar ?(sign_out = false) title actions body =
let account_menu =
V.buttons
~actions:
[ V.buttons_menu_action
~label:"Account menu"
~icon:"ellipsis"
~on_select:
(Ui.Event.Handler.create (function
| Ui.Event.Payload.Int64 1L -> dispatch.send Open_diagnostics
| Int64 2L when sign_out -> dispatch.send Sign_out
| _ -> ()))
([ V.Menu.action ~id:1L ~title:"Diagnostics" ~icon:"stethoscope" () ]
@
if sign_out
then
[ V.Menu.action
~id:2L
~title:"Sign out"
~icon:"rectangle.portrait.and.arrow.right"
()
]
else [])
]
()
|> V.with_test_id (Ui.Test_id.string "journal-startup-menu")
in
body
|> V.Body.toolbar
~items:
(V.Toolbar.item
~key:(Ui.Key.string "startup-title")
~placement:Principal
(V.text title)
:: V.Toolbar.item
~key:(Ui.Key.string "startup-diagnostics")
~placement:Secondary_action
diagnostics
:: actions)
((V.Toolbar.item
~key:(Ui.Key.string "startup-title")
~placement:Principal
(V.text title)
:: actions)
@ [ V.Toolbar.item
~key:(Ui.Key.string "startup-menu")
~placement:Primary_action
account_menu
])
in
let unavailable ~title ~symbol ~message ~actions =
Presentation.unavailable ~title ~symbol ~message ~actions
Expand Down Expand Up @@ -3012,6 +3063,7 @@ let manager_page state dispatch =
|> V.Body.with_test_id (Ui.Test_id.string "graph-picker-list")
in
toolbar
~sign_out:snapshot.startup.authenticated
"Choose a graph"
[ V.Toolbar.item
~key:(Ui.Key.string "graph-picker-refresh")
Expand Down Expand Up @@ -6123,13 +6175,14 @@ let start
~render_source:(render_source state)
~render_media:
(media_label ~store:media_store ~on_region:on_view_region state dispatch)
~render_row_media:(fun ~root ~image_children child ->
~render_row_media:(fun ~title ~root ~image_children child ->
on_view_region "timeline-row";
row_media_label
~store:media_store
~on_region:on_view_region
state
dispatch
~title
~root
~image_children
child)
Expand Down
36 changes: 28 additions & 8 deletions app/journal_media_view.ml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ let size_text size =

let view_content
~store
?title
?(on_region = fun _ -> ())
?(observed_roots = [])
?asset_root
Expand Down Expand Up @@ -526,15 +527,20 @@ let view_content
~equal:( = )
(function
| None -> L.column ~width:0 ~height:0 []
| Some ([ path ], _, false) ->
L.file_preview ~path ~on_dismiss:(fun _ -> close_preview ()) []
| Some (paths, selected_index, _) ->
| Some (paths, selected_index, image) ->
let payload =
Yojson.Safe.to_string
(`Assoc
[ "paths", `List (List.map (fun path -> `String path) paths)
; "selected_index", `Int selected_index
])
([ "paths", `List (List.map (fun path -> `String path) paths)
; "selected_index", `Int selected_index
]
@
if image
then []
else
[ "document", `Bool true
; "title", `String (Option.value title ~default:"Attachment")
]))
in
Journal_lui_native.image_preview
~payload
Expand Down Expand Up @@ -599,6 +605,7 @@ let reactive_structure store ~roots ~on_region build =

let view
~store
?title
?(on_region = fun _ -> ())
?(observed_roots = [])
?asset_root
Expand All @@ -612,6 +619,7 @@ let view
reactive_structure store ~roots ~on_region (fun () ->
view_content
~store
?title
~on_region
~observed_roots
?asset_root
Expand All @@ -627,6 +635,7 @@ let view
keep their lease/event owner, even when the parent references the same asset. *)
let row_content
~store
?title
?(on_region = fun _ -> ())
~scope
~root
Expand Down Expand Up @@ -717,6 +726,7 @@ let row_content
in
view_content
~store
?title
~on_region
~known_images:image_children
~observed_roots:(root :: List.map fst image_children)
Expand All @@ -728,10 +738,20 @@ let row_content
child
;;

let row ~store ?(on_region = fun _ -> ()) ~scope ~root ~image_children ~on_event child =
let row
~store
?title
?(on_region = fun _ -> ())
~scope
~root
~image_children
~on_event
child
=
reactive_structure
store
~roots:(root :: List.map fst image_children)
~on_region
(fun () -> row_content ~store ~on_region ~scope ~root ~image_children ~on_event child)
(fun () ->
row_content ~store ?title ~on_region ~scope ~root ~image_children ~on_event child)
;;
2 changes: 2 additions & 0 deletions app/journal_media_view.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type event =

val view
: store:Store.t
-> ?title:string
-> ?on_region:(string -> unit)
-> ?observed_roots:string list
-> ?asset_root:(string -> string)
Expand All @@ -47,6 +48,7 @@ val is_image_type : string -> bool
the root itself when it is an image asset. No runtime descriptor is required. *)
val row
: store:Store.t
-> ?title:string
-> ?on_region:(string -> unit)
-> scope:string
-> root:string
Expand Down
5 changes: 4 additions & 1 deletion app/journal_row.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ let view
else body ~render_source block
in
let content = V.column ~spacing:8. ~alignment:Leading (body :: metadata block) in
let labels = [ render_media ~root:id ~image_children content ] in
let labels =
[ render_media ~title:(Journal_model.source block) ~root:id ~image_children content ]
in
let labels =
labels
@ List.map
(fun (summary : Journal_graph_projection.child_summary) ->
render_media
~title:summary.source
~root:summary.block_id
~image_children:[]
(V.text (render_source summary.source)))
Expand Down
3 changes: 2 additions & 1 deletion app/journal_row.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
val view
: ?render_source:(string -> string)
-> render_media:
(root:string
(title:string
-> root:string
-> image_children:(string * string) list
-> Journal_view.View.t
-> Journal_view.View.t)
Expand Down
6 changes: 5 additions & 1 deletion app/journal_timeline.mli
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ val view
-> ?on_region:(string -> unit)
-> render_source:(string -> string)
-> render_media:
(root:string -> image_children:(string * string) list -> Ui.View.t -> Ui.View.t)
(title:string
-> root:string
-> image_children:(string * string) list
-> Ui.View.t
-> Ui.View.t)
-> state:Journal_timeline_state.t
-> day_presentation:(int -> Journal_calendar.date_presentation option)
-> on_visible_range:Ui.Event.Handler.t
Expand Down
Loading
Loading