diff --git a/lib/plausible_web/components/first_dashboard_launch_banner.ex b/lib/plausible_web/components/first_dashboard_launch_banner.ex
index 7646368a6fdd..e43923fa141d 100644
--- a/lib/plausible_web/components/first_dashboard_launch_banner.ex
+++ b/lib/plausible_web/components/first_dashboard_launch_banner.ex
@@ -1,52 +1,58 @@
defmodule PlausibleWeb.Components.FirstDashboardLaunchBanner do
@moduledoc """
- A banner that appears on the first dashboard launch
+ Dashboard banner pointing at email reports, shown once a site has stats and
+ only to roles that can access the email reports settings. Stays hidden while
+ the verification banner is up and reveals itself when that banner is dismissed.
"""
use PlausibleWeb, :component
- attr(:site, Plausible.Site, required: true)
-
- def set(assigns) do
- ~H"""
-
- """
- end
+ @roles_with_email_reports_access [:owner, :admin, :editor, :super_admin]
attr(:site, Plausible.Site, required: true)
+ attr(:site_role, :atom, required: true)
+ attr(:current_user_id, :any, required: true)
+ attr(:has_pageviews?, :boolean, required: true)
+ attr(:verify_installation?, :boolean, default: false)
def render(assigns) do
+ assigns =
+ assign(
+ assigns,
+ :visible?,
+ assigns.has_pageviews? and assigns.site_role in @roles_with_email_reports_access
+ )
+
~H"""
- <.styled_link
- class="plausible-event-name=Weekly+Email+Note+Click"
- href={Routes.site_path(PlausibleWeb.Endpoint, :settings_email_reports, @site.domain)}
+ <.notice
+ theme={:indigo}
+ dismissable_id={"first_dashboard_launched_#{@current_user_id}_#{@site.domain}"}
+ class="!p-4 text-center font-medium"
+ dismiss_class="top-1/2 -translate-y-1/2 right-4"
>
- Get weekly traffic summaries by email →
-
+
+ 🎉
+
+
+ Your first pageview has landed!
+
+ <.styled_link
+ class="plausible-event-name=Weekly+Email+Note+Click"
+ href={Routes.site_path(PlausibleWeb.Endpoint, :settings_email_reports, @site.domain)}
+ onclick={"localStorage['notice_dismissed__first_dashboard_launched_#{@current_user_id}_#{@site.domain}'] = 'true'"}
+ >
+ Get weekly traffic reports by email →
+
+
"""
end
-
- defp x_data(site) do
- "{show: !!sessionStorage.getItem('#{storage_key(site)}')}"
- end
-
- defp x_init(site) do
- "setTimeout(() => sessionStorage.removeItem('#{storage_key(site)}'), 3000)"
- end
-
- defp storage_key(site) do
- "dashboard_seen_#{site.domain}"
- end
end
diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex
index 173e6a6a6f88..e45cb11eff4c 100644
--- a/lib/plausible_web/components/generic.ex
+++ b/lib/plausible_web/components/generic.ex
@@ -235,6 +235,7 @@ defmodule PlausibleWeb.Components.Generic do
attr(:class, :string, default: "")
attr(:icon_class, :string, default: "")
attr(:title_class, :string, default: "")
+ attr(:dismiss_class, :string, default: "")
attr(:rest, :global)
slot(:inner_block)
slot(:actions)
@@ -248,7 +249,12 @@ defmodule PlausibleWeb.Components.Generic do