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
Remote sync upsell (#73948)
Benoit Vinay2b3901c5a9f2
diff --git a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsxindex 18ff2d4c8fc..64b297547ab 100644--- a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx+++ b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx@@ -3,6 +3,7 @@ import { t } from "ttag";import { AdminNavWrapper } from "metabase/admin/components/AdminNav";import { UpsellGem } from "metabase/common/components/upsells/components/UpsellGem";import { useHasTokenFeature, useSetting } from "metabase/common/hooks";+import { getPlan, isProPlan } from "metabase/common/utils/plan";import { PLUGIN_REMOTE_SYNC } from "metabase/plugins";import { useSelector } from "metabase/redux";import { getUserIsAdmin } from "metabase/selectors/user";@@ -23,7 +24,9 @@ export function SettingsNav() {const hasScim = useHasTokenFeature("scim");const hasPythonTransforms = useHasTokenFeature("transforms-python");const isHosted = useSetting("is-hosted?");+ const tokenFeatures = useSetting("token-features");const isAdmin = useSelector(getUserIsAdmin);+ const isPro = isProPlan(getPlan(tokenFeatures));return (<AdminNavWrapper>@@ -47,7 +50,20 @@ export function SettingsNav() {{hasJwt && <SettingsNavItem path="authentication/jwt" label="JWT" />}{hasOidc && <SettingsNavItem path="authentication/oidc" label="OIDC" />}</SettingsNavItem>- <PLUGIN_REMOTE_SYNC.LibraryNav />+ {PLUGIN_REMOTE_SYNC.isEnabled ? (+ <PLUGIN_REMOTE_SYNC.LibraryNav />+ ) : !isPro ? (+ <SettingsNavItem+ path="remote-sync"+ label={+ <Flex gap="sm" align="center">+ <span>{t`Remote sync`}</span>+ <UpsellGem />+ </Flex>+ }+ icon="sync"+ />+ ) : null}<NavDivider /><SettingsNavItem path="email" label={t`Email`} icon="mail" /><SettingsNavItem path="slack" label={t`Slack`} icon="slack" />diff --git a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsxindex 3a855ae401d..0fd51e0aca4 100644--- a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx+++ b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.unit.spec.tsx@@ -8,6 +8,7 @@ import {createMockRoutingState,createMockSettingsState,} from "metabase/redux/store/mocks";+import type { TokenFeatures } from "metabase-types/api";import {createMockSettings,createMockTokenFeatures,@@ -21,10 +22,12 @@ const setup = async ({initialRoute,isHosted,customVizDevModeEnabled,+ tokenFeatures,}: {initialRoute: string;isHosted?: boolean;customVizDevModeEnabled?: boolean;+ tokenFeatures?: Partial<TokenFeatures>;}) => {const versionInfo = createMockVersionInfo();const settings = createMockSettings({@@ -34,6 +37,7 @@ const setup = async ({hosting: Boolean(isHosted),"custom-viz": true,"custom-viz-available": true,+ ...tokenFeatures,}),});@@ -65,6 +69,24 @@ describe("SettingsNav", () => {expect(await screen.findByText("Authentication")).toBeInTheDocument();});+ it("should show Remote sync upsell nav item for non-pro plans", async () => {+ await setup({+ initialRoute: "/admin/settings/general",+ tokenFeatures: {+ "custom-viz": false,+ "custom-viz-available": false,+ },+ });++ expect(await screen.findByText("Remote sync")).toBeInTheDocument();+ });++ it("should hide Remote sync upsell nav item for pro plans", async () => {+ await setup({ initialRoute: "/admin/settings/general" });++ expect(screen.queryByText("Remote sync")).not.toBeInTheDocument();+ });+it("should highlight the active nav item", async () => {await setup({ initialRoute: "/admin/settings/general" });diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.tsxnew file mode 100644index 00000000000..434d01be060--- /dev/null+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.tsx@@ -0,0 +1,16 @@+import { UpsellRemoteSync } from "metabase/admin/upsells";+import { useHasTokenFeature, useSetting } from "metabase/common/hooks";+import { getPlan, isProPlan } from "metabase/common/utils/plan";+import { PLUGIN_REMOTE_SYNC } from "metabase/plugins";++export function RemoteSyncSettingsPage() {+ const hasRemoteSync = useHasTokenFeature("remote_sync");+ const tokenFeatures = useSetting("token-features");+ const isPro = isProPlan(getPlan(tokenFeatures));++ if (hasRemoteSync || isPro) {+ return <PLUGIN_REMOTE_SYNC.RemoteSyncSettings />;+ }++ return <UpsellRemoteSync source="settings-git-sync" />;+}diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.unit.spec.tsxnew file mode 100644index 00000000000..19d32cfab9f--- /dev/null+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/RemoteSyncSettingsPage.unit.spec.tsx@@ -0,0 +1,29 @@+import { mockSettings } from "__support__/settings";+import { renderWithProviders, screen } from "__support__/ui";+import { createMockState } from "metabase/redux/store/mocks";+import {+ createMockSettings,+ createMockTokenFeatures,+ createMockUser,+} from "metabase-types/api/mocks";++import { RemoteSyncSettingsPage } from "./RemoteSyncSettingsPage";++describe("RemoteSyncSettingsPage", () => {+ it("should show the remote sync upsell when the feature is off and plan is not Pro", () => {+ const settings = createMockSettings({+ "token-features": createMockTokenFeatures({}),+ });++ renderWithProviders(<RemoteSyncSettingsPage />, {+ storeInitialState: createMockState({+ currentUser: createMockUser({ is_superuser: true }),+ settings: mockSettings(settings),+ }),+ });++ expect(+ screen.getByText(/Manage your Metabase content in Git/i),+ ).toBeInTheDocument();+ });+});diff --git a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsxindex ed6cc8bf69b..5019db950eb 100644--- a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx+++ b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx@@ -29,6 +29,8 @@ const routes = routeObjtoArray({...upsellRoutes,...enterpriseRoutes, // includes the license routecloud: { path: "skip", testPattern: /nope/ },+ // `ossRoutes.remoteSync` expects OSS/Starter upsell copy; this suite enables all features (incl. remote_sync), so assert the real settings UI instead.+ remoteSync: { path: "/remote-sync", testPattern: /Set up remote sync/i },}).filter(({ path }) => path !== "skip");describe("Admin Settings Routing - Enterprise with all features", () => {diff --git a/frontend/src/metabase/admin/settings/tests/setup.tsx b/frontend/src/metabase/admin/settings/tests/setup.tsxindex b4c2cac6d80..fae8d0ad1ae 100644--- a/frontend/src/metabase/admin/settings/tests/setup.tsx+++ b/frontend/src/metabase/admin/settings/tests/setup.tsx@@ -76,6 +76,10 @@ export const ossRoutes: RouteMap = {testPattern: /Make Metabase look like you/i,},cloud: { path: "/cloud", testPattern: /Migrate to Metabase Cloud/i },+ remoteSync: {+ path: "/remote-sync",+ testPattern: /Manage your Metabase content in Git/i,+ },};export const enterpriseRoutes: RouteMap = {@@ -154,6 +158,14 @@ export const setup = async ({fetchMock.get("path:/api/cloud-migration", { status: 204 });fetchMock.get("path:/api/ee/sso/oidc", []);+ fetchMock.get("path:/api/ee/remote-sync/dirty", {+ data: [],+ metadata: {+ changed_collections: {},+ is_dirty: false,+ has_removed_items: false,+ },+ });const user = createMockUser({is_superuser: isAdmin,diff --git a/frontend/src/metabase/admin/settingsRoutes.tsx b/frontend/src/metabase/admin/settingsRoutes.tsxindex 1685ebb288c..46cdaf3a30c 100644--- a/frontend/src/metabase/admin/settingsRoutes.tsx+++ b/frontend/src/metabase/admin/settingsRoutes.tsx@@ -10,7 +10,6 @@ import { AdminSettingsLayout } from "metabase/admin/components/AdminLayout/Adminimport { NotFound } from "metabase/common/components/ErrorPages";import {PLUGIN_AUTH_PROVIDERS,- PLUGIN_REMOTE_SYNC,PLUGIN_TRANSFORMS_PYTHON,} from "metabase/plugins";import type { State } from "metabase/redux/store";@@ -33,6 +32,7 @@ import { LicenseSettingsPage } from "./settings/components/SettingsPages/Licenseimport { LocalizationSettingsPage } from "./settings/components/SettingsPages/LocalizationSettingsPage";import { MapsSettingsPage } from "./settings/components/SettingsPages/MapsSettingsPage";import { PublicSharingSettingsPage } from "./settings/components/SettingsPages/PublicSharingSettingsPage";+import { RemoteSyncSettingsPage } from "./settings/components/SettingsPages/RemoteSyncSettingsPage";import { SlackSettingsPage } from "./settings/components/SettingsPages/SlackSettingsPage";import { UpdatesSettingsPage } from "./settings/components/SettingsPages/UpdatesSettingsPage";import { UploadSettingsPage } from "./settings/components/SettingsPages/UploadSettingsPage";@@ -87,10 +87,7 @@ export const getSettingsRoutes = (path="authentication/oidc"component={() => <PLUGIN_AUTH_PROVIDERS.SettingsOIDCForm />}/>- <Route- path="remote-sync"- component={() => <PLUGIN_REMOTE_SYNC.RemoteSyncSettings />}- />+ <Route path="remote-sync" component={RemoteSyncSettingsPage} /><Route path="maps" component={MapsSettingsPage} /><Route path="localization" component={LocalizationSettingsPage} /><Routediff --git a/frontend/src/metabase/admin/upsells/UpsellRemoteSync.tsx b/frontend/src/metabase/admin/upsells/UpsellRemoteSync.tsxnew file mode 100644index 00000000000..3483fa2c7b1--- /dev/null+++ b/frontend/src/metabase/admin/upsells/UpsellRemoteSync.tsx@@ -0,0 +1,47 @@+import { t } from "ttag";++import { ExternalLink } from "metabase/common/components/ExternalLink";+import { UpsellBigCard } from "metabase/common/components/upsells/components";+import S from "metabase/common/components/upsells/components/Upsells.module.css";+import { UPGRADE_URL } from "metabase/common/components/upsells/constants";+import { useHasTokenFeature, useSetting } from "metabase/common/hooks";+import { getPlan, isProPlan } from "metabase/common/utils/plan";+import { PLUGIN_ADMIN_SETTINGS } from "metabase/plugins";+import { useSelector } from "metabase/redux";+import { getApplicationName } from "metabase/selectors/whitelabel";++export const UpsellRemoteSync = ({ source }: { source: string }) => {+ const hasRemoteSync = useHasTokenFeature("remote_sync");+ const tokenFeatures = useSetting("token-features");+ const applicationName = useSelector(getApplicationName);+ const isPro = isProPlan(getPlan(tokenFeatures));+ const campaign = "remote-sync";+ const { triggerUpsellFlow } = PLUGIN_ADMIN_SETTINGS.useUpsellFlow({+ campaign,+ location: source,+ });++ if (hasRemoteSync || isPro) {+ return null;+ }++ return (+ <UpsellBigCard+ title={t`Manage your ${applicationName} content in Git`}+ campaign={campaign}+ buttonText={t`Try for free`}+ buttonLink={UPGRADE_URL}+ source={source}+ onClick={triggerUpsellFlow}+ illustrationSrc="app/assets/img/upsell-remote-sync.png"+ >+ {t`Keep your most important datasets, metrics, and SQL logic under version control. Sync content to a Git repository to review changes, collaborate, and maintain a production-ready source of truth.`}+ <ExternalLink+ className={S.SecondaryCTALink}+ href="https://www.metabase.com/product/git-sync"+ >+ {t`Learn more`}+ </ExternalLink>+ </UpsellBigCard>+ );+};diff --git a/frontend/src/metabase/admin/upsells/index.ts b/frontend/src/metabase/admin/upsells/index.tsindex 9b22d39b88e..d5cd578eaeb 100644--- a/frontend/src/metabase/admin/upsells/index.ts+++ b/frontend/src/metabase/admin/upsells/index.ts@@ -7,6 +7,7 @@ export * from "./UpsellEmbeddingTheme";export * from "./UpsellHosting";export * from "./UpsellPerformanceTools";export * from "./UpsellPermissions";+export * from "./UpsellRemoteSync";export * from "./UpsellSSO";export * from "./UpsellUploads";export * from "./UpsellWhitelabel";diff --git a/frontend/src/metabase/common/components/upsells/components/UpsellBigCard.tsx b/frontend/src/metabase/common/components/upsells/components/UpsellBigCard.tsxindex 543ca9dd7cb..11942d9d724 100644--- a/frontend/src/metabase/common/components/upsells/components/UpsellBigCard.tsx+++ b/frontend/src/metabase/common/components/upsells/components/UpsellBigCard.tsx@@ -96,7 +96,7 @@ export const UpsellBigCardInner: React.FC<UpsellBigCardProps> = ({<Flex px="xl" py="md"><UpsellGem size={24} /><Stack align="flex-start" gap={0} ml="0.75rem" maw="18.75rem">- <Title order={2} lh={1} mb="sm">+ <Title order={2} lh={1} mb="sm" pr="1rem">{title}</Title><Text lh="xl" mb="lg">diff --git a/resources/frontend_client/app/assets/img/upsell-remote-sync.png b/resources/frontend_client/app/assets/img/upsell-remote-sync.pngnew file mode 100644index 00000000000..0a7cda5fba2Binary files /dev/null and b/resources/frontend_client/app/assets/img/upsell-remote-sync.png differ