+
<%= if @type == "fly" do %>
@@ -69,4 +84,14 @@ defmodule LivebookWeb.Hub.EditLive do
"""
end
+
+ @impl true
+ def handle_event("delete_hub", %{"id" => id}, socket) do
+ Hubs.delete_hub(id)
+
+ {:noreply,
+ socket
+ |> put_flash(:success, "Hub deleted successfully")
+ |> push_redirect(to: "/")}
+ end
end
diff --git a/lib/livebook_web/live/layout_helpers.ex b/lib/livebook_web/live/layout_helpers.ex
index 50e711169..1baeae0af 100644
--- a/lib/livebook_web/live/layout_helpers.ex
+++ b/lib/livebook_web/live/layout_helpers.ex
@@ -264,7 +264,7 @@ defmodule LivebookWeb.LayoutHelpers do
"h-7 flex items-center hover:text-white #{text_color} border-l-4 #{border_color} hover:border-white"
if tooltip = Provider.connection_error(hub) do
- [to: to, data_tooltip: tooltip, class: "tooltip top " <> class]
+ [to: to, data_tooltip: tooltip, class: "tooltip right " <> class]
else
[to: to, class: class]
end
diff --git a/test/livebook_web/live/hub/edit_live_test.exs b/test/livebook_web/live/hub/edit_live_test.exs
index abd3452c7..08781987e 100644
--- a/test/livebook_web/live/hub/edit_live_test.exs
+++ b/test/livebook_web/live/hub/edit_live_test.exs
@@ -63,6 +63,30 @@ defmodule LivebookWeb.Hub.EditLiveTest do
refute Hubs.fetch_hub!(hub.id) == hub
end
+ test "deletes hub", %{conn: conn, bypass: bypass} do
+ {:ok, pid} = Agent.start(fn -> %{fun: &fetch_app_response/2, type: :mount} end)
+ app_id = Livebook.Utils.random_short_id()
+ hub_id = "fly-#{app_id}"
+
+ hub = insert_hub(:fly, id: hub_id, application_id: app_id)
+ fly_bypass(bypass, app_id, pid)
+
+ {:ok, view, html} = live(conn, Routes.hub_path(conn, :edit, hub.id))
+
+ assert {:ok, view, _html} =
+ view
+ |> render_click("delete_hub", %{"id" => hub_id})
+ |> follow_redirect(conn)
+
+ hubs_html = view |> element("#hubs") |> render()
+
+ refute hubs_html =~ hub.hub_emoji
+ refute hubs_html =~ Routes.hub_path(conn, :edit, hub.id)
+ refute hubs_html =~ hub.hub_name
+
+ assert Hubs.get_hub(hub_id) == :error
+ end
+
test "add env var", %{conn: conn, bypass: bypass} do
{:ok, pid} = Agent.start(fn -> %{fun: &fetch_app_response/2, type: :mount} end)