Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Implement CTA for SSO (#5582)
Adrian Gruntkowski5d71ab92344a
diff --git a/extra/lib/plausible_web/controllers/sso_controller.ex b/extra/lib/plausible_web/controllers/sso_controller.exindex 63c231fcf7..033b64f552 100644--- a/extra/lib/plausible_web/controllers/sso_controller.ex+++ b/extra/lib/plausible_web/controllers/sso_controller.ex@@ -90,6 +90,10 @@ defmodule PlausibleWeb.SSOController doconn |> send_resp(200, "OK")end+ def cta(conn, _params) do+ render(conn, :cta, layout: {PlausibleWeb.LayoutView, :settings})+ end+def sso_settings(conn, _params) doif Plausible.Teams.setup?(conn.assigns.current_team) and Plausible.sso_enabled?() andPlausible.Billing.Feature.SSO.check_availability(conn.assigns.current_team) == :ok dodiff --git a/extra/lib/plausible_web/templates/sso/cta.html.heex b/extra/lib/plausible_web/templates/sso/cta.html.heexnew file mode 100644index 0000000000..48f680fc93--- /dev/null+++ b/extra/lib/plausible_web/templates/sso/cta.html.heex@@ -0,0 +1,15 @@+<.settings_tiles>+ <.tile docs="sso">+ <:title>+ <a id="sso-config">Single Sign-On</a>+ </:title>+ <:subtitle>+ Configure and manage Single Sign-On for your team+ </:subtitle>++ <p class="text-sm">+ Single Sign-On (SSO) enables team members to sign in without having to register an account. For more details,+ <.styled_link href="https://plausible.io/docs/sso">see our documentation</.styled_link>.+ </p>+ </.tile>+</.settings_tiles>diff --git a/lib/plausible_web/components/layout.ex b/lib/plausible_web/components/layout.exindex ef37fa4510..e55d356775 100644--- a/lib/plausible_web/components/layout.ex+++ b/lib/plausible_web/components/layout.ex@@ -60,11 +60,12 @@ defmodule PlausibleWeb.Components.Layout dodef settings_sidebar(assigns) do~H"""<.settings_top_tab- :for={%{key: key, value: value, icon: icon} <- @options}+ :for={%{key: key, value: value, icon: icon} = opts <- @options}selected_fn={@selected_fn}prefix={@prefix}icon={icon}text={key}+ badge={opts[:badge]}value={value}/>"""@@ -74,6 +75,7 @@ defmodule PlausibleWeb.Components.Layout doattr(:prefix, :string, default: "")attr(:icon, :any, default: nil)attr(:text, :string, required: true)+ attr(:badge, :any, default: nil)attr(:value, :any, default: nil)defp settings_top_tab(assigns) do@@ -84,6 +86,7 @@ defmodule PlausibleWeb.Components.Layout doprefix={@prefix}icon={@icon}text={@text}+ badge={@badge}value={@value}/><% else %>@@ -91,11 +94,12 @@ defmodule PlausibleWeb.Components.Layout do<div class="ml-6"><.settings_tab- :for={%{key: key, value: value} <- @value}+ :for={%{key: key, value: value} = opts <- @value}selected_fn={@selected_fn}prefix={@prefix}icon={nil}text={key}+ badge={opts[:badge]}value={value}submenu?={true}/>@@ -110,6 +114,7 @@ defmodule PlausibleWeb.Components.Layout doattr(:icon, :any, default: nil)attr(:submenu?, :boolean, default: false)attr(:text, :string, required: true)+ attr(:badge, :any, default: nil)defp settings_tab(assigns) docurrent_tab? = assigns[:selected_fn] != nil and assigns.selected_fn.(assigns[:value])@@ -133,6 +138,7 @@ defmodule PlausibleWeb.Components.Layout doclass={["h-4 w-4 mr-2", @current_tab? && "stroke-2"]}/>{@text}+ <.settings_badge type={@badge} /><Heroicons.chevron_down:if={is_nil(@value)}class="h-3 w-3 ml-2 text-gray-400 dark:text-gray-500"@@ -141,6 +147,16 @@ defmodule PlausibleWeb.Components.Layout do"""end+ defp settings_badge(%{type: :new} = assigns) do+ ~H"""+ <span class="inline-block ml-2 bg-indigo-700 text-gray-100 text-xs p-1 rounded">+ NEW+ </span>+ """+ end++ defp settings_badge(assigns), do: ~H""+defp theme_preference(%{theme: theme}) when not is_nil(theme), do: themedefp theme_preference(%{current_user: %Plausible.Auth.User{theme: theme}})diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex 359db7dc95..20dc27a042 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -472,6 +472,7 @@ defmodule PlausibleWeb.Router dopost "/team/leave", SettingsController, :leave_teamon_ee do+ get "/sso/info", SSOController, :ctaget "/sso/general", SSOController, :sso_settingsget "/sso/sessions", SSOController, :team_sessionsdelete "/sso/sessions/:session_id", SSOController, :delete_sessiondiff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.exindex 2235e56468..fcbc12ba65 100644--- a/lib/plausible_web/views/layout_view.ex+++ b/lib/plausible_web/views/layout_view.ex@@ -133,6 +133,16 @@ defmodule PlausibleWeb.LayoutView do]}),+ if(+ Plausible.sso_enabled?() and+ Plausible.Billing.Feature.SSO.check_availability(current_team) != :ok,+ do: %{+ key: "Single Sign-On",+ value: "sso/info",+ icon: :cloud,+ badge: :new+ }+ ),if(current_team_role == :owner,do: %{key: "Danger Zone", value: "team/delete", icon: :exclamation_triangle})diff --git a/test/plausible_web/controllers/sso_controller_test.exs b/test/plausible_web/controllers/sso_controller_test.exsindex 54d2ff1502..9f3345a174 100644--- a/test/plausible_web/controllers/sso_controller_test.exs+++ b/test/plausible_web/controllers/sso_controller_test.exs@@ -38,7 +38,8 @@ defmodule PlausibleWeb.SSOControllerTest doassert html = html_response(conn, 200)- assert html =~ "Single Sign-On"+ assert html =~ "/settings/sso/general"+ refute html =~ "/settings/sso/info"endtest "sso team settings item is hidden when there's no SSO plan feature", %{conn: conn} do@@ -51,7 +52,8 @@ defmodule PlausibleWeb.SSOControllerTest doassert html = html_response(conn, 200)- refute html =~ "Single Sign-On"+ refute html =~ "/settings/sso/general"+ assert html =~ "/settings/sso/info"endend