From 559798206f13fb4c1a27a6004661ea2fb6608b65 Mon Sep 17 00:00:00 2001 From: jamey Date: Wed, 18 Feb 2026 23:55:42 +0000 Subject: [PATCH] extract setup wizard to dedicated /admin/setup page Move the setup stepper out of the dashboard into its own LiveView. Dashboard now redirects to setup when site isn't live, and shows stats-only view once live. Also cleans up button component variant handling, fixes alert CSS, and removes stale demo.html. Co-Authored-By: Claude Opus 4.6 --- assets/css/admin/components.css | 10 +- lib/berrypod/products.ex | 7 + lib/berrypod_web/admin_layout_hook.ex | 6 +- .../components/core_components.ex | 18 +- .../components/layouts/admin.html.heex | 8 + lib/berrypod_web/live/admin/dashboard.ex | 651 +- lib/berrypod_web/live/admin/product_show.ex | 2 +- .../live/admin/providers/index.html.heex | 2 +- lib/berrypod_web/live/admin/setup.ex | 660 ++ lib/berrypod_web/live/auth/confirmation.ex | 12 +- lib/berrypod_web/live/auth/login.ex | 6 +- lib/berrypod_web/live/auth/registration.ex | 2 +- lib/berrypod_web/router.ex | 1 + lib/berrypod_web/user_auth.ex | 5 +- priv/static/demo.html | 6278 ----------------- .../user_session_controller_test.exs | 8 +- .../live/admin/dashboard_test.exs | 68 +- test/berrypod_web/live/admin/layout_test.exs | 6 +- test/berrypod_web/live/admin/setup_test.exs | 88 + .../live/auth/confirmation_test.exs | 2 +- test/berrypod_web/live/auth/login_test.exs | 2 +- .../live/auth/registration_test.exs | 2 +- test/berrypod_web/user_auth_test.exs | 4 +- 23 files changed, 835 insertions(+), 7013 deletions(-) create mode 100644 lib/berrypod_web/live/admin/setup.ex delete mode 100644 priv/static/demo.html create mode 100644 test/berrypod_web/live/admin/setup_test.exs diff --git a/assets/css/admin/components.css b/assets/css/admin/components.css index 6e8f76a..d060229 100644 --- a/assets/css/admin/components.css +++ b/assets/css/admin/components.css @@ -375,7 +375,7 @@ position: fixed; top: 1rem; right: 1rem; - z-index: 50; + z-index: 100; } .admin-alert { @@ -389,15 +389,15 @@ } .admin-alert-info { - background-color: color-mix(in oklch, var(--color-info) 10%, transparent); + background-color: color-mix(in oklch, var(--color-info) 12%, var(--color-base-100)); color: var(--color-info); - border: 1px solid color-mix(in oklch, var(--color-info) 25%, transparent); + border: 1px solid color-mix(in oklch, var(--color-info) 25%, var(--color-base-100)); } .admin-alert-error { - background-color: color-mix(in oklch, var(--color-error) 10%, transparent); + background-color: color-mix(in oklch, var(--color-error) 12%, var(--color-base-100)); color: var(--color-error); - border: 1px solid color-mix(in oklch, var(--color-error) 25%, transparent); + border: 1px solid color-mix(in oklch, var(--color-error) 25%, var(--color-base-100)); } /* ── Modal ── */ diff --git a/lib/berrypod/products.ex b/lib/berrypod/products.ex index cfb4605..186023a 100644 --- a/lib/berrypod/products.ex +++ b/lib/berrypod/products.ex @@ -90,6 +90,13 @@ defmodule Berrypod.Products do |> Repo.update_all(set: [sync_status: "idle"]) end + @doc """ + Returns the total count of all products. + """ + def count_products do + Repo.aggregate(Product, :count) + end + @doc """ Returns the count of products for a provider connection. """ diff --git a/lib/berrypod_web/admin_layout_hook.ex b/lib/berrypod_web/admin_layout_hook.ex index 62ed2c8..20cf44e 100644 --- a/lib/berrypod_web/admin_layout_hook.ex +++ b/lib/berrypod_web/admin_layout_hook.ex @@ -8,10 +8,14 @@ defmodule BerrypodWeb.AdminLayoutHook do socket = socket |> assign(:current_path, "") + |> assign(:site_live, Berrypod.Settings.site_live?()) |> Phoenix.LiveView.attach_hook(:set_current_path, :handle_params, fn _params, uri, socket -> - {:cont, assign(socket, :current_path, URI.parse(uri).path)} + {:cont, + socket + |> assign(:current_path, URI.parse(uri).path) + |> assign(:site_live, Berrypod.Settings.site_live?())} end) {:cont, socket} diff --git a/lib/berrypod_web/components/core_components.ex b/lib/berrypod_web/components/core_components.ex index 314c64f..a070de0 100644 --- a/lib/berrypod_web/components/core_components.ex +++ b/lib/berrypod_web/components/core_components.ex @@ -81,16 +81,24 @@ defmodule BerrypodWeb.CoreComponents do """ attr :rest, :global, include: ~w(href navigate patch method download name value disabled) attr :class, :string - attr :variant, :string, values: ~w(primary) + attr :variant, :string, values: ~w(primary outline) slot :inner_block, required: true def button(%{rest: rest} = assigns) do - variants = %{"primary" => "admin-btn-primary", nil => "admin-btn-primary admin-btn-soft"} + variants = %{ + "primary" => "admin-btn-primary", + "outline" => "admin-btn-outline", + nil => "admin-btn-primary admin-btn-soft" + } + + variant_class = Map.fetch!(variants, assigns[:variant]) assigns = - assign_new(assigns, :class, fn -> - ["admin-btn", Map.fetch!(variants, assigns[:variant])] - end) + assign(assigns, :class, [ + "admin-btn", + variant_class, + assigns[:class] + ]) if rest[:href] || rest[:navigate] || rest[:patch] do ~H""" diff --git a/lib/berrypod_web/components/layouts/admin.html.heex b/lib/berrypod_web/components/layouts/admin.html.heex index 8734c43..f480237 100644 --- a/lib/berrypod_web/components/layouts/admin.html.heex +++ b/lib/berrypod_web/components/layouts/admin.html.heex @@ -43,6 +43,14 @@ <%!-- nav links --%>