Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Remove custom domain link if site does not have a custom domain

Uku Taht5c886cc00411
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index 4f1b572c8e..7a981aa726 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -181,8 +181,7 @@ defmodule PlausibleWeb.SiteController do
def settings_people(conn, _params) do
site =
conn.assigns[:site]
- |> Repo.preload(memberships: :user)
- |> Repo.preload(:invitations)
+ |> Repo.preload(memberships: :user, invitations: [], custom_domain: [])
conn
|> assign(:skip_plausible_tracking, true)
@@ -193,7 +192,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_visibility(conn, _params) do
- site = conn.assigns[:site]
+ site = conn.assigns[:site] |> Repo.preload(:custom_domain)
shared_links = Repo.all(from l in Plausible.Site.SharedLink, where: l.site_id == ^site.id)
conn
@@ -206,7 +205,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_goals(conn, _params) do
- site = conn.assigns[:site]
+ site = conn.assigns[:site] |> Repo.preload(:custom_domain)
goals = Goals.for_site(site.domain)
conn
@@ -221,7 +220,7 @@ defmodule PlausibleWeb.SiteController do
def settings_search_console(conn, _params) do
site =
conn.assigns[:site]
- |> Repo.preload(:google_auth)
+ |> Repo.preload([:google_auth, :custom_domain])
search_console_domains =
if site.google_auth do
@@ -238,7 +237,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_email_reports(conn, _params) do
- site = conn.assigns[:site]
+ site = conn.assigns[:site] |> Repo.preload(:custom_domain)
conn
|> assign(:skip_plausible_tracking, true)
@@ -265,10 +264,12 @@ defmodule PlausibleWeb.SiteController do
end
def settings_danger_zone(conn, _params) do
+ site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+
conn
|> assign(:skip_plausible_tracking, true)
|> render("settings_danger_zone.html",
- site: conn.assigns[:site],
+ site: site,
layout: {PlausibleWeb.LayoutView, "site_settings.html"}
)
end
@@ -667,6 +668,6 @@ defmodule PlausibleWeb.SiteController do
conn
|> put_flash(:success, "Custom domain deleted successfully")
- |> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings/custom-domain")
+ |> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings/general")
end
end
diff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.ex
index c1a8bf401d..6cad0c241c 100644
--- a/lib/plausible_web/views/layout_view.ex
+++ b/lib/plausible_web/views/layout_view.ex
@@ -29,7 +29,7 @@ defmodule PlausibleWeb.LayoutView do
[key: "Goals", value: "goals"],
[key: "Search Console", value: "search-console"],
[key: "Email reports", value: "email-reports"],
- if !is_selfhost() do
+ if !is_selfhost() && conn.assigns[:site].custom_domain do
[key: "Custom domain", value: "custom-domain"]
else
nil