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
Crm consolidated views followup (#5764)
RobertJoonas627602d2a604
diff --git a/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex b/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.exindex 2f112ef342..2e43bd8119 100644--- a/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex+++ b/extra/lib/plausible_web/live/customer_support/team/components/consolidated_views.ex@@ -1,22 +1,16 @@defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews do@moduledoc """- [Experimental - new feature]-Lists ConsolidatedViews of a team and allows creating one if none exist. Currentlimitation is one consolidated view per team, which always includes all sites ofthis team."""use PlausibleWeb, :live_componentimport PlausibleWeb.CustomerSupport.Live+ alias Plausible.ConsolidatedViewdef update(%{team: team}, socket) do- cvs =- case Plausible.ConsolidatedView.get(team) do- nil -> []- cv -> [cv]- end-- {:ok, assign(socket, team: team, consolidated_views: cvs)}+ consolidated_views = ConsolidatedView.get(team) |> List.wrap()+ {:ok, assign(socket, team: team, consolidated_views: consolidated_views)}enddef render(assigns) do@@ -35,7 +29,6 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews do<.th>Domain</.th><.th>Timezone</.th><.th invisible>Dashboard</.th>- <.th invisible>Settings</.th><.th invisible>Delete</.th></:thead>@@ -51,22 +44,11 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews do</.styled_link></.td><.td>- <.styled_link- new_tab={true}- href={- Routes.site_path(- PlausibleWeb.Endpoint,- :settings_general,- consolidated_view.domain,- []- )- }- >- Settings- </.styled_link>- </.td>- <.td>- <.delete_button phx-click="delete-consolidated-view" phx-target={@myself} />+ <.delete_button+ phx-click="delete-consolidated-view"+ phx-target={@myself}+ data-confirm="Are you sure you want to delete this consolidated view?"+ /></.td></:tbody></.table>@@ -76,19 +58,19 @@ defmodule PlausibleWeb.CustomerSupport.Team.Components.ConsolidatedViews doenddef handle_event("create-consolidated-view", _, socket) do- case Plausible.ConsolidatedView.enable(socket.assigns.team) do- {:ok, cv} ->+ case ConsolidatedView.enable(socket.assigns.team) do+ {:ok, consolidated_view} ->success("Consolidated view created")- {:noreply, assign(socket, consolidated_views: [cv])}+ {:noreply, assign(socket, consolidated_views: [consolidated_view])}{:error, _} ->- failure("Could not create consolidated View")+ failure("Could not create consolidated view"){:noreply, socket}endenddef handle_event("delete-consolidated-view", _, socket) do- Plausible.ConsolidatedView.disable(socket.assigns.team)+ ConsolidatedView.disable(socket.assigns.team)success("Deleted consolidated view"){:noreply, assign(socket, consolidated_views: [])}enddiff --git a/test/plausible_web/live/customer_support/teams_test.exs b/test/plausible_web/live/customer_support/teams_test.exsindex d22b7d6c59..1c0a9e51cc 100644--- a/test/plausible_web/live/customer_support/teams_test.exs+++ b/test/plausible_web/live/customer_support/teams_test.exs@@ -204,7 +204,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest dolv |> element(@create_consolidated_view_button) |> render_click()- assert not is_nil(Plausible.ConsolidatedView.get(team))+ assert Plausible.ConsolidatedView.enabled?(team)endtest "renders existing consolidated view", %{conn: conn, user: user} do@@ -218,7 +218,6 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest doassert table_text =~ team.identifierassert table_text =~ "Dashboard"- assert table_text =~ "Settings"assert element_exists?(html, @delete_consolidated_view_button)end@@ -231,7 +230,7 @@ defmodule PlausibleWeb.Live.CustomerSupport.TeamsTest dolv |> element(@delete_consolidated_view_button) |> render_click()- assert is_nil(Plausible.ConsolidatedView.get(team))+ assert not Plausible.ConsolidatedView.enabled?(team)endend