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
Hide data apps nav items if user does not have a token feature (#78946)
Timofey Kachalov96e41d0d701b
diff --git a/e2e/test/scenarios/data-apps/admin.cy.spec.ts b/e2e/test/scenarios/data-apps/admin.cy.spec.tsindex 454c30ea212..86cb88f3ba4 100644--- a/e2e/test/scenarios/data-apps/admin.cy.spec.ts+++ b/e2e/test/scenarios/data-apps/admin.cy.spec.ts@@ -79,28 +79,57 @@ describe("scenarios > data apps > admin management", () => {});});-describe("scenarios > data apps > upsell (OSS)", { tags: "@OSS" }, () => {+// TODO(v65): data apps launch in v65 — replace the "no token" suite below with+// these upsell tests once the nav item + page are un-gated.+// describe("scenarios > data apps > upsell (OSS)", { tags: "@OSS" }, () => {+// beforeEach(() => {+// H.restore();+// cy.signInAsAdmin();+// // No token: on the OSS build the `data-apps` feature is unavailable, so the+// // settings page shows the upsell instead of the management UI.+// });+//+// it("shows the data-apps upsell instead of the management UI", () => {+// cy.visit("/admin/settings/apps");+//+// H.main().within(() => {+// cy.findByText("Build apps on your data").should("be.visible");+// cy.findByText("Try for free").should("be.visible");+// });+// });+//+// it("marks the Data apps settings nav item with an upsell gem", () => {+// cy.visit("/admin/settings/apps");+//+// cy.findByRole("link", { name: /Data apps/ }).within(() => {+// cy.findByTestId("upsell-gem").should("exist");+// });+// });+// });++describe("scenarios > data apps > no token (OSS)", { tags: "@OSS" }, () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- // No token: on the OSS build the `data-apps` feature is unavailable, so the- // settings page shows the upsell instead of the management UI.+ // No token: data apps launch in v65, so without the `data-apps` feature the+ // admin UI must not mention them at all — no nav item, no upsell, no page.});- it("shows the data-apps upsell instead of the management UI", () => {- cy.visit("/admin/settings/apps");+ it("hides the Data apps settings nav item", () => {+ cy.visit("/admin/settings/general");- H.main().within(() => {- cy.findByText("Build apps on your data").should("be.visible");- cy.findByText("Try for free").should("be.visible");- });+ cy.findByRole("heading", { name: "General" }).should("be.visible");+ cy.findByRole("link", { name: /Data apps/ }).should("not.exist");});- it("marks the Data apps settings nav item with an upsell gem", () => {+ it("404s the data apps settings page instead of showing an upsell", () => {cy.visit("/admin/settings/apps");- cy.findByRole("link", { name: /Data apps/ }).within(() => {- cy.findByTestId("upsell-gem").should("exist");+ H.main().within(() => {+ cy.findByText("The page you asked for couldn't be found.").should(+ "be.visible",+ );+ cy.findByText("Build apps on your data").should("not.exist");});});});diff --git a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsxindex e3d3c16f770..2c268476e8b 100644--- a/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx+++ b/frontend/src/metabase/admin/settings/components/SettingsNav/SettingsNav.tsx@@ -4,7 +4,11 @@ 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, PLUGIN_SECURITY_CENTER } from "metabase/plugins";+import {+ PLUGIN_DATA_APPS,+ PLUGIN_REMOTE_SYNC,+ PLUGIN_SECURITY_CENTER,+} from "metabase/plugins";import { useSelector } from "metabase/redux";import { getUserIsAdmin } from "metabase/selectors/user";import { Box, Divider, Flex } from "metabase/ui";@@ -80,7 +84,9 @@ export function SettingsNav() {/>{/* do not allow users with "Settings access" permissions to access custom viz pages */}{isAdmin && <CustomVisualizationsNav />}- {isAdmin && <DataAppsNav />}+ {/* TODO(v65): data apps launch in v65 — drop the isEnabled gate then so+ the nav item (and its upsell gem) shows without the token feature */}+ {isAdmin && PLUGIN_DATA_APPS.isEnabled && <DataAppsNav />}<SettingsNavItem path="maps" label={t`Maps`} icon="pinmap" /><SettingsNavItempath={!hasWhitelabel ? "whitelabel" : undefined}diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/DataAppsSettingsPage.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/DataAppsSettingsPage.tsxindex 5b8446de8c3..30c58e5e573 100644--- a/frontend/src/metabase/admin/settings/components/SettingsPages/DataAppsSettingsPage.tsx+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/DataAppsSettingsPage.tsx@@ -1,26 +1,30 @@-import { t } from "ttag";--import { SettingsPageWrapper } from "metabase/admin/components/SettingsSection";-import { UpsellDataApps } from "metabase/admin/upsells";-import { useHasTokenFeature } from "metabase/common/hooks";+// TODO(v65): data apps launch in v65 — uncomment these imports together with+// the upsell branch below.+// import { t } from "ttag";+//+// import { SettingsPageWrapper } from "metabase/admin/components/SettingsSection";+// import { UpsellDataApps } from "metabase/admin/upsells";+// import { useHasTokenFeature } from "metabase/common/hooks";import { PLUGIN_DATA_APPS } from "metabase/plugins";/**- * Admin page at /admin/settings/apps. Lives in OSS so the nav item + upsell- * show on every edition; the real management UI is provided by the enterprise- * plugin (`PLUGIN_DATA_APPS.ManageDataAppsPage`) and only rendered once the- * `data-apps` token feature is present.+ * Admin page at /admin/settings/apps. Until the v65 launch the route + nav item+ * only mount when the enterprise plugin has the `data-apps` token feature, so+ * instances without it get no mention of data apps.*/export function DataAppsManagePage() {- const hasDataApps = useHasTokenFeature("data-apps");-- if (!hasDataApps) {- return (- <SettingsPageWrapper title={t`Data apps`}>- <UpsellDataApps location="settings-data-apps" />- </SettingsPageWrapper>- );- }+ // TODO(v65): uncomment to bring back the upsell for instances without the+ // `data-apps` token feature (see the other TODO(v65) markers for the nav item+ // and route gates that hide this page until then).+ // const hasDataApps = useHasTokenFeature("data-apps");+ //+ // if (!hasDataApps) {+ // return (+ // <SettingsPageWrapper title={t`Data apps`}>+ // <UpsellDataApps location="settings-data-apps" />+ // </SettingsPageWrapper>+ // );+ // }return <PLUGIN_DATA_APPS.ManageDataAppsPage />;}diff --git a/frontend/src/metabase/admin/settingsRoutes.tsx b/frontend/src/metabase/admin/settingsRoutes.tsxindex 4cfe3c4f4de..d672f4cd926 100644--- a/frontend/src/metabase/admin/settingsRoutes.tsx+++ b/frontend/src/metabase/admin/settingsRoutes.tsx@@ -4,6 +4,7 @@ import { AdminSettingsLayout } from "metabase/admin/components/AdminLayout/Adminimport { NotFound } from "metabase/common/components/ErrorPages";import {PLUGIN_AUTH_PROVIDERS,+ PLUGIN_DATA_APPS,PLUGIN_TRANSFORMS_PYTHON,} from "metabase/plugins";import type { State } from "metabase/redux/store";@@ -102,14 +103,18 @@ export const getSettingsRoutes = (/>)}</Route>- <Route- path={- Urls.DATA_APP_URL_SEGMENT- } /* do not allow users with "Settings access" permissions to access data apps pages */- element={<IsAdmin />}- >- <Route index element={<DataAppsManagePage />} />- </Route>+ {/* TODO(v65): data apps launch in v65 — drop the isEnabled gate then so the+ page shows the upsell without the token feature instead of 404ing */}+ {PLUGIN_DATA_APPS.isEnabled && (+ <Route+ path={+ Urls.DATA_APP_URL_SEGMENT+ } /* do not allow users with "Settings access" permissions to access data apps pages */+ element={<IsAdmin />}+ >+ <Route index element={<DataAppsManagePage />} />+ </Route>+ )}<Route path="uploads" element={<UploadSettingsPage />} /><Routepath="python-runner"