defmodule LivebookWeb.SessionLive.DeleteSessionComponent do
use LivebookWeb, :live_component
alias Livebook.SessionSupervisor
@impl true
def render(assigns) do
~L"""
Delete session
Are you sure you want to delete 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("delete", %{}, socket) do
SessionSupervisor.delete_session(socket.assigns.session_summary.session_id)
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
end
end