From 7f161e1d123c4a33082ec83827e3b7f86d17bcc8 Mon Sep 17 00:00:00 2001 From: Artur Pata Date: Mon, 1 Dec 2025 15:54:39 +0200 Subject: [PATCH 01/33] Add :limited_to_segment_id field to shared_links schema --- ...1201154500_add_limited_to_segment_to_shared_links.exs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs diff --git a/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs new file mode 100644 index 000000000000..43791108c13d --- /dev/null +++ b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs @@ -0,0 +1,9 @@ +defmodule Plausible.Repo.Migrations.AddLimitedToSegmentToSharedLinks do + use Ecto.Migration + + def change do + alter table(:shared_links) do + add :limited_to_segment_id, :integer, null: true + end + end +end From 924e77ef7bde85c3ff0ac57a29dc1224537477ae Mon Sep 17 00:00:00 2001 From: Artur Pata Date: Tue, 2 Dec 2025 19:16:42 +0200 Subject: [PATCH 02/33] Refactor column name, add FK, index, and on delete cascade --- .../20251201154500_add_limited_to_segment_to_shared_links.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs index 43791108c13d..41c7f599bffe 100644 --- a/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs +++ b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs @@ -3,7 +3,8 @@ defmodule Plausible.Repo.Migrations.AddLimitedToSegmentToSharedLinks do def change do alter table(:shared_links) do - add :limited_to_segment_id, :integer, null: true + add :segment_id, references(:segments, on_delete: :delete_all) end + create index(:shared_links, [:segment_id]) end end From 0fb303516b4bfca9028a48974d0ac0d14ce947ab Mon Sep 17 00:00:00 2001 From: Artur Pata Date: Tue, 2 Dec 2025 19:32:26 +0200 Subject: [PATCH 03/33] Format --- .../20251201154500_add_limited_to_segment_to_shared_links.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs index 41c7f599bffe..f223735c7416 100644 --- a/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs +++ b/priv/repo/migrations/20251201154500_add_limited_to_segment_to_shared_links.exs @@ -5,6 +5,7 @@ defmodule Plausible.Repo.Migrations.AddLimitedToSegmentToSharedLinks do alter table(:shared_links) do add :segment_id, references(:segments, on_delete: :delete_all) end + create index(:shared_links, [:segment_id]) end end From 26212190c8e4990fc1bd874f2812130f5a0c9218 Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Tue, 4 Nov 2025 10:14:22 +0100 Subject: [PATCH 04/33] Add static UI for adding a segment to a shared link - Update password UI to use a toogle switch to emphasize the optional nature of the feature - Add UI for limiting the link to a segment - Add toggle_field component for full-width label and toggle switch layout - Add optional link to the input component, showing below the input, which can be used for documentation links - Add eye icon to shared links list that indicates limited view - Add tooltips to icons in the shared links list --- lib/plausible_web/components/generic.ex | 55 +++++++- lib/plausible_web/live/components/form.ex | 23 +++- .../live/shared_link_settings.ex | 24 +++- .../live/shared_link_settings/form.ex | 121 +++++++++++++++++- 4 files changed, 203 insertions(+), 20 deletions(-) diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index a1aac36cdffa..d407702d52b8 100644 --- a/lib/plausible_web/components/generic.ex +++ b/lib/plausible_web/components/generic.ex @@ -393,7 +393,7 @@ defmodule PlausibleWeb.Components.Generic do ~H""" <.link class={[ - "inline-flex items-center gap-x-0.5", + "inline-flex items-center gap-x-1", @class ]} href={@href} @@ -403,7 +403,7 @@ defmodule PlausibleWeb.Components.Generic do {@rest} > {render_slot(@inner_block)} - + """ else @@ -471,6 +471,51 @@ defmodule PlausibleWeb.Components.Generic do """ end + attr :id, :string, required: true + attr :js_active_var, :string, required: true + attr :id_suffix, :string, default: "" + attr :disabled, :boolean, default: false + attr :label, :string, required: true + attr :help_text, :string, default: nil + attr :help_text_conditional, :boolean, default: false + attr :mt?, :boolean, default: true + + attr(:rest, :global) + + def toggle_field(assigns) do + help_text_conditional = assigns[:help_text_conditional] || false + + assigns = assign(assigns, help_text_conditional: help_text_conditional) + + ~H""" +
+
+ + {@label} + +

+ {@help_text} +

+
+ +
+ """ + end + def settings_tiles(assigns) do ~H"""
@@ -683,9 +728,9 @@ defmodule PlausibleWeb.Components.Generic do if String.contains?(classes, "text-sm") or String.contains?(classes, "text-xs") do - ["w-3 h-3"] + ["size-3"] else - ["w-4 h-4"] + ["size-4"] end end @@ -793,7 +838,7 @@ defmodule PlausibleWeb.Components.Generic do - <.label for={@id} class={if @help_text, do: "mb-0.5", else: "mb-1.5"}>{@label} +
+ <.label + :if={@label != nil and @label != ""} + for={@id} + class={if @help_text, do: "mb-0.5", else: "mb-1.5"} + > + {@label} +

{@help_text} @@ -84,6 +91,9 @@ defmodule PlausibleWeb.Live.Components.Form do {Phoenix.HTML.Form.options_for_select(@options, @value)} +

+ {render_slot(@link)} +
<.error :for={msg <- @errors}>{msg}
""" @@ -138,7 +148,7 @@ defmodule PlausibleWeb.Live.Components.Form do {@help_text} {render_slot(@help_content)} @@ -150,7 +160,7 @@ defmodule PlausibleWeb.Live.Components.Form do def input(%{type: "textarea"} = assigns) do ~H""" -
+
<.label class="mb-1.5" for={@id}>{@label}