Disable saving UI in app sessions (#2952)

This commit is contained in:
Jonatan Kłosko 2025-03-06 10:43:58 +01:00 committed by GitHub
parent 3eb574c1aa
commit 1a33c3000a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View file

@ -178,6 +178,11 @@ defmodule LivebookWeb.SessionLive do
%{select_secret_metadata: select_secret_metadata, prefill_secret_name: params["secret_name"]}}
end
defp handle_params(:file_settings, _params, _url, socket)
when socket.private.data.mode == :app do
{redirect_to_self(socket), %{}}
end
defp handle_params(live_action, params, _url, socket)
when live_action in [:app_settings, :file_settings] do
{socket, %{context: params["context"]}}

View file

@ -28,6 +28,7 @@ defmodule LivebookWeb.SessionLive.Render do
<div data-el-js-view-iframes phx-update="ignore" id="js-view-iframes"></div>
<.indicators
session_id={@session.id}
mode={@session.mode}
file={@data_view.file}
dirty={@data_view.dirty}
persistence_warnings={@data_view.persistence_warnings}
@ -1029,6 +1030,7 @@ defmodule LivebookWeb.SessionLive.Render do
>
<.view_indicator />
<.persistence_indicator
mode={@mode}
file={@file}
dirty={@dirty}
persistence_warnings={@persistence_warnings}
@ -1090,6 +1092,24 @@ defmodule LivebookWeb.SessionLive.Render do
"""
end
defp persistence_indicator(%{mode: :app} = assigns) do
~H"""
<span
class="tooltip left"
data-tooltip={
~S'''
This session is a deployed app. You can use it
for debugging, but changes are not persisted.
'''
}
>
<button class={[status_button_classes(:gray), "opacity-60"]} disabled>
<.remix_icon icon="save-line" />
</button>
</span>
"""
end
defp persistence_indicator(%{file: nil} = assigns) do
~H"""
<span class="tooltip left" data-tooltip="Choose a file to save the notebook">