Remove :consolidated_view feature flag (#5908)
This commit is contained in:
parent
2c00acc89b
commit
5fe2be8dc8
|
|
@ -16,11 +16,6 @@ defmodule Plausible.ConsolidatedView do
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
@spec flag_enabled?(Team.t()) :: boolean()
|
|
||||||
def flag_enabled?(team) do
|
|
||||||
FunWithFlags.enabled?(:consolidated_view, for: team)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec cta_dismissed?(User.t(), Team.t()) :: boolean()
|
@spec cta_dismissed?(User.t(), Team.t()) :: boolean()
|
||||||
def cta_dismissed?(%User{} = user, %Team{} = team) do
|
def cta_dismissed?(%User{} = user, %Team{} = team) do
|
||||||
{:ok, team_membership} = Teams.Memberships.get_team_membership(team, user)
|
{:ok, team_membership} = Teams.Memberships.get_team_membership(team, user)
|
||||||
|
|
@ -51,7 +46,6 @@ defmodule Plausible.ConsolidatedView do
|
||||||
@spec ok_to_display?(Team.t() | nil) :: boolean()
|
@spec ok_to_display?(Team.t() | nil) :: boolean()
|
||||||
def ok_to_display?(team) do
|
def ok_to_display?(team) do
|
||||||
is_struct(team, Team) and
|
is_struct(team, Team) and
|
||||||
flag_enabled?(team) and
|
|
||||||
view_enabled?(team) and
|
view_enabled?(team) and
|
||||||
has_sites_to_consolidate?(team) and
|
has_sites_to_consolidate?(team) and
|
||||||
Plausible.Billing.Feature.ConsolidatedView.check_availability(team) == :ok
|
Plausible.Billing.Feature.ConsolidatedView.check_availability(team) == :ok
|
||||||
|
|
@ -102,9 +96,6 @@ defmodule Plausible.ConsolidatedView do
|
||||||
not Teams.setup?(team) ->
|
not Teams.setup?(team) ->
|
||||||
{:error, :team_not_setup}
|
{:error, :team_not_setup}
|
||||||
|
|
||||||
not flag_enabled?(team) ->
|
|
||||||
{:error, :unavailable}
|
|
||||||
|
|
||||||
true ->
|
true ->
|
||||||
do_enable(team)
|
do_enable(team)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1118,30 +1118,22 @@ defmodule PlausibleWeb.Live.Sites do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp init_consolidated_view_assigns(user, team) do
|
defp init_consolidated_view_assigns(user, team) do
|
||||||
if ConsolidatedView.flag_enabled?(team) do
|
case ConsolidatedView.enable(team) do
|
||||||
case ConsolidatedView.enable(team) do
|
{:ok, view} ->
|
||||||
{:ok, view} ->
|
%{
|
||||||
%{
|
consolidated_view: view,
|
||||||
consolidated_view: view,
|
can_manage_consolidated_view?: ConsolidatedView.can_manage?(user, team),
|
||||||
can_manage_consolidated_view?: ConsolidatedView.can_manage?(user, team),
|
consolidated_stats: :loading,
|
||||||
consolidated_stats: :loading,
|
no_consolidated_view_reason: nil,
|
||||||
no_consolidated_view_reason: nil,
|
consolidated_view_cta_dismissed?: ConsolidatedView.cta_dismissed?(user, team)
|
||||||
consolidated_view_cta_dismissed?: ConsolidatedView.cta_dismissed?(user, team)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
{:error, reason} ->
|
{:error, reason} ->
|
||||||
no_consolidated_view(
|
no_consolidated_view(
|
||||||
no_consolidated_view_reason: reason,
|
no_consolidated_view_reason: reason,
|
||||||
can_manage_consolidated_view?: ConsolidatedView.can_manage?(user, team),
|
can_manage_consolidated_view?: ConsolidatedView.can_manage?(user, team),
|
||||||
consolidated_view_cta_dismissed?: ConsolidatedView.cta_dismissed?(user, team)
|
consolidated_view_cta_dismissed?: ConsolidatedView.cta_dismissed?(user, team)
|
||||||
)
|
)
|
||||||
end
|
|
||||||
else
|
|
||||||
no_consolidated_view(
|
|
||||||
no_consolidated_view_reason: :unavailable,
|
|
||||||
can_manage_consolidated_view?: ConsolidatedView.can_manage?(user, team),
|
|
||||||
consolidated_view_cta_dismissed?: ConsolidatedView.cta_dismissed?(user, team)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ use Plausible
|
||||||
|
|
||||||
import Plausible.Teams.Test
|
import Plausible.Teams.Test
|
||||||
|
|
||||||
FunWithFlags.enable(:consolidated_view)
|
|
||||||
|
|
||||||
words =
|
words =
|
||||||
for i <- 0..(:erlang.system_info(:atom_count) - 1),
|
for i <- 0..(:erlang.system_info(:atom_count) - 1),
|
||||||
do: :erlang.binary_to_term(<<131, 75, i::24>>)
|
do: :erlang.binary_to_term(<<131, 75, i::24>>)
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,6 @@ defmodule Plausible.ConsolidatedViewTest do
|
||||||
refute ConsolidatedView.ok_to_display?(nil)
|
refute ConsolidatedView.ok_to_display?(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns false when feature flag is disabled", %{team: team} do
|
|
||||||
FunWithFlags.disable(:consolidated_view, for_actor: team)
|
|
||||||
refute ConsolidatedView.ok_to_display?(team)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "returns false when consolidated view is not enabled", %{team: team} do
|
test "returns false when consolidated view is not enabled", %{team: team} do
|
||||||
ConsolidatedView.disable(team)
|
ConsolidatedView.disable(team)
|
||||||
refute ConsolidatedView.ok_to_display?(team)
|
refute ConsolidatedView.ok_to_display?(team)
|
||||||
|
|
|
||||||
|
|
@ -331,52 +331,6 @@ defmodule PlausibleWeb.Live.SitesTest do
|
||||||
assert stats =~ "Views per visit 1.33"
|
assert stats =~ "Views per visit 1.33"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "consolidated view does not show up when flag is down (temp) during trial", %{
|
|
||||||
conn: conn,
|
|
||||||
user: user
|
|
||||||
} do
|
|
||||||
new_site(owner: user)
|
|
||||||
new_site(owner: user)
|
|
||||||
|
|
||||||
team = user |> team_of() |> Plausible.Teams.complete_setup()
|
|
||||||
|
|
||||||
FunWithFlags.disable(:consolidated_view, for_actor: team)
|
|
||||||
|
|
||||||
conn = set_current_team(conn, team)
|
|
||||||
|
|
||||||
{:ok, _lv, html} = live(conn, "/sites")
|
|
||||||
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-card"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-stats-loaded"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-chart-loaded"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-card-cta"]|)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "consolidated view does not show up when flag is down (temp) after trial ends", %{
|
|
||||||
conn: conn,
|
|
||||||
user: user
|
|
||||||
} do
|
|
||||||
new_site(owner: user)
|
|
||||||
new_site(owner: user)
|
|
||||||
|
|
||||||
team =
|
|
||||||
user
|
|
||||||
|> team_of()
|
|
||||||
|> Plausible.Teams.Team.end_trial()
|
|
||||||
|> Plausible.Repo.update!()
|
|
||||||
|
|
||||||
FunWithFlags.disable(:consolidated_view, for_actor: team)
|
|
||||||
|
|
||||||
conn = set_current_team(conn, team)
|
|
||||||
|
|
||||||
{:ok, _lv, html} = live(conn, "/sites")
|
|
||||||
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-card"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-stats-loaded"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-chart-loaded"]|)
|
|
||||||
refute element_exists?(html, ~s|[data-test-id="consolidated-view-card-cta"]|)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "consolidated view disappears when trial ends - CTA is shown instead", %{
|
test "consolidated view disappears when trial ends - CTA is shown instead", %{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
user: user
|
user: user
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ Mox.defmock(Plausible.DnsLookup.Mock,
|
||||||
|
|
||||||
Application.ensure_all_started(:double)
|
Application.ensure_all_started(:double)
|
||||||
|
|
||||||
FunWithFlags.enable(:consolidated_view)
|
|
||||||
|
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)
|
Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)
|
||||||
|
|
||||||
# warn about minio if it's included in tests but not running
|
# warn about minio if it's included in tests but not running
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue