Skip to content

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

Update styling of forms

Uku Taht6911a983b758
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index 64690ef7b6..31cdabd57c 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -91,17 +91,26 @@ defmodule PlausibleWeb.SiteController do
end
def settings_general(conn, %{"website" => website}) do
- site =
- Sites.get_for_user!(conn.assigns[:current_user].id, website)
+ site = Sites.get_for_user!(conn.assigns[:current_user].id, website)
+
+ conn
+ |> assign(:skip_plausible_tracking, true)
+ |> render("settings_general.html",
+ site: site,
+ changeset: Plausible.Site.changeset(site, %{}),
+ layout: {PlausibleWeb.LayoutView, "site_settings.html"}
+ )
+ end
+ def settings_visibility(conn, %{"website" => website}) do
+ site = Sites.get_for_user!(conn.assigns[:current_user].id, website)
shared_links = Repo.all(from l in Plausible.Site.SharedLink, where: l.site_id == ^site.id)
conn
|> assign(:skip_plausible_tracking, true)
- |> render("settings_general.html",
+ |> render("settings_visibility.html",
site: site,
shared_links: shared_links,
- changeset: Plausible.Site.changeset(site, %{}),
layout: {PlausibleWeb.LayoutView, "site_settings.html"}
)
end
@@ -168,6 +177,17 @@ defmodule PlausibleWeb.SiteController do
|> render("settings_snippet.html", site: site, layout: {PlausibleWeb.LayoutView, "site_settings.html"})
end
+ def settings_danger_zone(conn, %{"website" => website}) do
+ site = Sites.get_for_user!(conn.assigns[:current_user].id, website)
+
+ conn
+ |> assign(:skip_plausible_tracking, true)
+ |> render("settings_danger_zone.html",
+ site: site,
+ layout: {PlausibleWeb.LayoutView, "site_settings.html"}
+ )
+ end
+
def update_google_auth(conn, %{"website" => website, "google_auth" => attrs}) do
site =
Sites.get_for_user!(conn.assigns[:current_user].id, website)
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index 951e70c3a4..c7f069545e 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -146,11 +146,13 @@ defmodule PlausibleWeb.Router do
get "/:website/snippet", SiteController, :add_snippet
get "/:website/settings", SiteController, :settings
get "/:website/settings/general", SiteController, :settings_general
+ get "/:website/settings/visibility", SiteController, :settings_visibility
get "/:website/settings/goals", SiteController, :settings_goals
get "/:website/settings/search-console", SiteController, :settings_search_console
get "/:website/settings/email-reports", SiteController, :settings_email_reports
get "/:website/settings/custom-domain", SiteController, :settings_custom_domain
get "/:website/settings/js-snippet", SiteController, :settings_snippet
+ get "/:website/settings/danger-zone", SiteController, :settings_danger_zone
get "/:website/goals/new", SiteController, :new_goal
post "/:website/goals", SiteController, :create_goal
delete "/:website/goals/:id", SiteController, :delete_goal
diff --git a/lib/plausible_web/templates/layout/site_settings.html.eex b/lib/plausible_web/templates/layout/site_settings.html.eex
index b295c7a773..e4c7430d29 100644
--- a/lib/plausible_web/templates/layout/site_settings.html.eex
+++ b/lib/plausible_web/templates/layout/site_settings.html.eex
@@ -25,11 +25,13 @@
</div>
<div class="hidden lg:block">
<%= render("_settings_tab.html", this_tab: "general", text: "General", site: @site, conn: @conn) %>
+ <%= render("_settings_tab.html", this_tab: "visibility", text: "Visibility", site: @site, conn: @conn) %>
<%= render("_settings_tab.html", this_tab: "goals", text: "Goals", site: @site, conn: @conn) %>
<%= render("_settings_tab.html", this_tab: "search-console", text: "Search Console", site: @site, conn: @conn) %>
<%= render("_settings_tab.html", this_tab: "email-reports", text: "Email reports", site: @site, conn: @conn) %>
<%= render("_settings_tab.html", this_tab: "custom-domain", text: "Custom domain", site: @site, conn: @conn) %>
<%= render("_settings_tab.html", this_tab: "js-snippet", text: "JS snippet", site: @site, conn: @conn) %>
+ <%= render("_settings_tab.html", this_tab: "danger-zone", text: "Danger zone", site: @site, conn: @conn) %>
</div>
</div>
diff --git a/lib/plausible_web/templates/site/settings_danger_zone.html.eex b/lib/plausible_web/templates/site/settings_danger_zone.html.eex
new file mode 100644
index 0000000000..827819584f
--- /dev/null
+++ b/lib/plausible_web/templates/site/settings_danger_zone.html.eex
@@ -0,0 +1,32 @@
+<div class="sm:rounded-md sm:overflow-hidden shadow">
+ <div class="bg-white py-6 px-4 space-y-6 sm:p-6">
+ <div>
+ <h2 class="text-lg leading-6 font-medium text-gray-900">Danger zone</h2>
+ <p class="mt-1 text-sm leading-5 text-gray-500">Desctructive actions below can result in irrecoverable data loss. Be careful.</p>
+ </div>
+ <li class="py-4 flex items-center justify-between space-x-4">
+ <div class="flex flex-col">
+ <p class="text-sm leading-5 font-medium text-gray-900">
+ Reset stats
+ </p>
+ <p class="text-sm leading-5 text-gray-500">
+ Removes all pageviews but keeps the site configuration
+ </p>
+ </div>
+ <%= link("Reset #{@site.domain} stats", to: "/#{URI.encode_www_form(@site.domain)}/stats", method: :delete, class: "inline-block px-4 py-2 border border-gray-300 text-sm leading-5 font-medium rounded-md text-red-700 bg-white hover:text-red-500 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", data: [confirm: "Resetting the stats cannot be reversed. Are you sure?"]) %>
+ </li>
+ <div class="border-b border-gray-200"></div>
+
+ <li class="py-4 flex items-center justify-between space-x-4">
+ <div class="flex flex-col">
+ <p class="text-sm leading-5 font-medium text-gray-900">
+ Delete site
+ </p>
+ <p class="text-sm leading-5 text-gray-500">
+ Removes all stats along with the site configuration
+ </p>
+ </div>
+ <%= link "Delete #{@site.domain}", to: "/#{URI.encode_www_form(@site.domain)}", method: :delete, class: "inline-block px-4 py-2 border border-transparent font-medium rounded-md text-red-700 bg-red-100 hover:bg-red-50 focus:outline-none focus:border-red-300 focus:ring active:bg-red-200 transition ease-in-out duration-150 sm:text-sm sm:leading-5", data: [confirm: "Deleting the site data cannot be reversed. Are you sure?"] %>
+ </li>
+ </div>
+</div>
diff --git a/lib/plausible_web/templates/site/settings_email_reports.html.eex b/lib/plausible_web/templates/site/settings_email_reports.html.eex
index b8d488e5ca..0a3531d911 100644
--- a/lib/plausible_web/templates/site/settings_email_reports.html.eex
+++ b/lib/plausible_web/templates/site/settings_email_reports.html.eex
@@ -20,17 +20,36 @@
<div class="text-sm text-gray-700 mt-6">
<h4 class="font-bold my-2">Weekly report recipients</h4>
<%= for recipient <- @weekly_report.recipients do %>
- <div class="p-2 flex justify-between bg-gray-100 rounded my-2 max-w-md">
+ <div class="p-2 pl-3 flex justify-between bg-gray-100 rounded my-2 max-w-md">
<span>
- <svg class="feather mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg><%= recipient %>
+ <svg class="h-5 w-5 text-gray-400 inline mr-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
+ <path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" />
+ <path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" />
+ </svg><%= recipient %>
</span>
- <%= button("❌", to: "/sites/#{URI.encode_www_form(@site.domain)}/weekly-report/recipients/#{recipient}", method: :delete) %>
+ <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/weekly-report/recipients/#{recipient}", method: :delete) do %>
+ <svg class="w-4 h-4 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
+ <% end %>
</div>
<% end %>
<%= form_for @conn, "/sites/#{URI.encode_www_form(@site.domain)}/weekly-report/recipients", fn f -> %>
- <div class="flex justify-between my-2 max-w-md">
- <%= email_input f, :recipient, class: "transition bg-gray-100 appearance-none border border-transparent rounded w-full p-2 text-gray-700 leading-normal appearance-none focus:outline-none focus:border-gray-300", style: "flex-grow: 2", placeholder: "[email protected]" %>
- <%= submit "Add recipient", class: "button rounded-l-none whitespace-nowrap" %>
+ <div class="max-w-md mt-4">
+ <div class="mt-1 flex rounded-md shadow-sm">
+ <div class="relative flex items-stretch flex-grow focus-within:z-10">
+ <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+ <svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
+ <path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" />
+ <path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" />
+ </svg>
+ </div>
+ <%= email_input f, :recipient, class: "focus:ring-indigo-500 focus:border-indigo-500 block w-full rounded-none rounded-l-md pl-10 sm:text-sm border-gray-300", placeholder: "[email protected]" %>
+ </div>
+
+ <%= submit class: "-ml-px relative button rounded-l-none" do %>
+ <svg class="w-5 h-5 mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"></path></svg>
+ <span>Add recipient</span>
+ <% end %>
+ </div>
</div>
<% end %>
</div>
@@ -52,17 +71,36 @@
<div class="text-sm text-gray-700 mt-6">
<h4 class="font-bold my-2">Monthly report recipients</h4>
<%= for recipient <- @monthly_report.recipients do %>
- <div class="p-2 flex justify-between bg-gray-100 rounded my-2 max-w-md">
+ <div class="p-2 pl-3 flex justify-between bg-gray-100 rounded my-2 max-w-md">
<span>
- <svg class="feather mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg><%= recipient %>
+ <svg class="h-5 w-5 text-gray-400 inline mr-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
+ <path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" />
+ <path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" />
+ </svg><%= recipient %>
</span>
- <%= button("❌", to: "/sites/#{URI.encode_www_form(@site.domain)}/monthly-report/recipients/#{recipient}", method: :delete) %>
+ <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/monthly-report/recipients/#{recipient}", method: :delete) do %>
+ <svg class="w-4 h-4 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
+ <% end %>
</div>
<% end %>
<%= form_for @conn, "/sites/#{URI.encode_www_form(@site.domain)}/monthly-report/recipients", fn f -> %>
- <div class="flex justify-between my-2 max-w-md">
- <%= email_input f, :recipient, class: "transition bg-gray-100 appearance-none border border-transparent rounded w-full p-2 text-gray-700 leading-normal appearance-none focus:outline-none focus:border-gray-300", style: "flex-grow: 2", placeholder: "[email protected]" %>
- <%= submit "Add recipient", class: "button rounded-l-none whitespace-nowrap" %>
+ <div class="max-w-md mt-4">
+ <div class="mt-1 flex rounded-md shadow-sm">
+ <div class="relative flex items-stretch flex-grow focus-within:z-10">
+ <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
+ <svg class="h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
+ <path d="M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z" />
+ <path d="M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z" />
+ </svg>
+ </div>
+ <%= email_input f, :recipient, class: "focus:ring-indigo-500 focus:border-indigo-500 block w-full rounded-none rounded-l-md pl-10 sm:text-sm border-gray-300", placeholder: "[email protected]" %>
+ </div>
+
+ <%= submit class: "-ml-px relative button rounded-l-none" do %>
+ <svg class="w-5 h-5 mr-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M8 9a3 3 0 100-6 3 3 0 000 6zM8 11a6 6 0 016 6H2a6 6 0 016-6zM16 7a1 1 0 10-2 0v1h-1a1 1 0 100 2h1v1a1 1 0 102 0v-1h1a1 1 0 100-2h-1V7z"></path></svg>
+ <span>Add recipient</span>
+ <% end %>
+ </div>
</div>
<% end %>
</div>
diff --git a/lib/plausible_web/templates/site/settings_general.html.eex b/lib/plausible_web/templates/site/settings_general.html.eex
index b97663cee6..f72f273e06 100644
--- a/lib/plausible_web/templates/site/settings_general.html.eex
+++ b/lib/plausible_web/templates/site/settings_general.html.eex
@@ -25,82 +25,3 @@
</div>
</div>
<% end %>
-
-<div class="shadow bg-white sm:rounded-md sm:overflow-hidden mt-12 py-6 px-4 sm:p-6">
- <div>
- <h2 class="text-lg leading-6 font-medium text-gray-900">Dashboard visibility</h2>
- <p class="mt-1 text-sm leading-5 text-gray-500">Share your stats publicly or keep them private</p>
- </div>
-
- <%= if @site.public do %>
- <div class="flex items-center space-x-3 mt-4">
- <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/make-private", method: "POST", class: "bg-indigo-600 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring") do %>
- <span class="translate-x-5 inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"></span>
- <% end %>
- <span class="text-sm leading-5 font-medium text-gray-900">Make stats publicly available on <a href="<%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%>" class="text-indigo-500"><%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%></a></span>
- </div>
- <% else %>
- <div class="flex items-center space-x-3 mt-4">
- <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/make-public", method: "POST", class: "bg-gray-200 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring") do %>
- <span class="translate-x-0 inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"></span>
- <% end %>
- <span class="text-sm leading-5 font-medium text-gray-900">Make stats publicly available on <a href="<%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%>" class="text-indigo-500"><%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%></a></span>
- </div>
- <% end %>
-
- <div class="mt-8">
- <div>
- <h2 class="text-lg leading-6 font-medium text-gray-900">Shared links</h2>
- <p class="mt-1 text-sm leading-5 text-gray-500">You can share your stats privately by generating a shared link. The links are impossible to guess and you can add password protection for extra security.</p>
- </div>
-
- <div class="mt-6">
- <%= for link <- @shared_links do %>
- <div class="flex relative w-full max-w-xl mt-2 text-sm">
- <input type="text" id="<%= link.slug %>" readonly="readonly" value="<%= shared_link_dest(link) %>" class="transition bg-gray-100 appearance-none border border-transparent rounded rounded-r-none w-full p-2 text-gray-700 appearance-none focus:outline-none focus:border-gray-300" />
- <button onclick="var input = document.getElementById('<%= link.slug %>'); input.focus(); input.select(); document.execCommand('copy');" href="javascript:void(0)" class="py-2 px-4 bg-gray-100 text-indigo-800 rounded-none border-r border-gray-300">
- <svg class="feather-sm" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
- </button>
- <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/shared-links/#{link.slug}", method: :delete, class: "py-2 px-4 bg-gray-100 text-red-600 rounded-l-none", data: [confirm: "Are you sure you want to delete this shared link? The stats will not be accessible with this link anymore."]) do %>
- <svg class="feather feather-sm" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>
- <% end %>
- </div>
- <% end %>
-
- <%= link("+ New link", to: "/sites/#{URI.encode_www_form(@site.domain)}/shared-links/new", class: "button mt-4") %>
- </div>
- </div>
-</div>
-
-<div class="sm:rounded-md sm:overflow-hidden mt-12 border border-red-400">
- <div class="bg-white py-6 px-4 space-y-6 sm:p-6">
- <div>
- <h2 class="text-lg leading-6 font-medium text-gray-900">Danger zone</h2>
- <p class="mt-1 text-sm leading-5 text-gray-500">Desctructive actions below can result in irrecoverable data loss. Be careful.</p>
- </div>
- <li class="py-4 flex items-center justify-between space-x-4">
- <div class="flex flex-col">
- <p class="text-sm leading-5 font-medium text-gray-900">
- Reset stats
- </p>
- <p class="text-sm leading-5 text-gray-500">
- Removes all pageviews but keeps the site configuration
- </p>
- </div>
- <%= link("Reset #{@site.domain} stats", to: "/#{URI.encode_www_form(@site.domain)}/stats", method: :delete, class: "inline-block px-4 py-2 border border-gray-300 text-sm leading-5 font-medium rounded-md text-red-700 bg-white hover:text-red-500 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", data: [confirm: "Resetting the stats cannot be reversed. Are you sure?"]) %>
- </li>
- <div class="border-b border-gray-200"></div>
-
- <li class="py-4 flex items-center justify-between space-x-4">
- <div class="flex flex-col">
- <p class="text-sm leading-5 font-medium text-gray-900">
- Delete site
- </p>
- <p class="text-sm leading-5 text-gray-500">
- Removes all stats along with the site configuration
- </p>
- </div>
- <%= link "Delete #{@site.domain}", to: "/#{URI.encode_www_form(@site.domain)}", method: :delete, class: "inline-block px-4 py-2 border border-transparent font-medium rounded-md text-red-700 bg-red-100 hover:bg-red-50 focus:outline-none focus:border-red-300 focus:ring active:bg-red-200 transition ease-in-out duration-150 sm:text-sm sm:leading-5", data: [confirm: "Deleting the site data cannot be reversed. Are you sure?"] %>
- </li>
- </div>
-</div>
diff --git a/lib/plausible_web/templates/site/settings_visibility.html.eex b/lib/plausible_web/templates/site/settings_visibility.html.eex
new file mode 100644
index 0000000000..d2c3ccbbbe
--- /dev/null
+++ b/lib/plausible_web/templates/site/settings_visibility.html.eex
@@ -0,0 +1,46 @@
+<div class="shadow bg-white sm:rounded-md sm:overflow-hidden py-6 px-4 sm:p-6">
+ <div>
+ <h2 class="text-lg leading-6 font-medium text-gray-900">Dashboard visibility</h2>
+ <p class="mt-1 text-sm leading-5 text-gray-500">Share your stats publicly or keep them private</p>
+ </div>
+
+ <%= if @site.public do %>
+ <div class="flex items-center space-x-3 mt-4">
+ <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/make-private", method: "POST", class: "bg-indigo-600 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring") do %>
+ <span class="translate-x-5 inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"></span>
+ <% end %>
+ <span class="text-sm leading-5 font-medium text-gray-900">Make stats publicly available on <a href="<%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%>" class="text-indigo-500"><%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%></a></span>
+ </div>
+ <% else %>
+ <div class="flex items-center space-x-3 mt-4">
+ <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/make-public", method: "POST", class: "bg-gray-200 relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring") do %>
+ <span class="translate-x-0 inline-block h-5 w-5 rounded-full bg-white shadow transform transition ease-in-out duration-200"></span>
+ <% end %>
+ <span class="text-sm leading-5 font-medium text-gray-900">Make stats publicly available on <a href="<%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%>" class="text-indigo-500"><%= plausible_url() <> "/" <> URI.encode_www_form(@site.domain)%></a></span>
+ </div>
+ <% end %>
+
+ <div class="mt-8">
+ <div>
+ <h2 class="text-lg leading-6 font-medium text-gray-900">Shared links</h2>
+ <p class="mt-1 text-sm leading-5 text-gray-500">You can share your stats privately by generating a shared link. The links are impossible to guess and you can add password protection for extra security.</p>
+ </div>
+
+ <div class="mt-6">
+ <%= for link <- @shared_links do %>
+ <div class="flex relative w-full max-w-xl mt-2 text-sm">
+ <input type="text" id="<%= link.slug %>" readonly="readonly" value="<%= shared_link_dest(link) %>" class="transition bg-gray-100 appearance-none border border-transparent rounded rounded-r-none w-full p-2 text-gray-700 appearance-none focus:outline-none focus:border-gray-300" />
+ <button onclick="var input = document.getElementById('<%= link.slug %>'); input.focus(); input.select(); document.execCommand('copy');" href="javascript:void(0)" class="py-2 px-4 bg-gray-100 text-indigo-800 rounded-none border-r border-gray-300">
+ <svg class="feather-sm" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
+ </button>
+ <%= button(to: "/sites/#{URI.encode_www_form(@site.domain)}/shared-links/#{link.slug}", method: :delete, class: "py-2 px-4 bg-gray-100 text-red-600 rounded-l-none", data: [confirm: "Are you sure you want to delete this shared link? The stats will not be accessible with this link anymore."]) do %>
+ <svg class="feather feather-sm" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>
+ <% end %>
+ </div>
+ <% end %>
+
+ <%= link("+ New link", to: "/sites/#{URI.encode_www_form(@site.domain)}/shared-links/new", class: "button mt-4") %>
+ </div>
+ </div>
+</div>
+