defmodule LivebookWeb.Hub.NewLive do use LivebookWeb, :live_view alias LivebookWeb.LayoutHelpers alias Phoenix.LiveView.JS on_mount LivebookWeb.SidebarHook @impl true def mount(_params, _session, socket) do enabled? = Livebook.Config.feature_flag_enabled?(:create_hub) {:ok, assign(socket, selected_type: nil, page_title: "Livebook - Hub", enabled?: enabled?)} end @impl true def handle_params(_params, _url, socket), do: {:noreply, socket} @impl true def render(%{enabled?: false} = assigns) do ~H""" TODO """ end def render(assigns) do ~H"""

Manage your Livebooks in the cloud with Hubs.

1. Select your Hub service

<.card_item id="fly" selected={@selected_type} title="Fly"> <:logo> <%= Phoenix.HTML.raw(File.read!("static/images/fly.svg")) %> <:headline> Deploy notebooks to your Fly account. <.card_item id="enterprise" selected={@selected_type} title="Livebook Enterprise"> <:logo> Livebook Enterprise logo <:headline> Control access, manage secrets, and deploy notebooks within your team.

2. Configure your Hub

<.live_component :if={@selected_type == "fly"} module={LivebookWeb.Hub.New.FlyComponent} id="fly-form" /> <.live_component :if={@selected_type == "enterprise"} module={LivebookWeb.Hub.New.EnterpriseComponent} id="enterprise-form" />
""" end defp card_item(assigns) do ~H"""
<%= render_slot(@logo) %>

<%= @title %>

<%= render_slot(@headline) %>

""" end @impl true def handle_event("select_type", %{"value" => service}, socket) do {:noreply, assign(socket, selected_type: service)} end end