mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-01 01:13:16 +08:00
Add Hub sidebar
This commit is contained in:
parent
57ebf0f1be
commit
b1a7e13d35
1 changed files with 49 additions and 0 deletions
|
@ -47,6 +47,7 @@ defmodule LivebookWeb.SidebarHelpers do
|
|||
to={Routes.settings_path(@socket, :page)}
|
||||
current={@current_page}
|
||||
/>
|
||||
<.hub_section socket={@socket} />
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<%= if Livebook.Config.shutdown_enabled?() do %>
|
||||
|
@ -101,6 +102,54 @@ defmodule LivebookWeb.SidebarHelpers do
|
|||
"""
|
||||
end
|
||||
|
||||
defp hub_section(assigns) do
|
||||
~H"""
|
||||
<%= if Application.get_env(:livebook, :feature_flags)[:hub] do %>
|
||||
<div class="sidebar--hub">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 relative leading-6 mb-2">
|
||||
<div class="flex flex-col">
|
||||
<small class="ml-5 font-medium text-white">HUBS</small>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<%= live_redirect to: hub_path(@socket),
|
||||
class: "flex absolute right-5 items-center justify-center
|
||||
text-gray-400 hover:text-white hover:border-white" do %>
|
||||
<.remix_icon icon="add-line" />
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= for machine <- Livebook.Hub.Settings.fetch_machines() do %>
|
||||
<div class="h-7 flex items-center cursor-pointer text-gray-400 hover:text-white">
|
||||
<.remix_icon
|
||||
class="text-lg ml-1 leading-6 w-[56px] flex justify-center"
|
||||
icon="checkbox-blank-circle-fill"
|
||||
style={"color: #{machine.color}"}
|
||||
/>
|
||||
|
||||
<span class="ml-1 text-sm font-medium">
|
||||
<%= machine.name %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="h-7 flex items-center cursor-pointer text-gray-400 hover:text-white mt-2 ml-5">
|
||||
<%= live_redirect to: hub_path(@socket), class: "flex text-lg leading-6 flex items-center" do %>
|
||||
<.remix_icon icon="add-line" class="mr-6" />
|
||||
<span class="text-sm font-medium">Add Hub</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
defp hub_path(socket) do
|
||||
if Application.get_env(:livebook, :feature_flags)[:hub] do
|
||||
apply(Routes, :hub_path, [socket, :page])
|
||||
end
|
||||
end
|
||||
|
||||
defp sidebar_link_text_color(to, current) when to == current, do: "text-white"
|
||||
defp sidebar_link_text_color(_to, _current), do: "text-gray-400"
|
||||
|
||||
|
|
Loading…
Reference in a new issue