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
Updates to the license page (#78036)
Benoit Vinay075482040b40
diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.module.css b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.module.cssindex 40bd079e1a6..b3d757799a1 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.module.css+++ b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.module.css@@ -1,11 +1,17 @@.row {&:not(:last-child) {- border-bottom: 1px solid var(--mb-color-background_page-tertiary);+ border-bottom: 1px solid var(--mb-color-border-neutral);}}+.label {+ flex: 1 1 auto;+ min-width: 0;+}+.link {display: inline-flex;+ flex-shrink: 0;align-items: center;color: var(--mb-color-core-brand);}diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.tsxindex eac24755d5a..83173cf5c16 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfo.tsx@@ -34,12 +34,14 @@ export function BillingInfo({return <BillingInfoNotStoreManaged />;}- if (!billingInfo || !billingInfo.content || !billingInfo.content.length) {- return <BillingGoToStore />;+ if (billingInfo?.content?.length) {+ return <BillingInfoTable billingInfo={billingInfo} />;}- return <BillingInfoTable billingInfo={billingInfo} />;+ // Store-managed token but no billing content from Store (e.g. `{ "version": "v1" }`)+ return <BillingGoToStore />;}+const BillingInfoError = () => {return (<>diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsxindex 5fdf6690f9e..a919b84d5a2 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/BillingInfo/BillingInfoTable.tsx@@ -6,7 +6,7 @@ import { SettingHeader } from "metabase/admin/settings/components/SettingHeader"import { ExternalLink } from "metabase/common/components/ExternalLink";import { Link } from "metabase/common/components/Link";import { useSetting } from "metabase/common/hooks";-import { Card, Flex, Icon, Text } from "metabase/ui";+import { Box, Card, Flex, Icon, Text } from "metabase/ui";import type { BillingInfo, BillingInfoLineItem } from "metabase-types/api";import { StillNeedHelp } from "../StillNeedHelp";@@ -30,7 +30,7 @@ const BillingInfoValue = ({if (lineItem.display === "value") {return (- <Text fw="bold" color="currentColor" {...props}>+ <Text fw="bold" color="currentColor" ta="right" {...props}>{formattedValue}</Text>);@@ -69,11 +69,9 @@ const BillingInfoValue = ({function BillingInfoRow({lineItem,- extraPadding,...props}: {lineItem: BillingInfoLineItem;- extraPadding: boolean;}) {// avoid rendering the entire row if we can't format/display the valueif (!isSupportedLineItem(lineItem)) {@@ -97,13 +95,14 @@ function BillingInfoRow({className={S.row}align="center"justify="space-between"- px="md"- py={extraPadding ? "lg" : "sm"}+ gap="lg"+ px="lg"+ py="md"{...props}><Text+ className={S.label}c="text-secondary"- maw="15rem"data-testid={`billing-info-key-${id}`}>{lineItem.name}@@ -124,19 +123,15 @@ export const BillingInfoTable = ({}) => {const airgap_enabled = useSetting("airgap-enabled");return (- <>+ <Box><SettingHeader id="billing" title={t`Billing`} /><Card mt="md" p={0} radius="md" shadow="none" withBorder>- {billingInfo.content?.map((lineItem, index, arr) => (- <BillingInfoRow- key={lineItem.name}- lineItem={lineItem}- extraPadding={arr.length === index + 1}- />+ {billingInfo.content?.map((lineItem) => (+ <BillingInfoRow key={lineItem.name} lineItem={lineItem} />))}</Card>{airgap_enabled && <StillNeedHelp />}- </>+ </Box>);};diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.tsxindex 88c9c370302..9bdeebd6311 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.tsx@@ -126,20 +126,13 @@ export const LicenseAndBillingSettings = () => {return (<SettingsPageWrapper title={t`License`}><SettingsSection>- <Stack- data-testid="license-and-billing-content"- maw="36rem"- px="lg"- gap="lg"- >- <Box>- <BillingInfo- isStoreManagedBilling={isStoreManagedBilling}- hasToken={hasToken}- billingInfo={billingInfo}- error={!!billingError}- />- </Box>+ <Stack data-testid="license-and-billing-content" gap="xl" maw="40rem">+ <BillingInfo+ isStoreManagedBilling={isStoreManagedBilling}+ hasToken={hasToken}+ billingInfo={billingInfo}+ error={!!billingError}+ />{shouldShowLicenseInput && (<Box>@@ -176,7 +169,7 @@ function UpsellSection() {);return (- <Box mt="xl">+ <Box><SettingHeaderid="upsell"title={t`Looking for more?`}@@ -186,7 +179,7 @@ function UpsellSection() {</ExternalLink>)}`}/>- <Flex mt="md" justify="flex-end">+ <Flex mt="lg" justify="center"><ExplorePlansIllustration /></Flex><Divider />diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsxindex 5c3581b94fe..1ccf62d1877 100644--- a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx@@ -24,16 +24,40 @@ import { getBillingInfoId } from "../BillingInfo/utils";import { LicenseAndBillingSettings } from "./LicenseAndBillingSettings";+const selfHostedBillingInfo: BillingInfo = {+ version: "v1",+ content: [+ {+ name: "Visit the Metabase store to manage your account and billing preferences.",+ value: "Manage account",+ format: "string",+ display: "external-link",+ link: "https://store.metabase.com/account/manage/plans",+ },+ {+ name: "Cancel your Metabase Starter plan",+ value: "Cancel subscription",+ format: "string",+ display: "external-link",+ link: "https://store.metabase.com/account/cancel",+ },+ ],+};+const setup = async ({token = "token",is_env_setting = false,airgapEnabled = false,features = {},+ billingInfo,+ billingError = false,}: {token?: string | null;is_env_setting?: boolean;airgapEnabled?: boolean;features?: Partial<TokenFeatures> & { "metabase-store-managed"?: boolean };+ billingInfo?: BillingInfo;+ billingError?: boolean;}) => {const settings = createMockSettings({"airgap-enabled": airgapEnabled,@@ -61,6 +85,14 @@ const setup = async ({});setupUpdateSettingEndpoint();+ if (billingError) {+ fetchMock.get("path:/api/ee/billing", 500);+ } else if (billingInfo !== undefined) {+ fetchMock.get("path:/api/ee/billing", billingInfo);+ } else if (token && token !== "invalid") {+ fetchMock.get("path:/api/ee/billing", selfHostedBillingInfo);+ }+renderWithProviders(<LicenseAndBillingSettings />, {storeInitialState: {settings: createMockSettingsState(settings),@@ -140,11 +172,10 @@ describe("LicenseAndBilling", () => {],};- fetchMock.get("path:/api/ee/billing", mockData);-await setup({token: "valid",features: { "metabase-store-managed": true },+ billingInfo: mockData,});// test string format@@ -226,11 +257,10 @@ describe("LicenseAndBilling", () => {version: "v1",content: [plan, unsupportedFormat, unsupportedDisplay, invalidValue],};- fetchMock.get("path:/api/ee/billing", mockData);-await setup({token: "token",features: { "metabase-store-managed": true },+ billingInfo: mockData,});// test unsupported display, unsupported format, and invalid items do not render@@ -245,16 +275,77 @@ describe("LicenseAndBilling", () => {});it("renders error for billing info for store managed billing and info request fails", async () => {- fetchMock.get("path:/api/ee/billing", 500);await setup({token: "valid",features: { "metabase-store-managed": true },+ billingError: true,});expect(await screen.findByTestId("billing-info-error")).toBeInTheDocument();});- it("renders settings for non-store-managed billing with a valid token", async () => {+ it("renders billing links for store-managed self-hosted billing with a valid token", async () => {+ const mockData = selfHostedBillingInfo;+ const manageAccount = mockData.content?.[0];+ const cancelSubscription = mockData.content?.[1];++ await setup({+ token: "valid",+ features: { "metabase-store-managed": true },+ billingInfo: mockData,+ });++ expect(+ await screen.findByText(manageAccount?.name ?? ""),+ ).toBeInTheDocument();+ expect(+ await screen.findByText(cancelSubscription?.name ?? ""),+ ).toBeInTheDocument();++ const manageAccountLink = await screen.findByTestId(+ `billing-info-value-${getBillingInfoId(manageAccount!)}`,+ );+ expect(manageAccountLink).toHaveTextContent("Manage account");+ expect(manageAccountLink).toHaveAttribute(+ "href",+ "https://store.metabase.com/account/manage/plans",+ );++ const cancelSubscriptionLink = await screen.findByTestId(+ `billing-info-value-${getBillingInfoId(cancelSubscription!)}`,+ );+ expect(cancelSubscriptionLink).toHaveTextContent("Cancel subscription");+ expect(cancelSubscriptionLink).toHaveAttribute(+ "href",+ "https://store.metabase.com/account/cancel",+ );++ expect(+ screen.getByText(+ "Your license is active until Dec 31, 2099! Hope you’re enjoying it.",+ ),+ ).toBeInTheDocument();+ });++ it("renders go-to-store for store-managed billing when billing info has no content", async () => {+ await setup({+ token: "valid",+ features: { "metabase-store-managed": true },+ billingInfo: { version: "v1" },+ });++ expect(+ await screen.findByText(+ "Manage your Cloud account, including billing preferences, in your Metabase Store account.",+ ),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("link", { name: /Go to the Metabase Store/i }),+ ).toBeInTheDocument();+ expect(screen.queryByTestId("billing-info-error")).not.toBeInTheDocument();+ });++ it("renders email fallback for non-store-managed billing with a valid token", async () => {await setup({ token: "valid" });expect(@@ -275,7 +366,10 @@ describe("LicenseAndBilling", () => {});it("renders settings for airgapped token", async () => {- await setup({ token: "valid", airgapEnabled: true });+ await setup({+ token: "valid",+ airgapEnabled: true,+ });expect(await screen.findByText(