2021-04-02 20:00:49 +08:00
|
|
|
defmodule LivebookWeb.SessionLive.SessionsComponent do
|
2021-03-04 05:56:28 +08:00
|
|
|
use LivebookWeb, :live_component
|
2021-02-21 23:54:44 +08:00
|
|
|
|
|
|
|
@impl true
|
|
|
|
def render(assigns) do
|
|
|
|
~L"""
|
2021-03-12 18:57:01 +08:00
|
|
|
<div class="flex flex-col space-y-4">
|
2021-02-21 23:54:44 +08:00
|
|
|
<%= for summary <- @session_summaries do %>
|
2021-03-26 02:04:49 +08:00
|
|
|
<div class="p-5 flex items-center border border-gray-200 rounded-lg"
|
|
|
|
data-test-session-id="<%= summary.session_id %>">
|
2021-03-12 18:57:01 +08:00
|
|
|
<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" %>
|
2021-02-21 23:54:44 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-20 21:10:15 +08:00
|
|
|
<div class="relative">
|
2021-03-23 21:10:34 +08:00
|
|
|
<button class="icon-button" data-element="menu-toggle">
|
|
|
|
<%= remix_icon("more-2-fill", class: "text-xl") %>
|
2021-03-20 21:10:15 +08:00
|
|
|
</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"
|
2021-03-26 02:04:49 +08:00
|
|
|
phx-value-id="<%= summary.session_id %>">
|
2021-03-20 21:10:15 +08:00
|
|
|
<%= remix_icon("git-branch-line") %>
|
|
|
|
<span class="font-medium">Fork</span>
|
|
|
|
</button>
|
2021-04-15 04:37:17 +08:00
|
|
|
<%= link to: Routes.live_dashboard_path(@socket, :page, node(), "processes", info: Phoenix.LiveDashboard.Helpers.encode_pid(summary.pid)),
|
|
|
|
class: "flex space-x-3 px-5 py-2 items-center text-gray-600 hover:bg-gray-50",
|
|
|
|
target: "_blank" do %>
|
|
|
|
<%= remix_icon("dashboard-2-line") %>
|
|
|
|
<span class="font-medium">See on Dashboard</span>
|
|
|
|
<% end %>
|
2021-04-13 05:24:26 +08:00
|
|
|
<%= live_patch to: Routes.home_path(@socket, :close_session, summary.session_id),
|
2021-03-26 00:39:18 +08:00
|
|
|
class: "flex space-x-3 px-5 py-2 items-center text-red-600 hover:bg-gray-50" do %>
|
2021-04-13 05:24:26 +08:00
|
|
|
<%= remix_icon("close-circle-line") %>
|
|
|
|
<span class="font-medium">Close</span>
|
2021-03-26 00:39:18 +08:00
|
|
|
<% end %>
|
2021-03-20 21:10:15 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-21 23:54:44 +08:00
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
|
|
|
end
|