defmodule LivebookWeb.SessionLive.CloseSessionComponent do
use LivebookWeb, :live_component
alias Livebook.SessionSupervisor
@impl true
def render(assigns) do
~L"""
Close session
Are you sure you want to close this section -
“<%= @session_summary.notebook_name %>”?
This won't delete any persisted files.
<%= live_patch "Cancel", to: @return_to, class: "button button-outlined-gray" %>
"""
end
@impl true
def handle_event("close", %{}, socket) do
SessionSupervisor.close_session(socket.assigns.session_summary.session_id)
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
end
end