From 428ee747c3c510383345c8a919840fb72982610a Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 21 Apr 2022 16:43:16 +0300 Subject: [PATCH] Hook up flags to the custom prop filter --- assets/js/dashboard/filters.js | 4 +++- assets/js/dashboard/mount.js | 3 ++- lib/plausible_web/router.ex | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/assets/js/dashboard/filters.js b/assets/js/dashboard/filters.js index 68e80edf6..950744e8a 100644 --- a/assets/js/dashboard/filters.js +++ b/assets/js/dashboard/filters.js @@ -127,7 +127,9 @@ function DropdownContent({history, site, query, wrapped}) { const [addingFilter, setAddingFilter] = useState(false); if (wrapped === 0 || addingFilter) { - return Object.keys(FILTER_GROUPS).map((option) => filterDropdownOption(site, option)) + return Object.keys(FILTER_GROUPS) + .filter((option) => option === 'props' ? site.flags.custom_dimension_filter : true) + .map((option) => filterDropdownOption(site, option)) } return ( diff --git a/assets/js/dashboard/mount.js b/assets/js/dashboard/mount.js index 38cc914a3..4490c98b7 100644 --- a/assets/js/dashboard/mount.js +++ b/assets/js/dashboard/mount.js @@ -16,7 +16,8 @@ if (container) { statsBegin: container.dataset.statsBegin, embedded: container.dataset.embedded, background: container.dataset.background, - selfhosted: container.dataset.selfhosted === 'true' + selfhosted: container.dataset.selfhosted === 'true', + flags: JSON.parse(container.dataset.flags) } const loggedIn = container.dataset.loggedIn === 'true' diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex index 7687dcf7c..a66abf7b2 100644 --- a/lib/plausible_web/router.ex +++ b/lib/plausible_web/router.ex @@ -41,9 +41,11 @@ defmodule PlausibleWeb.Router do plug PlausibleWeb.Firewall end - pipeline :mounted_apps do + pipeline :flags do plug :accepts, ["html"] plug :put_secure_browser_headers + plug :fetch_session + plug PlausibleWeb.CRMAuthPlug end if Mix.env() == :dev do @@ -52,9 +54,9 @@ defmodule PlausibleWeb.Router do use Kaffy.Routes, scope: "/crm", pipe_through: [PlausibleWeb.CRMAuthPlug] - scope path: "/feature-flags" do - pipe_through :mounted_apps - forward "/", FunWithFlags.UI.Router, namespace: "feature-flags" + scope path: "/flags" do + pipe_through :flags + forward "/", FunWithFlags.UI.Router, namespace: "flags" end scope "/api/stats", PlausibleWeb.Api do