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
163 changes: 54 additions & 109 deletions app/application.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2093,62 +2093,32 @@ module Favorites_list = struct
let rows =
List.map2
(fun key label ->
let label =
if Keys.mem key block_keys
then
V.Navigation_link.create
~key:(Ui.Key.string ("favorite-open:" ^ key))
~activation_id:key
~enabled:actions_enabled
~on_activate:
(Ui.Event.Handler.create (fun _ ->
Ui.Event.Handler.Private.invoke on_open (Ui.Event.Payload.Text key)))
~label
()
else label
in
let context_menu =
if Keys.mem key block_keys
then
Some
(V.Context_menu.create
~actions:
[ V.Context_menu.action
~key:(Ui.Key.string "copy")
~enabled:actions_enabled
~title:"Copy"
~symbol:"doc.on.doc"
~on_press:
(Ui.Event.Handler.create (fun _ ->
Ui.Event.Handler.Private.invoke
on_copy
(Ui.Event.Payload.Text key)))
()
]
())
else None
in
V.Native_list.row
~key:(Ui.Key.string key)
~separator:Hidden
?context_menu
label)
keys
children
let menu = if Keys.mem key block_keys then
[Lui_elements.context_menu
[Lui_elements.menu_item ~text:"Copy" ~icon:(`app "doc-on-doc")
~disabled:(not actions_enabled)
~on_press:(fun _ -> Ui.Event.Handler.Private.invoke on_copy
(Ui.Event.Payload.Text key)) []]]
else [] in
Lui_elements.list_item ~key ~separator:`hidden
~accessibility_identifier:("favorite-open:" ^ key)
~disabled:(not actions_enabled)
~on_press:(fun _ -> Ui.Event.Handler.Private.invoke on_open
(Ui.Event.Payload.Text key))
(Ui.mount label :: menu))
keys children
in
V.Native_list.vertical
~key:(Ui.Key.string "favorites-native-list")
~style:Plain
~on_visible_range
[ V.Native_list.section
~key:(Ui.Key.string "favorites")
~separator:Hidden
~footer
rows
]
|> V.Viewport.Vertical.with_test_id (Ui.Test_id.string "favorites-native-list")
|> V.Body.Vertical.fill
|> fun content -> V.Body.Vertical.create [ content ]
V.of_lui (Lui_elements.list ~key:"favorites-native-list" ~style:`plain ~grow:1.
~accessibility_identifier:"favorites-native-list" ~track_visible_range:true
~on_visible_range:(function
| Lui_protocol.VisibleRange (_,first,last) ->
Ui.Event.Handler.Private.invoke on_visible_range
(Ui.Event.Payload.Visible_range {first_index=Int64.of_int first;
last_exclusive=Int64.of_int last})
| _ -> ())
[Lui_elements.list_section ~key:"favorites" ~separator:`hidden
~footer:(Ui.mount footer) rows])
|> V.Body.static
;;
end

Expand All @@ -2162,8 +2132,7 @@ let render_title state =
;;

let favorites_view
~render_source
~render_media
~render_title
~state
~actions_enabled
~on_visible_range
Expand Down Expand Up @@ -2213,32 +2182,19 @@ let favorites_view
(fun value ->
let favorite = Journal_graph_projection.favorite value in
let key = favorite.membership_id in
let text =
V.text
(match favorite.target with
| Page _ -> favorite.title
| Block _ -> render_source favorite.title)
in
let label =
if favorite.task_state = Journal_model.No_status
then text
else
V.column
[ text; V.text (Journal_model.status_name favorite.task_state) ]
in
let row =
match favorite.target with
| Page _ -> V.label ~title:label ~icon:(V.symbol ~name:"doc.text" ()) ()
| Block _ -> label
in
let root =
match favorite.target with
| Page id | Block id -> id
in
( key
, V.column
~key:(Ui.Key.string key)
[ render_media ~title:favorite.title ~root row ] ))
let title = match favorite.target with
| Page _ -> Journal_model.Title.render favorite.title
| Block _ -> render_title favorite.title in
let icon = match favorite.target with
| Page _ -> V.symbol ~name:"doc.text" ()
| Block _ ->
V.stack [ Journal_symbols.create ~size:6. Dot ]
|> V.frame ~width:18. ~height:18. in
let label = V.label
~title:(V.of_lui (Lui_elements.text ~grow:1. ~text_alignment:`start
~style_class:"single-line" ~value:(Journal_model.Title.plain title) []))
~icon () in
key, label)
rows)
in
let footer =
Expand Down Expand Up @@ -2487,7 +2443,6 @@ let timeline_page
~on_region
~render_source
~render_title
~render_media
~render_row_media
~platform
~graph_generation
Expand Down Expand Up @@ -2565,8 +2520,7 @@ let timeline_page
then (
on_region "favorites";
favorites_view
~render_source
~render_media
~render_title
~state:favorites
~actions_enabled:interaction_enabled
~on_visible_range:on_favorites_visible_range
Expand Down Expand Up @@ -2930,7 +2884,7 @@ module Detail_list = struct
let context_menu =
V.Context_menu.create
~actions:
([ V.Context_menu.action
((if id = Journal_model.page_id block then [] else [ V.Context_menu.action
~key:(Ui.Key.string "open")
~title:"Open block"
~symbol:"arrow.up.right.square"
Expand All @@ -2944,7 +2898,7 @@ module Detail_list = struct
~symbol:"trash"
~on_press:delete
()
; V.Context_menu.action
]) @ [ V.Context_menu.action
~key:(Ui.Key.string "copy")
~enabled
~title:"Copy"
Expand Down Expand Up @@ -3055,10 +3009,18 @@ let detail_page
| Any_value (Internal_uuid uuid) -> Some (Graph.Uuid.to_string uuid)
| _ -> None
in
let property_parent_id block =
match Journal_model.parent_id block with
| Some _ as parent -> parent
| None when Journal_model.id block <> Journal_model.page_id block ->
Some (Journal_model.page_id block)
| None -> None
in
let owned_value property_uuid value =
Option.fold ~none:false ~some:(fun id ->
match Journal_detail.find_block detail ~block_id:id with
| Some child -> Journal_model.parent_id child = Some (Journal_model.id block)
| Some child -> property_parent_id child = Some (Journal_model.id block)
&& Journal_model.page_id child = Journal_model.page_id block
&& Option.fold ~none:false ~some:(Graph.Uuid.equal property_uuid) (created_from child)
| None -> false) (value_id value)
in
Expand All @@ -3070,7 +3032,7 @@ let detail_page
in
let property_name =
Option.bind (created_from block) (fun property_uuid ->
Option.bind (Journal_model.parent_id block) (fun parent_id ->
Option.bind (property_parent_id block) (fun parent_id ->
Option.bind (Journal_detail.find_block detail ~block_id:parent_id) (fun parent ->
List.find_map (fun (p : Graph.property_summary) ->
if Graph.Uuid.equal p.uuid property_uuid
Expand Down Expand Up @@ -5749,18 +5711,8 @@ let start
in
let first_index = bounded first_index in
let last_exclusive = max first_index (bounded last_exclusive) in
let roots =
Rrbvec.subvec snapshot.favorites_media_roots first_index last_exclusive
|> Option.get
|> Rrbvec.to_list
in
Journal_media_runtime.retain_visible_roots
~owner:(media_presentation_scope snapshot ~detail:false)
media_runtime
roots;
Effect.bind (flush_media set_state) ~f:(fun () ->
update (fun state ->
favorites_event state (Visible { first_index; last_exclusive })))
update (fun state ->
favorites_event state (Visible { first_index; last_exclusive }))
| Native_payload (Ui.Event.Payload.Visible_range _)
when Journal_routes.destination snapshot.routes = Journal_routes.Favorites ->
Effect.ignore
Expand Down Expand Up @@ -6913,8 +6865,6 @@ let start
~on_region:on_view_region
~render_source:(render_source state)
~render_title:(render_title state)
~render_media:
(media_label ~store:media_store ~on_region:on_view_region state dispatch)
~render_row_media:(fun ~title ~root ~image_children child ->
on_view_region "timeline-row";
row_media_label
Expand Down Expand Up @@ -7622,11 +7572,6 @@ module For_testing = struct
~on_region:(fun _ -> ())
~render_source:(render_source initial_state)
~render_title:(render_title initial_state)
~render_media:
(media_label
~store:(Journal_media_view.Store.create ())
initial_state
(ignore_dispatch handler))
~render_row_media:
(row_media_label
~store:(Journal_media_view.Store.create ())
Expand Down
6 changes: 5 additions & 1 deletion app/journal_detail.ml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ let matching_child pending ~root_id ~child ~parent =
command.block_id = Journal_model.id child
&& command.parent_block_id = Journal_model.id parent
&& command.parent_block_id = root_id
&& Journal_model.parent_id child = Some root_id
&& Journal_model.page_id child = Journal_model.page_id parent
&& (Journal_model.parent_id child = Some root_id
|| (Journal_model.id parent = Journal_model.page_id parent
&& Journal_model.page_id child = root_id
&& Journal_model.parent_id child = None))
| _ -> false
;;

Expand Down
Loading
Loading