Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Dont show hosting upsell to pro self hosted users (#69522)

Ryan Lauriec55a5d23a126
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.unit.spec.tsx
index 83bfbe354b9..d3f17b07dfe 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/UpdatesSettingsPage.unit.spec.tsx
@@ -12,12 +12,23 @@ import type { SettingKey } from "metabase-types/api";
import {
createMockSettingDefinition,
createMockSettings,
+ createMockTokenFeatures,
+ createMockUser,
} from "metabase-types/api/mocks";
import { createMockSettingsState } from "metabase-types/store/mocks";
import { UpdatesSettingsPage } from "./UpdatesSettingsPage";
-const setup = async (props: { isHosted: boolean; versionTag: string }) => {
+const setup = async (props: {
+ isHosted: boolean;
+ versionTag: string;
+ isPro?: boolean;
+}) => {
+ // having any SSO feature is how we detect if you have a pro plan
+ const tokenFeatures = createMockTokenFeatures(
+ props.isPro ? { sso_jwt: true } : {},
+ );
+
const updatesSettings = {
"is-hosted?": props.isHosted,
"check-for-updates": true,
@@ -27,7 +38,8 @@ const setup = async (props: { isHosted: boolean; versionTag: string }) => {
tag: props.versionTag,
hash: "4742ea1",
},
- } as const;
+ "token-features": tokenFeatures,
+ };
const settings = createMockSettings(updatesSettings);
setupPropertiesEndpoints(settings);
@@ -56,6 +68,7 @@ const setup = async (props: { isHosted: boolean; versionTag: string }) => {
{
storeInitialState: {
settings: createMockSettingsState(settings),
+ currentUser: createMockUser({ is_superuser: true }), // upsells only show for admins
},
},
);
@@ -87,4 +100,42 @@ describe("UpdatesSettingsPage", () => {
);
expect(await screen.findByRole("switch")).toBeChecked();
});
+
+ it("should show upsell when not hosted", async () => {
+ await act(() =>
+ setup({
+ isHosted: false,
+ isPro: false,
+ versionTag: "v1.53.8",
+ }),
+ );
+ expect(
+ await screen.findByText("Migrate to Metabase Cloud"),
+ ).toBeInTheDocument();
+ });
+
+ it("should not show upsell to self-hosted pro users", async () => {
+ await act(() =>
+ setup({
+ isHosted: false,
+ isPro: true,
+ versionTag: "v1.53.8",
+ }),
+ );
+ expect(
+ screen.queryByText("Migrate to Metabase Cloud"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("should not show upsell when hosted", async () => {
+ await act(() =>
+ setup({
+ isHosted: true,
+ versionTag: "v1.53.8",
+ }),
+ );
+ expect(
+ screen.queryByText("Migrate to Metabase Cloud"),
+ ).not.toBeInTheDocument();
+ });
});
diff --git a/frontend/src/metabase/admin/upsells/UpsellHosting.tsx b/frontend/src/metabase/admin/upsells/UpsellHosting.tsx
index 39d38746b09..e02b9ce5a32 100644
--- a/frontend/src/metabase/admin/upsells/UpsellHosting.tsx
+++ b/frontend/src/metabase/admin/upsells/UpsellHosting.tsx
@@ -1,44 +1,17 @@
import { jt, t } from "ttag";
-const RocketGlobeIllustrationSrc = "app/assets/img/rocket-globe.svg";
-import { UpsellCard } from "metabase/common/components/UpsellCard";
+import { isProPlan, useGetPlan } from "metabase/common/utils/plan";
import { useSelector } from "metabase/lib/redux";
import { getIsHosted } from "metabase/setup/selectors";
import { UpsellBanner } from "./components";
-// the default 200px width will break the title into two lines
-const UPSELL_CARD_WIDTH = 202;
-const CLOUD_PAGE = "/admin/settings/cloud";
-
-export const UpsellHosting = ({ location }: { location: string }) => {
- const isHosted = useSelector(getIsHosted);
-
- if (isHosted) {
- return null;
- }
-
- return (
- <UpsellCard
- title={t`Minimize maintenance`}
- campaign="hosting"
- buttonText={t`Learn more`}
- internalLink={CLOUD_PAGE}
- illustrationSrc={RocketGlobeIllustrationSrc}
- location={location}
- maxWidth={UPSELL_CARD_WIDTH}
- >
- {jt`${(
- <strong key="migrate">{t`Migrate to Metabase Cloud`}</strong>
- )} for fast, reliable, and secure deployment.`}
- </UpsellCard>
- );
-};
-
export const UpsellHostingBanner = ({ location }: { location: string }) => {
const isHosted = useSelector(getIsHosted);
+ const plan = useGetPlan();
+ const isPro = isProPlan(plan);
- if (isHosted) {
+ if (isHosted || isPro) {
return null;
}
@@ -56,27 +29,3 @@ export const UpsellHostingBanner = ({ location }: { location: string }) => {
</UpsellBanner>
);
};
-
-export const UpsellHostingUpdates = ({ location }: { location: string }) => {
- const isHosted = useSelector(getIsHosted);
-
- if (isHosted) {
- return null;
- }
-
- return (
- <UpsellCard
- title={t`Get automatic updates`}
- campaign="hosting"
- buttonText={t`Learn more`}
- internalLink={CLOUD_PAGE}
- illustrationSrc={RocketGlobeIllustrationSrc}
- location={location}
- maxWidth={UPSELL_CARD_WIDTH}
- >
- {jt`${(
- <strong key="migrate">{t`Migrate to Metabase Cloud`}</strong>
- )} for fast, reliable, and secure deployment.`}
- </UpsellCard>
- );
-};
diff --git a/frontend/src/metabase/common/utils/plan.ts b/frontend/src/metabase/common/utils/plan.ts
index cd314aa0e39..3d29e68f90f 100644
--- a/frontend/src/metabase/common/utils/plan.ts
+++ b/frontend/src/metabase/common/utils/plan.ts
@@ -1,6 +1,8 @@
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;
@@ -36,3 +38,8 @@ 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);
+};