- <%= render_editor(@cell, @cell_info) %>
+ <%= render_editor(assigns) %>
@@ -125,11 +125,11 @@ defmodule LivebookWeb.CellComponent do
- <%= render_editor(@cell, @cell_info, show_status: true) %>
+ <%= render_editor(assigns) %>
<%= if @cell.outputs != [] do %>
- <%= render_outputs(@cell.outputs, @cell.id) %>
+ <%= render_outputs(assigns) %>
<% end %>
@@ -137,10 +137,7 @@ defmodule LivebookWeb.CellComponent do
"""
end
- defp render_editor(cell, cell_info, opts \\ []) do
- show_status = Keyword.get(opts, :show_status, false)
- assigns = %{cell: cell, cell_info: cell_info, show_status: show_status}
-
+ defp render_editor(assigns) do
~L"""
- <%= if @show_status do %>
+ <%= if @cell.type == :elixir do %>
- <%= render_cell_status(@cell_info) %>
+ <%= render_cell_status(
+ @cell_info.validity_status,
+ @cell_info.evaluation_status,
+ @cell_info.digest != @cell_info.evaluation_digest
+ ) %>
<% end %>
@@ -207,14 +208,12 @@ defmodule LivebookWeb.CellComponent do
"""
end
- defp render_outputs(outputs, cell_id) do
- assigns = %{outputs: outputs, cell_id: cell_id}
-
+ defp render_outputs(assigns) do
~L"""
- <%= for {output, index} <- @outputs |> Enum.reverse() |> Enum.with_index(), output != :ignored do %>
+ <%= for {output, index} <- @cell.outputs |> Enum.reverse() |> Enum.with_index(), output != :ignored do %>
- <%= render_output(output, "#{@cell_id}-output#{index}") %>
+ <%= render_output(output, "#{@cell.id}-output#{index}") %>
<% end %>
@@ -274,33 +273,33 @@ defmodule LivebookWeb.CellComponent do
|> String.split("\n")
end
- defp render_cell_status(%{evaluation_status: :evaluating} = info) do
+ defp render_cell_status(_, :evaluating, changed) do
render_status_indicator(
"Evaluating",
"bg-blue-500",
"bg-blue-400",
- info.digest != info.evaluation_digest
+ changed
)
end
- defp render_cell_status(%{evaluation_status: :queued}) do
+ defp render_cell_status(_, :queued, _) do
render_status_indicator("Queued", "bg-gray-500", "bg-gray-400", false)
end
- defp render_cell_status(%{validity_status: :evaluated} = info) do
+ defp render_cell_status(:evaluated, _, changed) do
render_status_indicator(
"Evaluated",
"bg-green-400",
nil,
- info.digest != info.evaluation_digest
+ changed
)
end
- defp render_cell_status(%{validity_status: :stale} = info) do
- render_status_indicator("Stale", "bg-yellow-200", nil, info.digest != info.evaluation_digest)
+ defp render_cell_status(:stale, _, changed) do
+ render_status_indicator("Stale", "bg-yellow-200", nil, changed)
end
- defp render_cell_status(_), do: nil
+ defp render_cell_status(_, _, _), do: nil
defp render_status_indicator(text, circle_class, animated_circle_class, show_changed) do
assigns = %{
diff --git a/lib/livebook_web/live/insert_buttons_component.ex b/lib/livebook_web/live/insert_buttons_component.ex
index 9639dcd41..caaec7711 100644
--- a/lib/livebook_web/live/insert_buttons_component.ex
+++ b/lib/livebook_web/live/insert_buttons_component.ex
@@ -5,7 +5,24 @@ defmodule LivebookWeb.InsertButtonsComponent do
~L"""
hover:opacity-100 focus-within:opacity-100 flex space-x-2 justify-center items-center">
- <%= render_block(@inner_block) %>
+
+
+ <%= if @insert_section_index do %>
+
+ <% end %>
"""
diff --git a/lib/livebook_web/live/section_component.ex b/lib/livebook_web/live/section_component.ex
index f1842f250..8435cbaac 100644
--- a/lib/livebook_web/live/section_component.ex
+++ b/lib/livebook_web/live/section_component.ex
@@ -28,20 +28,11 @@ defmodule LivebookWeb.SectionComponent do
<%= for {cell, index} <- Enum.with_index(@section.cells) do %>
<%= live_component @socket, LivebookWeb.InsertButtonsComponent,
- persistent: false do %>
-
-
- <% end %>
+ id: "#{@section.id}:#{index}",
+ persistent: false,
+ section_id: @section.id,
+ insert_cell_index: index,
+ insert_section_index: nil %>
<%= live_component @socket, LivebookWeb.CellComponent,
id: cell.id,
session_id: @session_id,
@@ -49,24 +40,11 @@ defmodule LivebookWeb.SectionComponent do
cell_info: @cell_infos[cell.id] %>
<% end %>
<%= live_component @socket, LivebookWeb.InsertButtonsComponent,
- persistent: @section.cells == [] do %>
-
-
-
- <% end %>
+ id: "#{@section.id}:last",
+ persistent: @section.cells == [],
+ section_id: @section.id,
+ insert_cell_index: length(@section.cells),
+ insert_section_index: @index + 1 %>