livebook/lib/livebook_web/live/sessions_component.ex
Jonatan Kłosko 90e7941fe4
Redesign (#80)
* Update cell actions

* Add new focus indicator

* Update headings typography

* Update cell actions and insert buttons

* Add sidebar menu

* Add settings modal

* Update homepage

* Update settings dialog

* Rename classes

* Add floating menu

* Update icon colors on hover

* Fix homepage tests

* Format assets source

* Update monaco editor

* Fix editor width on resize

* Add more padding to the notebook content

* Update settings dialog title

* Show reevaluate button when the cell is in evaluated state

* Show section actions on focus or hover only

* Pre-fill runtime selector with the current configuration

* Ignore cmd + enter in Markdown cells
2021-03-20 14:10:15 +01:00

57 lines
2.1 KiB
Elixir

defmodule LivebookWeb.SessionsComponent do
use LivebookWeb, :live_component
alias Livebook.SessionSupervisor
@impl true
def render(assigns) do
~L"""
<div class="flex flex-col space-y-4">
<%= for summary <- @session_summaries do %>
<div class="p-5 flex items-center border border-gray-200 rounded-lg">
<div class="flex-grow flex flex-col space-y-1">
<%= live_redirect summary.notebook_name, to: Routes.session_path(@socket, :page, summary.session_id),
class: "font-semibold text-gray-800 hover:text-gray-900" %>
<div class="text-gray-600 text-sm">
<%= summary.path || "No file" %>
</div>
</div>
<div class="relative">
<button data-element="menu-toggle">
<%= remix_icon("more-2-fill", class: "text-xl action-icon") %>
</button>
<div class="absolute right-0 z-20 rounded-lg shadow-center bg-white flex flex-col py-2" data-element="menu">
<button class="flex space-x-3 px-5 py-2 items-center text-gray-500 hover:bg-gray-50"
phx-click="fork_session"
phx-value-id="<%= summary.session_id %>"
phx-target="<%= @myself %>">
<%= remix_icon("git-branch-line") %>
<span class="font-medium">Fork</span>
</button>
<button class="flex space-x-3 px-5 py-2 items-center text-red-600 hover:bg-gray-50"
phx-click="delete_session"
phx-value-id="<%= summary.session_id %>"
phx-target="<%= @myself %>">
<%= remix_icon("delete-bin-6-line") %>
<span class="font-medium">Delete</span>
</button>
</div>
</div>
</div>
<% end %>
</div>
"""
end
@impl true
def handle_event("delete_session", %{"id" => session_id}, socket) do
SessionSupervisor.delete_session(session_id)
{:noreply, socket}
end
def handle_event("fork_session", %{"id" => session_id}, socket) do
send(self(), {:fork_session, session_id})
{:noreply, socket}
end
end