Moves a file or a folder of the media library into another folder of its site, chosen by browsing the folders the way the library's own rail does.
Its own component because it reads its own folders, as the reader opens them, and answers its own clicks; the page only says what to move.
Usage
<.live_component
module={MishkaCmsCoreWeb.Live.Admin.Components.MediaMove}
id="media-move"
current_user={@current_user}
/>
send_update(MediaMove, id: "media-move", open: {:media, media_id})
send_update(MediaMove, id: "media-move", open: {:folder, folder_id})It opens on the folder the item is in, lists the folders inside the one being browsed with a path back up to the top level, and moves the item with "Move here" — through the resource's own update, as the reader, so the resource's rules decide: a folder never goes inside itself or one of its own folders, and the folder being moved is never listed, so nothing under it can be opened. A refusal is shown in the dialog, and it stays open.
A move that lands sends {:put_flash, :info, message} to the page and closes. The page hears the
write itself the way it hears anybody's — the row's own broadcast.