defmodule LivebookWeb.SessionLive.ElixirCellSettingsComponent do use LivebookWeb, :live_component alias Livebook.Session @impl true def update(assigns, socket) do cell = assigns.cell socket = socket |> assign(assigns) |> assign_new(:disable_formatting, fn -> cell.disable_formatting end) {:ok, socket} end @impl true def render(assigns) do ~H"""

Cell settings

<.switch_checkbox name="disable_formatting" label="Disable code formatting (when saving to file)" checked={@disable_formatting} />
<%= live_patch "Cancel", to: @return_to, class: "button button-outlined-gray" %>
""" end @impl true def handle_event("save", %{"disable_formatting" => disable_formatting}, socket) do disable_formatting = disable_formatting == "true" Session.set_cell_attributes(socket.assigns.session_id, socket.assigns.cell.id, %{ disable_formatting: disable_formatting }) {:noreply, push_patch(socket, to: socket.assigns.return_to)} end end