<%= if @installing? do %>
Waiting for dependency installation to complete...
<% else %>
Run the notebook setup to show the contents of this Smart cell.
<% end %>
<% :down -> %>
The Smart cell crashed unexpectedly, this is most likely a bug.
"""
end
defp cell_evaluation_button(assigns) do
~H"""
"""
end
defp setup_cell_evaluation_button(%{status: :ready} = assigns) do
~H"""
<%= unless Livebook.Runtime.fixed_dependencies?(@runtime) do %>
<.menu id="setup-menu" position={:bottom_left} distant>
<:toggle>
<.menu_item>
<% end %>
"""
end
defp setup_cell_evaluation_button(assigns) do
~H"""
"""
end
defp enable_insert_mode_button(assigns) do
~H"""
"""
end
defp toggle_source_button(assigns) do
~H"""
"""
end
defp convert_smart_cell_button(assigns) do
~H"""
"""
end
defp package_search_button(assigns) do
~H"""
<%= if Livebook.Runtime.fixed_dependencies?(@runtime) do %>
<% else %>
<.link
patch={~p"/sessions/#{@session_id}/package-search"}
class="icon-button"
role="button"
data-btn-package-search
>
<.remix_icon icon="play-list-add-line" class="text-xl" />
<% end %>
"""
end
defp cell_link_button(assigns) do
~H"""
<.remix_icon icon="link" class="text-xl" />
"""
end
def amplify_output_button(assigns) do
~H"""
"""
end
defp cell_settings_button(assigns) do
~H"""
<.link
patch={~p"/sessions/#{@session_id}/cell-settings/#{@cell_id}"}
class="icon-button"
aria-label="cell settings"
role="button"
>
<.remix_icon icon="settings-3-line" class="text-xl" />
"""
end
defp move_cell_up_button(assigns) do
~H"""
"""
end
defp move_cell_down_button(assigns) do
~H"""
"""
end
defp delete_cell_button(assigns) do
~H"""
"""
end
defp setup_cell_info(assigns) do
~H"""
<.remix_icon icon="question-line" class="text-xl" />
"""
end
defp evaluation_outputs(assigns) do
~H"""
"""
end
defp empty?(%{source: ""} = _source_view), do: true
defp empty?(_source_view), do: false
defp cell_status(%{cell_view: %{eval: %{status: :evaluating}}} = assigns) do
~H"""
<.cell_status_indicator variant={:progressing} change_indicator={true}>
"""
end
defp cell_status(%{cell_view: %{eval: %{status: :queued}}} = assigns) do
~H"""
<.cell_status_indicator variant={:waiting}>
Queued
"""
end
defp cell_status(%{cell_view: %{eval: %{validity: :evaluated}}} = assigns) do
~H"""
<.cell_status_indicator
variant={if(@cell_view.eval.errored, do: :error, else: :success)}
change_indicator={true}
tooltip={evaluated_label(@cell_view.eval.evaluation_time_ms)}
>
Evaluated
"""
end
defp cell_status(%{cell_view: %{eval: %{validity: :stale}}} = assigns) do
~H"""
<.cell_status_indicator variant={:warning} change_indicator={true}>
Stale
"""
end
defp cell_status(%{cell_view: %{eval: %{validity: :aborted}}} = assigns) do
~H"""
<.cell_status_indicator variant={:inactive}>
Aborted
"""
end
defp cell_status(assigns), do: ~H""
attr :variant, :atom, required: true
attr :tooltip, :string, default: nil
attr :change_indicator, :boolean, default: false
slot :inner_block, required: true
defp cell_status_indicator(assigns) do
~H"""
<%= render_slot(@inner_block) %>
*
<.status_indicator variant={@variant} />
"""
end
defp evaluated_label(time_ms) when is_integer(time_ms) do
evaluation_time =
if time_ms > 100 do
seconds = time_ms |> Kernel./(1000) |> Float.floor(1)
"#{seconds}s"
else
"#{time_ms}ms"
end
"Took " <> evaluation_time
end
defp evaluated_label(_time_ms), do: nil
defp smart_cell_js_view_ref(%{type: :smart, status: :started, js_view: %{ref: ref}}), do: ref
defp smart_cell_js_view_ref(_cell_view), do: nil
end