defmodule LivebookWeb.SessionLive.AppInfoComponent do use LivebookWeb, :live_component import LivebookWeb.AppHelpers @impl true def render(assigns) do ~H"""

App

<.app_info_icon />
<%= if @session.mode == :app do %>
<.message_box kind={:info} message="This session is a running app. To deploy a modified version, you can fork it." />
<% else %>
<.link patch={~p"/sessions/#{@session.id}/settings/app"} class="button-base button-outlined-gray bg-transparent" > Configure
<%= if @app do %>

Latest deployment

<.labeled_text label="URL" one_line> <%= ~p"/apps/#{@app.slug}" %> <.labeled_text label="Version" one_line> v<%= @app.version %> <.labeled_text label="Session type" one_line> <%= if(@app.multi_session, do: "Multi", else: "Single") %>

Running sessions

<.labeled_text label="Status"> <.app_status status={app_session.app_status} /> <.labeled_text label="Version"> v<%= app_session.version %>
<.remix_icon icon="link" class="text-lg" />
<.remix_icon icon="terminal-line" class="text-lg" /> <%= if app_session.app_status.lifecycle == :active do %> <% else %> <% end %>
<% end %> <% end %>
""" end defp app_info_icon(assigns) do ~H""" <.remix_icon icon="question-line" class="text-xl leading-none" /> """ end @impl true def handle_event("terminate_app", %{}, socket) do {:noreply, confirm_app_termination(socket, socket.assigns.app.pid)} end def handle_event("terminate_app_session", %{"session_id" => session_id}, socket) do app_session = Enum.find(socket.assigns.app.sessions, &(&1.id == session_id)) Livebook.Session.close(app_session.pid) {:noreply, socket} end def handle_event("deactivate_app_session", %{"session_id" => session_id}, socket) do app_session = Enum.find(socket.assigns.app.sessions, &(&1.id == session_id)) Livebook.Session.app_deactivate(app_session.pid) {:noreply, socket} end end