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 %>”?

Options

<%# If there is no previous section, all cells need to be deleted %> <%= render_switch("delete_cells", @is_first, "Delete all cells in this section", disabled: @is_first) %>
<%= live_patch "Cancel", to: @return_to, class: "button button-outlined-gray" %>
""" 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