defmodule LivebookWeb.SessionLive.DeleteSectionComponent do
use LivebookWeb, :live_component
@impl true
def render(assigns) do
~L"""
Delete section
Are you sure you want to delete this section -
“<%= @section.name %>”?
"""
end
@impl true
def handle_event("delete", params, socket) do
delete_cells? = Map.has_key?(params, "delete_cells")
Livebook.Session.delete_section(
socket.assigns.session_id,
socket.assigns.section.id,
delete_cells?
)
{:noreply, push_patch(socket, to: socket.assigns.return_to)}
end
end