Skip to content

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

Design updates for static and interactive embedding settings (#64930)

Phoomparin Mano02467bd231ad
diff --git a/.eslintrc.js b/.eslintrc.js
index 5e048f908ce..4781fc35500 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -203,6 +203,7 @@ module.exports = {
"frontend/src/metabase/admin/**/*",
"frontend/src/metabase/setup/**/*",
"enterprise/frontend/src/metabase-enterprise/whitelabel/**/*",
+ "enterprise/frontend/src/metabase-enterprise/embedding/**/*",
"frontend/lint/**/*",
"*.stories.*",
"**/.storybook/*",
diff --git a/e2e/test/scenarios/admin/i18n/content-translation/helpers/e2e-content-translation-helpers.ts b/e2e/test/scenarios/admin/i18n/content-translation/helpers/e2e-content-translation-helpers.ts
index 57850a73f28..d0e848590d0 100644
--- a/e2e/test/scenarios/admin/i18n/content-translation/helpers/e2e-content-translation-helpers.ts
+++ b/e2e/test/scenarios/admin/i18n/content-translation/helpers/e2e-content-translation-helpers.ts
@@ -21,7 +21,7 @@ export const uploadTranslationDictionary = (rows: DictionaryArray) => {
cy.wait("@getSettings");
cy.findByTestId("content-localization-setting").findByText(
- /Upload translation dictionary/,
+ /Upload edited translation dictionary/,
);
cy.get("#content-translation-dictionary-upload-input").selectFile(
diff --git a/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts b/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts
index ca344ac2943..53274257c81 100644
--- a/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts
+++ b/e2e/test/scenarios/admin/i18n/content-translation/upload-and-download.cy.spec.ts
@@ -54,7 +54,7 @@ describe("scenarios > admin > embedding > static embedding> content translation"
uploadTranslationDictionaryViaAPI(germanFieldNames);
cy.visit("/admin/embedding/static");
cy.findByTestId("content-translation-configuration")
- .button(/Download translation dictionary/i)
+ .button(/Get translation dictionary template/i)
.click();
const downloadsFolder = Cypress.config("downloadsFolder");
cy.readFile(
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/ContentTranslationConfiguration.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/ContentTranslationConfiguration.tsx
index 8058c6662e0..b635cd84850 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/ContentTranslationConfiguration.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/ContentTranslationConfiguration.tsx
@@ -1,7 +1,7 @@
+import cx from "classnames";
import {
type ChangeEvent,
type Dispatch,
- type PropsWithChildren,
type ReactNode,
type SetStateAction,
useCallback,
@@ -17,6 +17,7 @@ import ExternalLink from "metabase/common/components/ExternalLink";
import Markdown from "metabase/common/components/Markdown";
import { UploadInput } from "metabase/common/components/upload";
import { useConfirmation, useDocsUrl, useToast } from "metabase/common/hooks";
+import CS from "metabase/css/core/index.css";
import {
Form,
FormProvider,
@@ -32,7 +33,7 @@ import {
Loader,
Stack,
Text,
- type TextProps,
+ Title,
} from "metabase/ui";
import { useUploadContentTranslationDictionaryMutation } from "metabase-enterprise/api";
@@ -114,87 +115,92 @@ export const ContentTranslationConfiguration = () => {
[isDownloadInProgress],
);
+ // eslint-disable-next-line no-literal-metabase-strings -- This string only shows for admins.
+ const uploadDescription = t`Upload a translation dictionary to translate strings both in Metabase content (like dashboard titles) and in the data itself (like column names and values). The dictionary must be a CSV with these columns: **Locale Code**, **String**, **Translation**.`;
+
return (
<ErrorBoundary>
- <SettingsSection
- title={t`Translate embedded dashboards and questions`}
- data-testid={"content-translation-configuration"}
- >
- <Stack gap="sm">
- {/* eslint-disable-next-line no-literal-metabase-strings -- Metabase settings */}
- <DescriptionText>{t`Upload a translation dictionary to translate strings both in Metabase content (like dashboard titles) and in the data itself (like column names and values).`}</DescriptionText>
- <DescriptionText>{t`The dictionary must be a CSV with these columns:`}</DescriptionText>
- <List ms="sm">
- <List.Item>{t`Locale Code`}</List.Item>
- <List.Item>{t`String`}</List.Item>
- <List.Item>{t`Translation`}</List.Item>
- </List>
- <DescriptionText>{t`Don't put any sensitive data in the dictionary, since anyone can see the dictionary—including viewers of public links.`}</DescriptionText>
- <DescriptionText>{t`Uploading a new dictionary will replace the existing dictionary.`}</DescriptionText>
- <Markdown
- components={{
- em: ({ children }: { children: ReactNode }) => (
- <ExternalLink href={availableLocalesDocsUrl}>
- {children}
- </ExternalLink>
- ),
- }}
- >
- {t`See a list of *supported locales*.`}
- </Markdown>
- </Stack>
- <Group>
- <Button
- onClick={triggerDownload}
- leftSection={
- showDownloadingIndicator ? null : (
- <Icon name="download" c="brand" />
- )
- }
- miw="calc(50% - 0.5rem)"
- style={{ flexGrow: 1 }}
- disabled={isDownloadInProgress}
- >
- {showDownloadingIndicator ? (
- <Loader size="sm" />
- ) : (
- t`Download translation dictionary`
- )}
- </Button>
- <FormProvider
- // We're only using Formik to make the appearance of the submit button
- // depend on the form's status. We're not using Formik's other features
- // here.
- initialValues={{}}
- onSubmit={() => {}}
- >
- <UploadForm setErrorMessages={setUploadErrorMessages} />
- </FormProvider>
- </Group>
- {downloadErrorMessage && (
- <Text role="alert" c="danger">
- {downloadErrorMessage}
- </Text>
- )}
- {!!uploadErrorMessages.length && (
- <Stack gap="xs">
- <Text role="alert" c="error">
- {ngettext(
- msgid`We couldn't upload the file due to this error:`,
- `We couldn't upload the file due to these errors:`,
- uploadErrorMessages.length,
+ <SettingsSection data-testid="content-translation-configuration">
+ <Stack>
+ <Stack gap="sm">
+ <Title
+ fz="lg"
+ lh="xs"
+ fw={600}
+ >{t`Translate embedded dashboards and questions`}</Title>
+
+ <Markdown c="text-secondary">{uploadDescription}</Markdown>
+
+ <Markdown
+ c="text-secondary"
+ components={{
+ em: ({ children }: { children: ReactNode }) => (
+ <ExternalLink
+ href={availableLocalesDocsUrl}
+ className={cx(CS.textBold, CS.link)}
+ >
+ {children}
+ </ExternalLink>
+ ),
+ }}
+ >
+ {t`Don't put any sensitive data in the dictionary, since anyone can see the dictionary—including viewers of public links. Uploading a new dictionary will replace the existing dictionary. See a list of _supported locales_.`}
+ </Markdown>
+ </Stack>
+
+ <Group>
+ <Button
+ onClick={triggerDownload}
+ leftSection={
+ showDownloadingIndicator ? null : (
+ <Icon name="download" c="brand" />
+ )
+ }
+ miw="calc(50% - 0.5rem)"
+ fw="normal"
+ style={{ flexGrow: 1 }}
+ disabled={isDownloadInProgress}
+ >
+ {showDownloadingIndicator ? (
+ <Loader size="sm" />
+ ) : (
+ t`Get translation dictionary template`
)}
+ </Button>
+ <FormProvider
+ // We're only using Formik to make the appearance of the submit button
+ // depend on the form's status. We're not using Formik's other features
+ // here.
+ initialValues={{}}
+ onSubmit={() => {}}
+ >
+ <UploadForm setErrorMessages={setUploadErrorMessages} />
+ </FormProvider>
+ </Group>
+ {downloadErrorMessage && (
+ <Text role="alert" c="danger">
+ {downloadErrorMessage}
</Text>
- <List withPadding>
- {uploadErrorMessages.map((errorMessage) => (
- <List.Item key={errorMessage} role="alert" c="danger">
- {errorMessage}
- </List.Item>
- ))}
- </List>
- </Stack>
- )}
- {/* </Stack> */}
+ )}
+ {!!uploadErrorMessages.length && (
+ <Stack gap="xs">
+ <Text role="alert" c="error">
+ {ngettext(
+ msgid`We couldn't upload the file due to this error:`,
+ `We couldn't upload the file due to these errors:`,
+ uploadErrorMessages.length,
+ )}
+ </Text>
+ <List withPadding>
+ {uploadErrorMessages.map((errorMessage) => (
+ <List.Item key={errorMessage} role="alert" c="danger">
+ {errorMessage}
+ </List.Item>
+ ))}
+ </List>
+ </Stack>
+ )}
+ </Stack>
</SettingsSection>
</ErrorBoundary>
);
@@ -328,7 +334,10 @@ const UploadForm = ({
label={
<Group gap="sm">
<Icon name="upload" c="brand" />
- <Text c="inherit">{t`Upload translation dictionary`}</Text>
+ <Text
+ c="inherit"
+ fw="normal"
+ >{t`Upload edited translation dictionary`}</Text>
</Group>
}
successLabel={
@@ -363,6 +372,3 @@ const UploadForm = ({
</Form>
);
};
-const DescriptionText = (props: PropsWithChildren<TextProps>) => (
- <Text c="inherit" lh="1.5" {...props} />
-);
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/tests/common.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/tests/common.unit.spec.tsx
index f9b16e8ffe6..f3b3c647dd5 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/tests/common.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/components/ContentTranslationConfiguration/tests/common.unit.spec.tsx
@@ -24,11 +24,11 @@ describe("ContentTranslationConfiguration", () => {
expect(
screen.getByText(
- "Upload a translation dictionary to translate strings both in Metabase content (like dashboard titles) and in the data itself (like column names and values).",
+ /Upload a translation dictionary to translate strings both in Metabase content \(like dashboard titles\) and in the data itself \(like column names and values\)/,
),
).toBeInTheDocument();
expect(
- screen.getByText("The dictionary must be a CSV with these columns:"),
+ screen.getByText(/The dictionary must be a CSV with these columns:/),
).toBeInTheDocument();
expect(screen.getByText("Locale Code")).toBeInTheDocument();
expect(screen.getByText("String")).toBeInTheDocument();
@@ -40,7 +40,7 @@ describe("ContentTranslationConfiguration", () => {
expect(
screen.getByText(
- "Don't put any sensitive data in the dictionary, since anyone can see the dictionary—including viewers of public links.",
+ /Don't put any sensitive data in the dictionary, since anyone can see the dictionary—including viewers of public links/,
),
).toBeInTheDocument();
});
@@ -50,7 +50,7 @@ describe("ContentTranslationConfiguration", () => {
expect(
screen.getByText(
- "Uploading a new dictionary will replace the existing dictionary.",
+ /Uploading a new dictionary will replace the existing dictionary/,
),
).toBeInTheDocument();
});
@@ -60,11 +60,13 @@ describe("ContentTranslationConfiguration", () => {
expect(
screen.getByRole("button", {
- name: /Download translation dictionary/i,
+ name: /Get translation dictionary template/i,
}),
).toBeInTheDocument();
expect(
- screen.getByRole("button", { name: /Upload translation dictionary/i }),
+ screen.getByRole("button", {
+ name: /Upload edited translation dictionary/i,
+ }),
).toBeInTheDocument();
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/embedding/components/EmbeddingAppOriginDescription/EmbeddingAppOriginDescription.tsx b/enterprise/frontend/src/metabase-enterprise/embedding/components/EmbeddingAppOriginDescription/EmbeddingAppOriginDescription.tsx
index a9ab2129b93..d6b2589347a 100644
--- a/enterprise/frontend/src/metabase-enterprise/embedding/components/EmbeddingAppOriginDescription/EmbeddingAppOriginDescription.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/embedding/components/EmbeddingAppOriginDescription/EmbeddingAppOriginDescription.tsx
@@ -1,12 +1,15 @@
+import cx from "classnames";
import { jt, t } from "ttag";
import ExternalLink from "metabase/common/components/ExternalLink";
+import CS from "metabase/css/core/index.css";
export const EmbeddingAppOriginDescription = () => {
return jt`Enter the origins for the websites or web apps where you want to allow embedding, separated by a space. Here are the ${(
<ExternalLink
key="specs"
href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"
+ className={cx(CS.textBold, CS.link)}
>
{t`exact specifications`}
</ExternalLink>
diff --git a/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.tsx b/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.tsx
index 4590cfb9a3c..b7b6a7c724d 100644
--- a/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.tsx
@@ -8,13 +8,10 @@ import {
SettingsPageWrapper,
SettingsSection,
} from "metabase/admin/components/SettingsSection";
-import { EmbeddingToggle } from "metabase/admin/settings/components/EmbeddingSettings/EmbeddingToggle";
-import { SettingHeader } from "metabase/admin/settings/components/SettingHeader";
+import { EmbeddingSettingsCard } from "metabase/admin/settings/components/EmbeddingSettings";
import { AdminSettingInput } from "metabase/admin/settings/components/widgets/AdminSettingInput";
import { UpsellDevInstances } from "metabase/admin/upsells";
-import ExternalLink from "metabase/common/components/ExternalLink";
import { useDocsUrl } from "metabase/common/hooks";
-import { Box, Button } from "metabase/ui";
import { EmbeddingAppOriginDescription } from "./EmbeddingAppOriginDescription";
@@ -26,7 +23,6 @@ const utmTags = {
};
export function InteractiveEmbeddingSettings() {
- // eslint-disable-next-line no-unconditional-metabase-links-render -- This is used in admin settings
const { url: quickStartUrl } = useDocsUrl(
"embedding/interactive-embedding-quick-start-guide",
{
@@ -36,25 +32,18 @@ export function InteractiveEmbeddingSettings() {
return (
<SettingsPageWrapper title={t`Interactive embedding`}>
- <SettingsSection>
- <EmbeddingToggle
- settingKey="enable-embedding-interactive"
- label={t`Enable interactive embedding`}
- />
-
- <Box>
- <SettingHeader id="get-started" title={t`Get started`} />
- <Button
- mt="xs"
- variant="outline"
- component={ExternalLink}
- href={quickStartUrl}
- >{t`Check out the Quickstart`}</Button>
- </Box>
+ <EmbeddingSettingsCard
+ title={t`Enable interactive embedding`}
+ description={t`Embed the full power of Metabase into your application to build a custom analytics experience and programmatically manage dashboards and data.`}
+ settingKey="enable-embedding-interactive"
+ links={[{ icon: "bolt", title: t`Quick start`, href: quickStartUrl }]}
+ />
+ <SettingsSection>
<AdminSettingInput
name="embedding-app-origins-interactive"
title={t`Authorized origins`}
+ titleProps={{ fz: "lg", mb: "xs" }}
description={<EmbeddingAppOriginDescription />}
placeholder="https://*.example.com"
inputType="text"
diff --git a/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.unit.spec.tsx
index d7b1d21d921..cfc41097bf6 100644
--- a/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/embedding/components/InteractiveEmbeddingSettings.unit.spec.tsx
@@ -42,7 +42,9 @@ describe("InteractiveEmbeddingSettings", () => {
it("should toggle interactive embedding on", async () => {
await setup({ enabled: false });
- const toggle = await screen.findByText("Enable interactive embedding");
+ const toggle = await screen.findByLabelText(
+ "Enable interactive embedding toggle",
+ );
await userEvent.click(toggle);
const puts = await findRequests("PUT");
@@ -55,9 +57,7 @@ describe("InteractiveEmbeddingSettings", () => {
it("should show quickstart link", async () => {
await setup({ enabled: true });
- expect(
- await screen.findByText("Check out the Quickstart"),
- ).toBeInTheDocument();
+ expect(await screen.findByText("Quick start")).toBeInTheDocument();
});
it("should allow changing authorized origins", async () => {
diff --git a/frontend/src/metabase/admin/components/RelatedSettingsSection/RelatedSettingsSection.module.css b/frontend/src/metabase/admin/components/RelatedSettingsSection/RelatedSettingsSection.module.css
index edb960654c0..b940ab4ad27 100644
--- a/frontend/src/metabase/admin/components/RelatedSettingsSection/RelatedSettingsSection.module.css
+++ b/frontend/src/metabase/admin/components/RelatedSettingsSection/RelatedSettingsSection.module.css
@@ -1,3 +1,3 @@
.relatedSettingCard:hover {
- background: var(--mb-color-background-hover);
+ background: var(--mb-color-background-hover-light);
}
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
index e77d4f7f070..5c43603d1a2 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx
@@ -22,9 +22,8 @@ import {
import { Box, Button, Group, HoverCard, Icon, Stack, Text } from "metabase/ui";
import { AdminSettingInput } from "../../widgets/AdminSettingInput";
-
-import S from "./EmbeddingSdkSettings.module.css";
-import { SdkSettingsCard } from "./SdkSettingsCard/SdkSettingsCard";
+import S from "../EmbeddingSettings.module.css";
+import { EmbeddingSettingsCard } from "../EmbeddingSettingsCard";
const utmTags = {
utm_source: "product",
@@ -130,7 +129,7 @@ export function EmbeddingSdkSettings() {
return (
<SettingsPageWrapper title={t`Modular embedding`}>
- <SdkSettingsCard
+ <EmbeddingSettingsCard
title={t`Embedded Analytics JS`}
description={t`An easy-to-use library that lets you embed Metabase entities like charts, dashboards, or even the query builder into your own application using customizable components.`}
settingKey="enable-embedding-simple"
@@ -161,9 +160,10 @@ export function EmbeddingSdkSettings() {
</Link>
)
}
+ testId="sdk-setting-card"
/>
- <SdkSettingsCard
+ <EmbeddingSettingsCard
title={t`SDK for React`}
description={t`Embed the full power of Metabase into your application to build a custom analytics experience and programmatically manage dashboards and data.`}
settingKey="enable-embedding-sdk"
@@ -180,6 +180,7 @@ export function EmbeddingSdkSettings() {
},
]}
alertInfoText={apiKeyBannerText}
+ testId="sdk-setting-card"
/>
<Box py="lg" px="xl" className={S.SectionCard}>
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecretKeyWidget.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecretKeyWidget.tsx
index fcd3568c37c..f938c05e5f5 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecretKeyWidget.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecretKeyWidget.tsx
@@ -4,6 +4,7 @@ import { t } from "ttag";
import { SetByEnvVarWrapper } from "metabase/admin/settings/components/widgets/AdminSettingInput";
import { useAdminSetting } from "metabase/api/utils";
import { ConfirmModal } from "metabase/common/components/ConfirmModal";
+import { CopyButton } from "metabase/common/components/CopyButton";
import InputBlurChange from "metabase/common/components/InputBlurChange";
import { UtilApi } from "metabase/services";
import { Box, Button, Flex } from "metabase/ui";
@@ -31,25 +32,28 @@ export const EmbeddingSecretKeyWidget = () => {
};
return (
- <Box data-testid="embedding-secret-key-setting" maw="36rem">
+ <Box data-testid="embedding-secret-key-setting">
<SettingHeader
id="embedding-secret-key"
title={t`Embedding secret key`}
+ titleProps={{ fz: "lg", mb: "xs" }}
description={t`Standalone Embed Secret Key used to sign JSON Web Tokens for requests to /api/embed endpoints. This lets you create a secure environment limited to specific users or organizations.`}
/>
<SetByEnvVarWrapper
settingDetails={settingDetails}
settingKey="embedding-secret-key"
>
- <Flex maw="52rem" py="md" gap="md" w="full">
+ <Flex gap="md" w="100%">
<InputBlurChange
value={value}
onBlurChange={(e) => handleChange(e.target.value)}
+ rightSection={value && <CopyButton value={value} />}
+ w="100%"
/>
{value ? (
<>
<Button
- variant="filled"
+ variant="outline"
onClick={openModal}
style={{ flexShrink: 0 }}
>{t`Regenerate key`}</Button>
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.module.css b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings.module.css
similarity index 100%
rename from frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.module.css
rename to frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings.module.css
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/SdkSettingsCard/SdkSettingsCard.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettingsCard.tsx
similarity index 82%
rename from frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/SdkSettingsCard/SdkSettingsCard.tsx
rename to frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettingsCard.tsx
index 997977a28bc..834d741cd6a 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/SdkSettingsCard/SdkSettingsCard.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettingsCard.tsx
@@ -10,12 +10,12 @@ import {
Text,
} from "metabase/ui";
-import { EmbeddingToggle } from "../../EmbeddingToggle";
-import S from "../EmbeddingSdkSettings.module.css";
+import S from "./EmbeddingSettings.module.css";
+import { EmbeddingToggle } from "./EmbeddingToggle";
type LinkItem = { icon: IconName; title: string; href: string };
-export function SdkSettingsCard({
+export function EmbeddingSettingsCard({
title,
description,
settingKey,
@@ -24,30 +24,32 @@ export function SdkSettingsCard({
rightSideContent,
alertInfoText,
actionButton,
+ testId,
}: {
title: string;
description: string;
- settingKey: "enable-embedding-sdk" | "enable-embedding-simple";
+ settingKey:
+ | "enable-embedding-sdk"
+ | "enable-embedding-simple"
+ | "enable-embedding-static"
+ | "enable-embedding-interactive";
isFeatureEnabled?: boolean;
links?: LinkItem[];
rightSideContent?: React.ReactNode;
alertInfoText?: React.ReactNode;
actionButton?: React.ReactNode;
+ testId?: string;
}) {
const hasLinksContent = links && links.length > 0;
return (
- <Flex
- direction="column"
- className={S.SectionCard}
- data-testid="sdk-setting-card"
- >
- <Stack gap="sm" px="xl" py="lg">
- <Text fz="h3" fw={600} c="text-dark">
+ <Flex direction="column" className={S.SectionCard} data-testid={testId}>
+ <Stack gap="xs" px="xl" py="lg">
+ <Text fw={600} c="text-dark" fz="h4">
{title}
</Text>
- <Text c="var(--mb-color-text-secondary)" lh="lg" mb="md">
+ <Text c="var(--mb-color-text-secondary)" lh="lg" mb="md" maw="38rem">
{description}
</Text>
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.tsx
index b023a10e64a..9620e11d959 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.tsx
@@ -17,27 +17,37 @@ import { SettingTitle } from "../SettingHeader";
import { EmbeddedResources } from "../widgets/PublicLinksListing/EmbeddedResources";
import { EmbeddingSecretKeyWidget } from "./EmbeddingSecretKeyWidget";
-import { EmbeddingToggle } from "./EmbeddingToggle";
+import { EmbeddingSettingsCard } from "./EmbeddingSettingsCard";
export function StaticEmbeddingSettings() {
const isStaticEmbeddingEnabled = useSetting("enable-embedding-static");
return (
<SettingsPageWrapper title={t`Static embedding`}>
+ <EmbeddingSettingsCard
+ title={t`Enable static embedding`}
+ description={t`A secure way to embed charts and dashboards when you don’t want to offer ad-hoc querying or chart drill-through.`}
+ settingKey="enable-embedding-static"
+ />
+
<SettingsSection>
- <EmbeddingToggle
- settingKey="enable-embedding-static"
- label={t`Enable static embedding`}
- />
<EmbeddingSecretKeyWidget />
+ </SettingsSection>
- {isStaticEmbeddingEnabled && (
+ {isStaticEmbeddingEnabled && (
+ <SettingsSection>
<Box data-testid="embedded-resources">
- <SettingTitle id="static-embeds">{t`Manage embeds`}</SettingTitle>
+ <SettingTitle
+ id="static-embeds"
+ fz="lg"
+ mb="md"
+ >{t`Published embeds`}</SettingTitle>
+
<EmbeddedResources />
</Box>
- )}
- </SettingsSection>
+ </SettingsSection>
+ )}
+
<PLUGIN_CONTENT_TRANSLATION.ContentTranslationConfiguration />
<RelatedSettingsSection items={getStaticEmbeddingRelatedSettingItems()} />
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.unit.spec.tsx
index 62a9c371c92..799b6af9c7c 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/StaticEmbeddingSettings.unit.spec.tsx
@@ -54,9 +54,15 @@ describe("StaticEmbeddingSettings", () => {
it("should toggle static embedding on", async () => {
await setup({ enabled: false });
- const toggle = await screen.findByText("Enable static embedding");
+
+ await screen.findByText("Enable static embedding");
+
+ const toggle = screen.getByRole("switch", {
+ name: /Enable static embedding toggle/i,
+ });
await userEvent.click(toggle);
+
const puts = await findRequests("PUT");
expect(puts).toHaveLength(1);
const [{ url, body }] = puts;
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/index.ts b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/index.ts
index 406ffdb759c..8f994457931 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/index.ts
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/index.ts
@@ -1,3 +1,5 @@
export { StaticEmbeddingSettings } from "./StaticEmbeddingSettings";
export { EmbeddingSdkSettings } from "./EmbeddingSdkSettings/EmbeddingSdkSettings";
export { EmbeddingSecuritySettings } from "./EmbeddingSecuritySettings";
+export { EmbeddingSettingsCard } from "./EmbeddingSettingsCard";
+export { EmbeddingToggle } from "./EmbeddingToggle";
diff --git a/frontend/src/metabase/admin/settings/components/SettingHeader/SettingHeader.tsx b/frontend/src/metabase/admin/settings/components/SettingHeader/SettingHeader.tsx
index 0334c54d536..f913a16aab7 100644
--- a/frontend/src/metabase/admin/settings/components/SettingHeader/SettingHeader.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingHeader/SettingHeader.tsx
@@ -1,20 +1,24 @@
import type React from "react";
-import type { BoxProps } from "metabase/ui";
+import type { BoxProps, TextProps } from "metabase/ui";
import { Box, Text } from "metabase/ui";
export const SettingHeader = ({
id,
description,
title,
+ titleProps,
...boxProps
}: {
id: string;
description?: string | React.ReactNode;
title?: string;
+ titleProps?: TextProps;
} & BoxProps) => (
<Box {...boxProps}>
- <SettingTitle id={id}>{title}</SettingTitle>
+ <SettingTitle {...titleProps} id={id}>
+ {title}
+ </SettingTitle>
{!!description && (
<Text mb="sm" maw="38rem" lh="xl" c="text-medium">
{description}
@@ -26,9 +30,10 @@ export const SettingHeader = ({
export const SettingTitle = ({
id,
children,
-}: {
+ ...props
+}: TextProps & {
id?: string;
- children: React.ReactNode;
+ children?: React.ReactNode;
}) => (
<Text
htmlFor={id}
@@ -36,6 +41,7 @@ export const SettingTitle = ({
c="text-dark"
fw="bold"
display="inline-block"
+ {...props}
>
{children}
</Text>
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
index be1983d7c06..4e79caad823 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
@@ -12,6 +12,7 @@ import {
Stack,
Switch,
TextInput,
+ type TextProps,
Textarea,
} from "metabase/ui";
import type {
@@ -57,6 +58,7 @@ type InputDetails =
export type AdminSettingInputProps<S extends EnterpriseSettingKey> = {
name: S;
title?: string;
+ titleProps?: TextProps;
description?: React.ReactNode;
hidden?: boolean;
disabled?: boolean;
@@ -71,6 +73,7 @@ export type AdminSettingInputProps<S extends EnterpriseSettingKey> = {
*/
export function AdminSettingInput<SettingName extends EnterpriseSettingKey>({
title,
+ titleProps,
description,
name,
inputType,
@@ -106,6 +109,7 @@ export function AdminSettingInput<SettingName extends EnterpriseSettingKey>({
<SettingHeader
id={name}
title={title}
+ titleProps={titleProps}
description={description ?? settingDescription}
/>
{settingDetails?.is_env_setting && settingDetails?.env_name ? (
diff --git a/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/EmbeddedResources.tsx b/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/EmbeddedResources.tsx
index ab2f662e897..bf73afd6619 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/EmbeddedResources.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/EmbeddedResources.tsx
@@ -22,15 +22,15 @@ const DashboardEmbeddedResources = () => {
const query = useListEmbeddableDashboardsQuery(undefined, refetchSettings);
return (
- <>
- <SettingHeader id="embedded-dashboards" title={t`Embedded Dashboards`} />
+ <Stack gap="xs">
+ <SettingHeader id="embedded-dashboards" title={t`Embedded dashboards`} />
<PublicLinksListing<GetEmbeddableDashboard>
data-testid="-embedded-dashboards-setting"
getUrl={(dashboard) => Urls.dashboard(dashboard)}
noLinksMessage={t`No dashboards have been embedded yet.`}
{...query}
/>
- </>
+ </Stack>
);
};
@@ -38,21 +38,21 @@ export const QuestionEmbeddedResources = () => {
const query = useListEmbeddableCardsQuery(undefined, refetchSettings);
return (
- <>
- <SettingHeader id="embedded-questions" title={t`Embedded Questions`} />
+ <Stack gap="xs">
+ <SettingHeader id="embedded-questions" title={t`Embedded questions`} />
<PublicLinksListing<GetEmbeddableCard>
data-testid="-embedded-questions-setting"
getUrl={(question) => Urls.question(question)}
noLinksMessage={t`No questions have been embedded yet.`}
{...query}
/>
- </>
+ </Stack>
);
};
export const EmbeddedResources = () => {
return (
- <Stack gap="md" maw="50rem">
+ <Stack gap="lg" maw="50rem">
<DashboardEmbeddedResources />
<QuestionEmbeddedResources />
</Stack>
diff --git a/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/PublicLinksListing.tsx b/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/PublicLinksListing.tsx
index 497b3c55f3c..f9e78824124 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/PublicLinksListing.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/PublicLinksListing/PublicLinksListing.tsx
@@ -5,10 +5,9 @@ import { t } from "ttag";
import { ConfirmModal } from "metabase/common/components/ConfirmModal";
import ExternalLink from "metabase/common/components/ExternalLink";
import Link from "metabase/common/components/Link";
-import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
import AdminS from "metabase/css/admin.module.css";
import CS from "metabase/css/core/index.css";
-import { ActionIcon, Icon, Loader } from "metabase/ui";
+import { ActionIcon, Box, Icon, Loader, Text } from "metabase/ui";
export const PublicLinksListing = <
T extends { id: string | number; name: string },
@@ -37,7 +36,17 @@ export const PublicLinksListing = <
}
if (data.length === 0) {
- return <LoadingAndErrorWrapper error={noLinksMessage} />;
+ return (
+ <Box
+ bg="bg-light"
+ bd="1px solid var(--mb-color-border)"
+ bdrs="xs"
+ px="md"
+ py="md"
+ >
+ <Text c="text-secondary">{noLinksMessage}</Text>
+ </Box>
+ );
}
return (
@@ -52,20 +61,15 @@ export const PublicLinksListing = <
</thead>
<tbody>
{data.map((item) => {
- const internalUrl = getUrl?.(item);
+ const internalUrl = getUrl(item);
const publicUrl = getPublicUrl?.(item);
return (
<tr key={item.id}>
- <td>
- {internalUrl ? (
- <Link to={internalUrl} className={CS.textWrap}>
- {item.name}
- </Link>
- ) : (
- item.name
- )}
- </td>
+ <Link to={internalUrl} className={cx(CS.flex, CS.fullWidth)}>
+ <td>{item.name}</td>
+ </Link>
+
{publicUrl && (
<td>
<ExternalLink
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/StepperWithCards/StepperWithCards.module.css b/frontend/src/metabase/embedding/embedding-hub/components/StepperWithCards/StepperWithCards.module.css
index 2d54b5e21f2..9aeb28cffad 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/StepperWithCards/StepperWithCards.module.css
+++ b/frontend/src/metabase/embedding/embedding-hub/components/StepperWithCards/StepperWithCards.module.css
@@ -67,7 +67,7 @@
}
.stepCard:not(.lockedStepCard):hover {
- background-color: var(--mb-color-background-hover);
+ background-color: var(--mb-color-background-hover-light);
}
.stepCard.nextStepCard {
diff --git a/frontend/src/metabase/ui/components/icons/Icon/icons/embed_static.svg b/frontend/src/metabase/ui/components/icons/Icon/icons/embed_static.svg
index 51dec897688..d3434d3d6df 100644
--- a/frontend/src/metabase/ui/components/icons/Icon/icons/embed_static.svg
+++ b/frontend/src/metabase/ui/components/icons/Icon/icons/embed_static.svg
@@ -1,7 +1,3 @@
-<svg viewBox="0 0 16 16" fill="currentcolor" xmlns="http://www.w3.org/2000/svg">
- <path d="M1 3C1 2.44772 1.44772 2 2 2H14C14.5523 2 15 2.44772 15 3V4H1V3Z" />
- <path d="M1 5H3V13H2C1.44772 13 1 12.5523 1 12V5Z" />
- <path d="M4 6C4 5.44772 4.44772 5 5 5H14C14.5523 5 15 5.44772 15 6V8H4V6Z" />
- <path d="M4 9H9V13H5C4.44772 13 4 12.5523 4 12V9Z" />
- <path d="M10 9H15V12C15 12.5523 14.5523 13 14 13H10V9Z" />
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentcolor">
+ <path d="M13.6533 2.00781C14.4097 2.08461 15 2.72334 15 3.5V12.5C15 13.2767 14.4097 13.9154 13.6533 13.9922L13.5 14H2.5C1.67157 14 1 13.3284 1 12.5V3.5C1 2.67157 1.67157 2 2.5 2H13.5L13.6533 2.00781ZM6 12.5H13.5V7H6V12.5ZM2.5 12.5H4.5V7H2.5V12.5ZM2.5 5.5H13.5V3.5H2.5V5.5Z" />
</svg>