The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix Circular Dependency in useGetPlan (#69672)
Ryan Laurieea30b8973d1a
diff --git a/frontend/src/metabase/admin/upsells/UpsellHosting.tsx b/frontend/src/metabase/admin/upsells/UpsellHosting.tsxindex e02b9ce5a32..8c4dbf77fc8 100644--- a/frontend/src/metabase/admin/upsells/UpsellHosting.tsx+++ b/frontend/src/metabase/admin/upsells/UpsellHosting.tsx@@ -1,6 +1,7 @@import { jt, t } from "ttag";-import { isProPlan, useGetPlan } from "metabase/common/utils/plan";+import { useSetting } from "metabase/common/hooks";+import { getPlan, isProPlan } from "metabase/common/utils/plan";import { useSelector } from "metabase/lib/redux";import { getIsHosted } from "metabase/setup/selectors";@@ -8,7 +9,9 @@ import { UpsellBanner } from "./components";export const UpsellHostingBanner = ({ location }: { location: string }) => {const isHosted = useSelector(getIsHosted);- const plan = useGetPlan();+ const features = useSetting("token-features");++ const plan = getPlan(features);const isPro = isProPlan(plan);if (isHosted || isPro) {diff --git a/frontend/src/metabase/common/utils/plan.ts b/frontend/src/metabase/common/utils/plan.tsindex 3d29e68f90f..cd314aa0e39 100644--- a/frontend/src/metabase/common/utils/plan.ts+++ b/frontend/src/metabase/common/utils/plan.ts@@ -1,8 +1,6 @@import type { TokenFeatures } from "metabase-types/api";import { tokenFeatures } from "metabase-types/api";-import { useSetting } from "../hooks";-export type ProPlan = "pro-cloud" | "pro-cloud-with-dwh" | "pro-self-hosted";export type Plan = "oss" | "starter" | "starter-with-dwh" | ProPlan;@@ -38,8 +36,3 @@ export const getPlan = (features?: TokenFeatures | null): Plan => {const ssoFeatures = ["sso_google", "sso_jwt", "sso_ldap", "sso_saml"] as const;export const hasAnySsoFeature = (features?: TokenFeatures | null): boolean =>features != null && ssoFeatures.some((ssoFeature) => features[ssoFeature]);--export const useGetPlan = (): Plan => {- const features = useSetting("token-features");- return getPlan(features);-};