Disable add menu if file system is not writable

This commit is contained in:
Alexandre de Souza 2025-09-05 17:19:46 -03:00
parent 82b7432da5
commit 79cb0e1132
No known key found for this signature in database
GPG key ID: E39228FFBA346545
2 changed files with 4 additions and 2 deletions

View file

@ -40,6 +40,7 @@ defmodule LivebookWeb.FileSelectComponent do
# Component default attribute values # Component default attribute values
inner_block: nil, inner_block: nil,
file_system_select_disabled: false, file_system_select_disabled: false,
writable: true,
on_submit: nil, on_submit: nil,
# State # State
current_dir: nil, current_dir: nil,
@ -119,11 +120,11 @@ defmodule LivebookWeb.FileSelectComponent do
</div> </div>
<.menu <.menu
id={"#{@id}-new-item-menu"} id={"#{@id}-new-item-menu"}
disabled={@file_system_select_disabled} disabled={@file_system_select_disabled or not @writable}
position="bottom-right" position="bottom-right"
> >
<:toggle> <:toggle>
<.icon_button tabindex="-1" aria-label="add"> <.icon_button disabled={not @writable} tabindex="-1" aria-label="add">
<.remix_icon icon="add-line" /> <.remix_icon icon="add-line" />
</.icon_button> </.icon_button>
</:toggle> </:toggle>

View file

@ -34,6 +34,7 @@ defmodule LivebookWeb.OpenLive.FileComponent do
file={@file} file={@file}
extnames={[LiveMarkdown.extension()]} extnames={[LiveMarkdown.extension()]}
running_files={files(@sessions)} running_files={files(@sessions)}
writable={writable?(@file_info)}
target={{__MODULE__, @id}} target={{__MODULE__, @id}}
> >
<div class="flex justify-end space-x-2"> <div class="flex justify-end space-x-2">