defmodule LivebookWeb.HomeLive.CloseSessionComponent do
use LivebookWeb, :live_component
@impl true
def render(assigns) do
~H"""
Close session
Are you sure you want to close this section -
“<%= @session.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
Livebook.Session.close(socket.assigns.session.pid)
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
end
end