Hide terminate button if no more sessions (#3064)

Co-authored-by: José Valim <jose.valim@dashbit.co>
This commit is contained in:
Hugo Baraúna 2025-09-12 15:03:20 -03:00 committed by GitHub
parent e5281d8b21
commit fc08a42447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,7 +98,7 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
</h3>
<div class="flex flex-col mt-2 space-y-4">
<div :if={@app} class="flex flex-col space-y-3">
<div :if={app_has_sessions?(@app)} class="flex flex-col space-y-3">
<.labeled_text label="URL" one_line>
<a href={~p"/apps/#{@app.slug}"}>
{~p"/apps/#{@app.slug}"}
@ -118,9 +118,9 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
</div>
</div>
<div class={["grid gap-2", @app && "grid-cols-2"]}>
<div class={["grid gap-2", app_has_sessions?(@app) && "grid-cols-2"]}>
<span class="flex flex-col">
<%= if @app do %>
<%= if app_has_sessions?(@app) do %>
<.button color="gray" outlined phx-click="deploy_app">
<.remix_icon icon="slideshow-4-line" /> Relaunch
</.button>
@ -131,7 +131,7 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
<% end %>
</span>
<.button
:if={@app}
:if={app_has_sessions?(@app)}
color="red"
outlined
type="button"
@ -215,6 +215,10 @@ defmodule LivebookWeb.SessionLive.AppInfoComponent do
"""
end
defp app_has_sessions?(app) do
app && app.sessions != []
end
defp app_info_icon(assigns) do
~H"""
<span