Skip to content

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

Integration branch for embed wizard and guide UX improvements (#74497)

Sébastien454aff6e7dfe
diff --git a/e2e/support/helpers/e2e-embedding-helpers.js b/e2e/support/helpers/e2e-embedding-helpers.js
index 0d9c851be73..99a7402a356 100644
--- a/e2e/support/helpers/e2e-embedding-helpers.js
+++ b/e2e/support/helpers/e2e-embedding-helpers.js
@@ -313,7 +313,7 @@ export function unpublishChanges(apiPath, callback) {
}
export function getParametersContainer() {
- return cy.findByLabelText("Configuring parameters");
+ return cy.findByTestId("parameters-container");
}
export function setEmbeddingParameter(name, value) {
diff --git a/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts b/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
index b07ab411625..32e37270364 100644
--- a/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
+++ b/e2e/support/helpers/e2e-embedding-iframe-sdk-setup-helpers.ts
@@ -6,16 +6,24 @@ export const embedModalEnableEmbeddingCard = () =>
export const embedModalEnableEmbedding = () => {
cy.get("body").then(($body) => {
- const isEmbeddingDisabled =
- $body.find('[data-testid="enable-embedding-card"]').length > 0;
+ const $card = $body.find('[data-testid="enable-embedding-card"]');
- if (isEmbeddingDisabled) {
- embedModalEnableEmbeddingCard().within(() => {
- cy.findByText(
- /(Agree and (continue|enable)|Enable and continue)/,
- ).click();
- });
+ // No enable card on screen — terms were already accepted before mount.
+ if ($card.length === 0) {
+ return;
}
+
+ // Once accepted, the action button becomes disabled and shows "Enabled".
+ // The card itself stays mounted, so guard against double-clicks.
+ if ($card.find("button:disabled").length > 0) {
+ return;
+ }
+
+ embedModalEnableEmbeddingCard().within(() => {
+ cy.findByText(
+ /(Agree and (continue|enable)|Enable and continue)/,
+ ).click();
+ });
});
};
diff --git a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
index b55136455ce..7e7a87c6ec1 100644
--- a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
@@ -27,7 +27,7 @@ describe("scenarios - embedding hub", () => {
.should("exist");
});
- it('"Create a dashboard" card should show return toast after saving x-ray', () => {
+ it('"Create a dashboard" card should save the x-ray and show a success toast without leaving the guide', () => {
cy.visit("/admin/embedding/setup-guide");
cy.log("Find and click on 'Create a dashboard' card");
@@ -43,20 +43,13 @@ describe("scenarios - embedding hub", () => {
H.pickEntity({ path: ["Databases", "Sample Database", "Accounts"] });
});
- cy.log("Should navigate to auto dashboard with from param");
- cy.url().should("include", "/auto/dashboard/table/");
- cy.url().should("include", "returnToEmbeddingSetupGuide=");
-
- cy.log("Wait for x-ray dashboard to load and save it");
- cy.findByRole("button", { name: "Save this", timeout: 30_000 }).click();
-
- cy.log("Should show modal prompting to return to setup guide");
- H.modal().within(() => {
- cy.findByText("Dashboard saved!").should("be.visible");
- cy.findByText("Return to the setup guide").click();
- });
+ cy.log("Should show a success toast with a link to the new dashboard");
+ H.undoToast()
+ .findByText("Your dashboard was saved", { timeout: 30_000 })
+ .should("be.visible");
+ H.undoToast().findByText("See it").should("be.visible");
- cy.log("Should navigate back to the setup guide");
+ cy.log("Should remain on the setup guide");
cy.url().should("include", "/admin/embedding/setup-guide");
});
@@ -169,18 +162,24 @@ describe("scenarios - embedding hub", () => {
.findByText("Get embed snippet")
.click();
- cy.log("choose dashboard experience");
H.modal()
.first()
.within(() => {
+ cy.log("switch to guest auth");
+ cy.findByLabelText("Guest").click();
+ cy.log("choose dashboard experience");
cy.findByText("Dashboard").click();
- cy.findByText("Next").click();
+ cy.log("pick a dashboard");
+ cy.findByTestId("embed-browse-entity-button").click();
});
- cy.log("pick a dashboard");
- H.modal().first().findByTestId("embed-browse-entity-button").click();
H.entityPickerModal().findByText("Test Dashboard").click();
- H.modal().first().findByText("Next").click();
+
+ H.modal()
+ .first()
+ .within(() => {
+ cy.findByText("Next").click();
+ });
cy.log("publish the embed");
H.publishChanges("dashboard");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/common-ee.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/common-ee.cy.spec.ts
index ae5794f557a..08fe84ed190 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/common-ee.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/common-ee.cy.spec.ts
@@ -50,6 +50,7 @@ describe("scenarios > embedding > sdk iframe embed setup > common", () => {
navigateToGetCodeStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
+ preselectGuest: true,
});
H.publishChanges("dashboard");
@@ -114,32 +115,6 @@ describe("scenarios > embedding > sdk iframe embed setup > common", () => {
cy.findByLabelText("Metabase account (SSO)").should("be.enabled");
});
- it("should reset experience to a default only when switching from SSO to Guest auth type and the current experience does not support guest embeds", () => {
- visitNewEmbedPage();
-
- getEmbedSidebar().within(() => {
- cy.findByLabelText("Metabase account (SSO)").click();
-
- cy.findByLabelText("Browser").click();
- cy.findByLabelText("Browser").should("be.checked");
-
- cy.findByLabelText("Guest").click();
-
- cy.findByLabelText("Dashboard").should("be.checked");
-
- cy.findByLabelText("Chart").click();
- cy.findByLabelText("Chart").should("be.checked");
-
- cy.findByLabelText("Metabase account (SSO)").click();
-
- cy.findByLabelText("Chart").should("be.checked");
-
- cy.findByLabelText("Guest").click();
-
- cy.findByLabelText("Chart").should("be.checked");
- });
- });
-
it("should not reset experience when changing auth type for Embed JS wizard opened from an entity page", () => {
H.visitQuestion(ORDERS_QUESTION_ID);
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-ee.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-ee.cy.spec.ts
index 054f565d33f..2c48c641239 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-ee.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-ee.cy.spec.ts
@@ -102,16 +102,14 @@ describe("scenarios > embedding > sdk iframe embed setup > enable embed js (EE)"
.should("be.visible")
.should("be.disabled");
- // Going to the next step and selecting "Orders in a dashboard" explicitely
+ // Selecting "Orders in a dashboard" explicitly on the first step
// because sometimes it selects another one that's been used recently
// see EMB-1106
- cy.log(
- "Navigating to embed flow step 2 and selecting an item to embed",
- );
- cy.findByRole("button", { name: "Next" }).click();
- cy.get('[data-testid="embed-recent-item-card"]')
- .should("have.length.greaterThan", 0)
- .contains("Orders in a dashboard")
+ cy.log("Selecting an item to embed on the first step");
+ cy.findByTestId("embed-browse-entity-button").click();
+ H.entityPickerModal()
+ .findAllByText("Orders in a dashboard")
+ .first()
.click();
cy.log("Preview should load after embedding is enabled");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-oss-and-starter.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-oss-and-starter.cy.spec.ts
index 0bbf78ec441..1fc83facd8d 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-oss-and-starter.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-flow-enable-embed-js-oss-and-starter.cy.spec.ts
@@ -79,16 +79,14 @@ describe("scenarios > embedding > sdk iframe embed setup > enable embed js (oss
.should("be.visible")
.should("be.disabled");
- // Going to the next step and selecting "Orders in a dashboard" explicitely
+ // Selecting "Orders in a dashboard" explicitly on the first step
// because sometimes it selects another one that's been used recently
// see EMB-1106
- cy.log(
- "Navigating to embed flow step 2 and selecting an item to embed",
- );
- cy.findByRole("button", { name: "Next" }).click();
- cy.get('[data-testid="embed-recent-item-card"]')
- .should("have.length.greaterThan", 0)
- .contains("Orders in a dashboard")
+ cy.log("Selecting an item to embed on the first step");
+ cy.findByTestId("embed-browse-entity-button").click();
+ H.entityPickerModal()
+ .findAllByText("Orders in a dashboard")
+ .first()
.click();
cy.log("Preview should load after embedding is enabled");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters-remapping.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters-remapping.cy.spec.ts
index d36f666273e..139b1015997 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters-remapping.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters-remapping.cy.spec.ts
@@ -154,6 +154,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: "Dashboard with Remapping",
+ preselectGuest: true,
});
H.setEmbeddingParameter("Internal", "Editable");
@@ -294,6 +295,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "chart",
resourceName: "Question with Remapping",
+ preselectGuest: true,
});
H.setEmbeddingParameter("Internal", "Editable");
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts
index 38aab30e920..740826af15e 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-ee.cy.spec.ts
@@ -135,28 +135,28 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
H.waitForSimpleEmbedIframesToLoad();
- // Experience step
+ // Switch to Guest auth (wizard now defaults to SSO when SSO isn't configured)
+ getEmbedSidebar().within(() => {
+ cy.findByLabelText("Guest").click();
+ });
+ embedModalEnableEmbedding();
+
+ // Combined experience + resource step
getEmbedSidebar().within(() => {
cy.findByLabelText("Guest").should("be.visible").should("be.checked");
cy.findByTestId("upsell-card").should("not.exist");
cy.findByText("Chart").click();
- cy.findByText("Next").click();
- });
-
- H.expectUnstructuredSnowplowEvent({
- event: "embed_wizard_experience_completed",
- event_detail:
- "authType=guest-embed,experience=chart,isDefaultExperience=false",
- });
- // Entity selection step
- getEmbedSidebar().within(() => {
cy.findByTestId("embed-browse-entity-button").click();
});
H.entityPickerModal().within(() => {
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
+
cy.findByText("Select a chart").should("be.visible");
cy.findByText(FIRST_QUESTION_NAME).click();
});
@@ -165,6 +165,12 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
cy.findByText("Next").click();
});
+ H.expectUnstructuredSnowplowEvent({
+ event: "embed_wizard_experience_completed",
+ event_detail:
+ "authType=guest-embed,experience=chart,isDefaultExperience=false",
+ });
+
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_resource_selection_completed",
event_detail: "isDefaultResource=false,experience=chart",
@@ -299,6 +305,7 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
navigateToEmbedOptionsStep({
experience: "chart",
resourceName: FIRST_QUESTION_NAME,
+ preselectGuest: true,
});
cy.button("Unpublish").should("be.visible");
@@ -314,7 +321,9 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
});
entityPickerModal().within(() => {
- cy.findByText("Our analytics").click();
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
cy.findAllByText(SECOND_QUESTION_NAME).first().click();
});
@@ -343,7 +352,9 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
});
entityPickerModal().within(() => {
- cy.findByText("Our analytics").click();
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
cy.findAllByText(FIRST_QUESTION_NAME).first().click();
});
@@ -370,6 +381,7 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
+ preselectGuest: true,
});
getEmbedSidebar().within(() => {
@@ -387,7 +399,6 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
codeBlock().first().should("not.contain", "hidden-parameters=");
codeBlock().first().should("not.contain", "locked-parameters=");
- cy.findByText("Back").click();
cy.findByText("Back").click();
cy.findByText("Back").click();
@@ -399,7 +410,6 @@ describe("scenarios > embedding > sdk iframe embed setup > guest-embed", () => {
embedModalEnableEmbedding();
getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
cy.findByText("Next").click();
cy.findByText("Get code").click();
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts
index b7d50fdea12..15eaa2f9566 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/guest-embed-oss.cy.spec.ts
@@ -126,7 +126,7 @@ describe(
H.waitForSimpleEmbedIframesToLoad();
- // Experience step
+ // Combined experience + resource step
getEmbedSidebar().within(() => {
cy.findByLabelText("Guest").should("be.visible").should("be.checked");
@@ -139,22 +139,15 @@ describe(
cy.findByTestId("upsell-card").should("be.visible");
cy.findByText("Chart").click();
- cy.findByText("Next").click();
- });
-
- H.expectUnstructuredSnowplowEvent({
- event: "embed_wizard_experience_completed",
- event_detail:
- "authType=guest-embed,experience=chart,isDefaultExperience=false",
- });
- // Entity selection step
- getEmbedSidebar().within(() => {
cy.findByTestId("embed-browse-entity-button").click();
});
H.entityPickerModal().within(() => {
cy.findByText("Select a chart").should("be.visible");
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
cy.findByText(FIRST_QUESTION_NAME).click();
});
@@ -162,6 +155,12 @@ describe(
cy.findByText("Next").click();
});
+ H.expectUnstructuredSnowplowEvent({
+ event: "embed_wizard_experience_completed",
+ event_detail:
+ "authType=guest-embed,experience=chart,isDefaultExperience=false",
+ });
+
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_resource_selection_completed",
event_detail: "isDefaultResource=false,experience=chart",
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
index d98d472d567..edd18f4dbe7 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/helpers/index.ts
@@ -20,8 +20,9 @@ export const getEmbedSidebar = () =>
.first()
.within(() => cy.findByRole("complementary"));
-export const getRecentItemCards = () =>
- cy.findAllByTestId("embed-recent-item-card");
+export const getResourceSelectorButton = (
+ options?: Partial<Cypress.Timeoutable>,
+) => cy.findByTestId("embed-browse-entity-button", options);
export const visitNewEmbedPage = (
{ waitForResource } = { waitForResource: true },
@@ -75,17 +76,19 @@ type NavigateToStepOptions =
experience: "exploration" | "metabot";
resourceName?: never;
preselectSso?: boolean;
+ preselectGuest?: boolean;
}
| {
experience: "dashboard" | "chart" | "browser";
resourceName: string;
preselectSso?: boolean;
+ preselectGuest?: boolean;
};
export const navigateToEntitySelectionStep = (
options: NavigateToStepOptions,
) => {
- const { experience, preselectSso } = options;
+ const { experience, preselectSso, preselectGuest } = options;
visitNewEmbedPage();
@@ -99,6 +102,9 @@ export const navigateToEntitySelectionStep = (
if (preselectSso || !isQuestionOrDashboardExperience) {
cy.findByLabelText("Metabase account (SSO)").click();
embedModalEnableEmbedding();
+ } else if (preselectGuest) {
+ cy.findByLabelText("Guest").click();
+ embedModalEnableEmbedding();
}
const labelByExperience = match(experience)
@@ -112,14 +118,9 @@ export const navigateToEntitySelectionStep = (
cy.findByText(labelByExperience).click();
}
- // exploration and metabot experience does not have the entity selection step
+ // Experience selection and resource picker are part of the same step.
+ // exploration and metabot do not show a resource picker.
if (hasEntitySelection && options.resourceName) {
- cy.log("navigate to the entity selection step");
-
- getEmbedSidebar().within(() => {
- cy.findByText("Next").click(); // Entity selection step
- });
-
const resourceType = match(experience)
.with("dashboard", () => "Dashboards")
.with("chart", () => "Questions")
@@ -132,8 +133,16 @@ export const navigateToEntitySelectionStep = (
});
entityPickerModal().within(() => {
- cy.findByText("Our analytics").click();
- cy.findAllByText(options.resourceName).first().click();
+ // The picker opens on the "Recent items" tab by default. Scope each
+ // navigation step to its column to disambiguate when the target also
+ // appears in the recents list.
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
+ cy.findByTestId("item-picker-level-1")
+ .findAllByText(options.resourceName)
+ .first()
+ .click();
// Collection picker requires an explicit confirmation.
if (experience === "browser") {
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts
index b90f0693302..5ef45ceb2bc 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts
@@ -11,7 +11,7 @@ import {
import {
getEmbedSidebar,
- getRecentItemCards,
+ getResourceSelectorButton,
visitNewEmbedPage,
} from "./helpers";
@@ -49,11 +49,11 @@ describe(suiteTitle, () => {
visitNewEmbedPage();
getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
cy.findByText("Select a dashboard to embed").should("be.visible");
- cy.log("first dashboard should be selected by default");
- getRecentItemCards().first().should("have.attr", "data-selected", "true");
+ cy.log("a default dashboard is preselected");
+ getResourceSelectorButton().should("contain", FIRST_DASHBOARD_NAME);
+
cy.findByText("Next").click();
});
@@ -78,7 +78,6 @@ describe(suiteTitle, () => {
visitNewEmbedPage();
getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
cy.findByText("Select a dashboard to embed").should("be.visible");
// see the "shows recently created dashboard at the top of the list (EMB-1179)"
@@ -86,19 +85,22 @@ describe(suiteTitle, () => {
cy.log(
"recently created dashboard should be selected by default (EMB-1179)",
);
- getRecentItemCards()
- .should("have.length", 2)
- .first()
- .should("contain", SECOND_DASHBOARD_NAME)
- .should("have.attr", "data-selected", "true");
+ getResourceSelectorButton().should("contain", SECOND_DASHBOARD_NAME);
- cy.findByText(FIRST_DASHBOARD_NAME).should("be.visible");
- cy.findByText(SECOND_DASHBOARD_NAME).should("be.visible");
+ cy.log("a different dashboard can be selected via the picker");
+ getResourceSelectorButton().click();
+ });
- cy.log("a different dashboard can be selected");
+ H.entityPickerModal().within(() => {
cy.findByText(FIRST_DASHBOARD_NAME).click();
+ });
- getRecentItemCards().eq(1).should("have.attr", "data-selected", "true");
+ getEmbedSidebar().within(() => {
+ getResourceSelectorButton().should("contain", FIRST_DASHBOARD_NAME);
+ });
+
+ getEmbedSidebar().within(() => {
+ cy.findByLabelText("Guest").click();
});
cy.log("selected dashboard should be shown in the preview");
@@ -133,23 +135,22 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.findByText("Chart").click();
- cy.findByText("Next").click();
cy.findByText("Select a chart to embed").should("be.visible");
cy.log("first question should be selected by default");
- getRecentItemCards()
- .should("have.length", 2)
- .first()
- .should("have.attr", "data-selected", "true");
+ getResourceSelectorButton().should("contain", FIRST_QUESTION_NAME);
- cy.findByText(FIRST_QUESTION_NAME).should("be.visible");
- cy.findByText(SECOND_QUESTION_NAME).should("be.visible");
+ cy.log("a different question can be selected via the picker");
+ getResourceSelectorButton().click();
+ });
- cy.log("second question can be selected");
+ H.entityPickerModal().within(() => {
cy.findByText(SECOND_QUESTION_NAME).click();
+ });
- getRecentItemCards().eq(1).should("have.attr", "data-selected", "true");
+ getEmbedSidebar().within(() => {
+ getResourceSelectorButton().should("contain", SECOND_QUESTION_NAME);
cy.findByText("Next").click();
@@ -174,23 +175,25 @@ describe(suiteTitle, () => {
visitNewEmbedPage();
getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
- cy.findByTestId("embed-browse-entity-button").click();
+ getResourceSelectorButton().click();
});
H.entityPickerModal().within(() => {
cy.findByText("Select a dashboard").should("be.visible");
- cy.findByText("Our analytics").click();
- cy.findByText(SECOND_DASHBOARD_NAME).click();
+
+ // The picker opens on "Recent items" by default. Navigate via the
+ // root sidebar to disambiguate from any matching recent entries.
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
+ cy.findByTestId("item-picker-level-1")
+ .findByText(SECOND_DASHBOARD_NAME)
+ .click();
});
- cy.log("dashboard is added to the top of recents list and selected");
+ cy.log("button reflects the newly selected dashboard");
getEmbedSidebar().within(() => {
- getRecentItemCards()
- .should("have.length", 2)
- .first()
- .should("contain", SECOND_DASHBOARD_NAME)
- .should("have.attr", "data-selected", "true");
+ getResourceSelectorButton().should("contain", SECOND_DASHBOARD_NAME);
});
cy.wait("@dashboard");
@@ -204,8 +207,7 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.findByText("Chart").click();
- cy.findByText("Next").click();
- cy.findByTestId("embed-browse-entity-button").click();
+ getResourceSelectorButton().click();
});
H.entityPickerModal().within(() => {
@@ -214,13 +216,9 @@ describe(suiteTitle, () => {
cy.findByText(FIRST_QUESTION_NAME).click();
});
- cy.log("question is added to the top of recents list and selected");
+ cy.log("button reflects the newly selected question");
getEmbedSidebar().within(() => {
- getRecentItemCards()
- .should("have.length", 1)
- .first()
- .should("contain", FIRST_QUESTION_NAME)
- .should("have.attr", "data-selected", "true");
+ getResourceSelectorButton().should("contain", FIRST_QUESTION_NAME);
cy.findByText("Next").click();
});
@@ -246,22 +244,27 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.findByText("Browser").click();
- cy.findByText("Next").click();
- cy.findByText("Select a collection to embed").should("be.visible");
- cy.findByTestId("embed-browse-entity-button").click();
+ cy.findByText("Select initial collection").should("be.visible");
+ getResourceSelectorButton().click();
});
H.entityPickerModal().within(() => {
- cy.findByText("Select a collection").should("be.visible");
- cy.findByText("First collection").click();
+ cy.findByText("Select default collection").should("be.visible");
+
+ // The picker opens on "Recent items" by default. Navigate via the
+ // root sidebar to disambiguate from any matching recent entries.
+ cy.findByTestId("item-picker-level-0")
+ .findByText("Our analytics")
+ .click();
+ cy.findByTestId("item-picker-level-1")
+ .findByText("First collection")
+ .click();
cy.findByText("Select").click();
});
- cy.log("collection is added to recents list");
+ cy.log("button reflects the newly selected collection");
getEmbedSidebar().within(() => {
- getRecentItemCards()
- .should("contain", "First collection")
- .should("have.attr", "data-selected", "true");
+ getResourceSelectorButton().should("contain", "First collection");
});
cy.log("collection is shown in the breadcrumbs and preview");
@@ -274,87 +277,6 @@ describe(suiteTitle, () => {
cy.findByText("Second collection").should("be.visible");
});
});
-
- describe("when there is no recent activity", () => {
- beforeEach(() => {
- cy.intercept("GET", "/api/activity/recents?*", {
- recents: [],
- }).as("emptyRecentItems");
-
- // The embed wizard calls the search API to find recently created
- // dashboards. Without this, the snapshot's admin-owned dashboards
- // would be returned and selected as the default.
- cy.log("simulate that there are no recently created dashboards");
- cy.intercept("GET", "/api/search?*", { data: [], total: 0 }).as(
- "emptySearch",
- );
-
- visitNewEmbedPage();
- cy.wait("@emptyRecentItems");
- });
-
- it("can open a picker from the dashboard empty state", () => {
- getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
-
- cy.log("shows the empty state for missing recent dashboards");
- cy.findByTestId("embed-recent-item-card").should("not.exist");
- cy.findByText("No recent dashboards").should("be.visible");
- cy.findByText(/You haven't visited any dashboards recently/).should(
- "be.visible",
- );
-
- cy.findByText(/search for dashboards/).click();
- });
-
- H.entityPickerModal().within(() => {
- cy.findByText("Select a dashboard").should("be.visible");
- });
- });
-
- it("can open a picker from the chart empty state", () => {
- getEmbedSidebar().within(() => {
- cy.findByText("Chart").click();
- cy.findByText("Next").click();
-
- cy.log("shows the empty state for missing recent questions");
- cy.findByTestId("embed-recent-item-card").should("not.exist");
- cy.findByText("No recent charts").should("be.visible");
- cy.findByText(/You haven't visited any charts recently/).should(
- "be.visible",
- );
-
- cy.findByText(/search for charts/).click();
- });
-
- H.entityPickerModal().within(() => {
- cy.findByText("Select a chart").should("be.visible");
- });
- });
-
- it("can open a collection picker from browser empty state", () => {
- getEmbedSidebar().within(() => {
- cy.findByLabelText("Metabase account (SSO)").click();
- });
-
- embedModalEnableEmbedding();
-
- getEmbedSidebar().within(() => {
- cy.findByText("Browser").click();
- cy.findByText("Next").click();
-
- cy.log("shows empty state for missing recent collections");
- cy.findByTestId("embed-recent-item-card").should("not.exist");
- cy.findByText("No recent collections").should("be.visible");
-
- cy.findByTitle("Browse collections").click();
- });
-
- H.entityPickerModal().within(() => {
- cy.findByText("Select a collection").should("be.visible");
- });
- });
- });
});
const logRecent = (model: "dashboard" | "card", modelId: number | string) =>
@@ -399,22 +321,16 @@ describe("recently created dashboards", () => {
visitNewEmbedPage();
getEmbedSidebar().within(() => {
- cy.findByText("Next").click();
cy.findByText("Select a dashboard to embed").should("be.visible");
cy.log(
- "recently created dashboard should show up even though it was never viewed",
+ "the recently created x-ray dashboard should be the default selection",
);
const XRAY_DASHBOARD_NAME = "A look at Orders";
- cy.findByText(XRAY_DASHBOARD_NAME, { timeout: 10_000 }).should(
- "be.visible",
+ getResourceSelectorButton({ timeout: 10_000 }).should(
+ "contain",
+ XRAY_DASHBOARD_NAME,
);
-
- cy.log("the x-ray dashboard should be selected by default");
- getRecentItemCards()
- .first()
- .should("contain", XRAY_DASHBOARD_NAME)
- .should("have.attr", "data-selected", "true");
});
});
});
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts
index 5a7da7c3b8a..541324481ec 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts
@@ -49,6 +49,11 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });
H.waitForSimpleEmbedIframesToLoad();
+ getEmbedSidebar().within(() => {
+ cy.findByLabelText("Guest").click();
+ });
+ embedModalEnableEmbedding();
+
getEmbedSidebar().within(() => {
cy.findByText("Next").click();
});
@@ -79,6 +84,11 @@ describe(suiteTitle, () => {
assertRecentItemName("card", questionName);
H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });
+ getEmbedSidebar().within(() => {
+ cy.findByLabelText("Guest").click();
+ });
+ embedModalEnableEmbedding();
+
getEmbedSidebar().within(() => {
cy.findByText("Chart").click();
cy.findByText("Next").click();
@@ -191,6 +201,11 @@ describe(suiteTitle, () => {
visitNewEmbedPage();
cy.wait("@emptyRecentItems");
+ getEmbedSidebar().within(() => {
+ cy.findByLabelText("Guest").click();
+ });
+ embedModalEnableEmbedding();
+
getEmbedSidebar().within(() => {
cy.findByText("Chart").click();
cy.findByText("Next").click();
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
index 9ddcb654a3e..4d1c4217c57 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts
@@ -184,6 +184,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
+ preselectGuest: true,
});
getEmbedSidebar()
@@ -221,7 +222,6 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.button("Back").click();
cy.button("Back").click();
- cy.button("Back").click();
cy.findByLabelText("Metabase account (SSO)").click();
});
@@ -230,7 +230,6 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.button("Next").click();
- cy.button("Next").click();
// Trigger mouseover (not mouseenter) because this HoverCard is outside a
// HoverCardGroup, so Mantine attaches a React onMouseEnter prop. React 18
@@ -381,6 +380,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
+ preselectGuest: true,
});
H.publishChanges("dashboard");
@@ -458,6 +458,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "chart",
resourceName: QUESTION_NAME,
+ preselectGuest: true,
});
H.publishChanges("card");
@@ -559,6 +560,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "chart",
resourceName: QUESTION_NAME,
+ preselectGuest: true,
});
getEmbedSidebar()
@@ -593,7 +595,6 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.button("Back").click();
cy.button("Back").click();
- cy.button("Back").click();
cy.findByLabelText("Metabase account (SSO)").click();
});
@@ -602,7 +603,6 @@ describe(suiteTitle, () => {
getEmbedSidebar().within(() => {
cy.button("Next").click();
- cy.button("Next").click();
cy.findByLabelText("Allow alerts")
.closest("[data-testid=tooltip-warning]")
@@ -703,7 +703,6 @@ describe(suiteTitle, () => {
.and("include", "embedding/components.html#question");
cy.findByText("Back").click();
- cy.findByText("Back").click();
cy.findByText("Metabot").click();
cy.findByText("Next").click();
@@ -775,6 +774,31 @@ describe(suiteTitle, () => {
});
});
+ it("toggles save button for metabot", () => {
+ navigateToEmbedOptionsStep({ experience: "metabot" });
+
+ getEmbedSidebar()
+ .findByLabelText("Allow people to save new questions")
+ .should("not.be.checked");
+
+ cy.log("turn on save option");
+ getEmbedSidebar()
+ .findByLabelText("Allow people to save new questions")
+ .click()
+ .should("be.checked");
+
+ cy.log("snippet should be updated");
+ getEmbedSidebar().findByText("Get code").click();
+
+ H.expectUnstructuredSnowplowEvent({
+ event: "embed_wizard_options_completed",
+ event_detail:
+ "settings=custom,experience=metabot,authType=sso,isSaveEnabled=true,theme=default",
+ });
+
+ codeBlock().should("contain", 'is-save-enabled="true"');
+ });
+
it("can toggle read-only setting for browser", () => {
navigateToEmbedOptionsStep({
experience: "browser",
@@ -815,6 +839,7 @@ describe(suiteTitle, () => {
navigateToEmbedOptionsStep({
experience: "dashboard",
resourceName: DASHBOARD_NAME,
+ preselectGuest: true,
});
H.publishChanges("dashboard");
@@ -969,7 +994,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- "settings=custom,experience=metabot,authType=sso,layout=stacked,theme=default",
+ "settings=custom,experience=metabot,authType=sso,isSaveEnabled=false,layout=stacked,theme=default",
});
getEmbedSidebar().findByText("Back").click();
@@ -985,7 +1010,7 @@ describe(suiteTitle, () => {
H.expectUnstructuredSnowplowEvent({
event: "embed_wizard_options_completed",
event_detail:
- "settings=custom,experience=metabot,authType=sso,layout=sidebar,theme=default",
+ "settings=custom,experience=metabot,authType=sso,isSaveEnabled=false,layout=sidebar,theme=default",
});
});
});
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/NewEmbedButton/NewEmbedButton.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/NewEmbedButton/NewEmbedButton.tsx
index 49e317f8955..77192b87fbc 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/NewEmbedButton/NewEmbedButton.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/NewEmbedButton/NewEmbedButton.tsx
@@ -4,7 +4,14 @@ import { useDispatch } from "metabase/redux";
import { setOpenModalWithProps } from "metabase/redux/ui";
import { Button } from "metabase/ui";
-export const NewEmbedButton = () => {
+interface NewEmbedButtonProps {
+ /**
+ * Force initial authentication mode to `guest`
+ */
+ forceIsGuest?: boolean;
+}
+
+export const NewEmbedButton = ({ forceIsGuest }: NewEmbedButtonProps) => {
const dispatch = useDispatch();
return (
@@ -17,8 +24,7 @@ export const NewEmbedButton = () => {
id: "embed",
props: {
initialState: {
- isGuest: true,
- useExistingUserSession: true,
+ isGuest: forceIsGuest,
},
},
}),
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
index 1cc483d310d..07d1ecfe3ab 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/SharedCombinedEmbeddingSettings/SharedCombinedEmbeddingSettings.tsx
@@ -45,7 +45,7 @@ export function SharedCombinedEmbeddingSettings({
title={t`Enable guest embeds`}
description={t`A secure way to embed charts and dashboards, without single sign-on, when you don’t want to offer ad-hoc querying or chart drill-through.`}
settingKey="enable-embedding-static"
- actionButton={<NewEmbedButton />}
+ actionButton={<NewEmbedButton forceIsGuest />}
sdk-setting-card
testId="guest-embeds-setting-card"
/>
diff --git a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx
index 21498c8b110..6a79fbd8877 100644
--- a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx
+++ b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx
@@ -18,8 +18,6 @@ import {
useDashboardContext,
} from "metabase/dashboard/context";
import { useDashboardUrlQuery } from "metabase/dashboard/hooks";
-import { ReturnToSetupGuideModal } from "metabase/embedding/components/ReturnToSetupGuideModal";
-import { RETURN_TO_SETUP_GUIDE_PARAM } from "metabase/embedding/constants";
import { usePageTitle } from "metabase/hooks/use-page-title";
import { useDispatch } from "metabase/redux";
import { addUndo } from "metabase/redux/undo";
@@ -51,10 +49,6 @@ const AutomaticDashboardAppInner = () => {
const invalidateCollections = () => invalidateTags(null, ["collection"]);
const [savedDashboardUrl, setSavedDashboardUrl] = useState<string>();
- const [showReturnModal, setShowReturnModal] = useState(false);
- const fromEmbeddingSetupGuide = new URLSearchParams(
- window.location.search,
- ).has(RETURN_TO_SETUP_GUIDE_PARAM);
useEffect(() => {
setSavedDashboardUrl(undefined);
@@ -91,9 +85,6 @@ const AutomaticDashboardAppInner = () => {
}),
);
setSavedDashboardUrl(newDashboardUrl);
- if (fromEmbeddingSetupGuide) {
- setShowReturnModal(true);
- }
}
};
@@ -218,14 +209,6 @@ const AutomaticDashboardAppInner = () => {
</Box>
)}
</div>
- {fromEmbeddingSetupGuide && (
- <ReturnToSetupGuideModal
- opened={showReturnModal}
- onClose={() => setShowReturnModal(false)}
- title={t`Dashboard saved!`}
- message={t`Your dashboard has been saved. Return to the setup guide to continue.`}
- />
- )}
</div>
);
};
diff --git a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/ParametersSettings.tsx b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/ParametersSettings.tsx
index 22f47dd168d..51d9154a448 100644
--- a/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/ParametersSettings.tsx
+++ b/frontend/src/metabase/embedding/components/EmbedModal/StaticEmbedSetupPane/ParametersSettings.tsx
@@ -82,6 +82,7 @@ export const ParametersSettings = ({
<>
<StaticEmbedSetupPaneSettingsContentSection
title={t`Configuring parameters`}
+ data-testid="parameters-container"
>
<Stack gap="1rem">
<Text>{t`Parameters are disabled by default, which also makes them hidden from end-users. Make them editable so that end-users can see and modify them. Make them locked so that they are hidden from end-users but you can set their values from your app.`}</Text>
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
index 4a10a4ed204..49489b1e877 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.tsx
@@ -119,7 +119,6 @@ export const EmbeddingHub = () => {
<EmbeddingHubXrayPickerModal
opened={openedModal?.type === "xray-dashboard"}
onClose={closeModal}
- fromEmbeddingSetupGuide
/>
{openedModal?.type === "user-strategy" && (
<PLUGIN_TENANTS.EditUserStrategyModal onClose={closeModal} />
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.unit.spec.tsx
index 37e19006e18..4d223c47da5 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHub.unit.spec.tsx
@@ -1,6 +1,5 @@
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
-import { push } from "react-router-redux";
import {
setupCollectionByIdEndpoint,
@@ -20,22 +19,14 @@ import {
import { createMockState } from "metabase/redux/store/mocks";
import {
createMockCollection,
+ createMockDashboard,
createMockRecentTableDatabaseInfo,
createMockRecentTableItem,
createMockUser,
} from "metabase-types/api/mocks";
-jest.mock("react-router-redux", () => ({
- push: jest.fn(() => ({
- type: "@@router/CALL_HISTORY_METHOD",
- payload: { method: "push" },
- })),
-}));
-
import { EmbeddingHub } from "./EmbeddingHub";
-const mockPush = push as jest.MockedFunction<typeof push>;
-
const setup = ({ isAdmin = true, checklist = {} } = {}) => {
mockGetBoundingClientRect();
const state = createMockState({
@@ -87,14 +78,13 @@ const setup = ({ isAdmin = true, checklist = {} } = {}) => {
"data-isolation-strategy": null,
});
- return renderWithProviders(<EmbeddingHub />, { storeInitialState: state });
+ return renderWithProviders(<EmbeddingHub />, {
+ storeInitialState: state,
+ withUndos: true,
+ });
};
describe("EmbeddingHub", () => {
- beforeEach(() => {
- mockPush.mockClear();
- });
-
it("opens AddDataModal when 'Connect a database' is clicked", async () => {
setup();
@@ -108,7 +98,19 @@ describe("EmbeddingHub", () => {
});
});
- it("opens table picker when 'Create a dashboard' is clicked", async () => {
+ it("creates and saves an x-ray dashboard when a table is picked", async () => {
+ const xrayDashboard = createMockDashboard({
+ id: 10,
+ name: "A look at Foo Bar Table",
+ });
+ const savedDashboard = createMockDashboard({
+ id: 42,
+ name: "A look at Foo Bar Table",
+ });
+
+ fetchMock.get("path:/api/automagic-dashboards/table/10", xrayDashboard);
+ fetchMock.post("path:/api/dashboard/save", savedDashboard);
+
setup();
await userEvent.click(await screen.findByText("Create a dashboard"));
@@ -128,9 +130,34 @@ describe("EmbeddingHub", () => {
await userEvent.click(within(dialog).getByText("Foo Bar Table"));
- expect(mockPush).toHaveBeenCalledWith(
- "/auto/dashboard/table/10?returnToEmbeddingSetupGuide=true",
- );
+ expect(
+ await screen.findByText("Your dashboard was saved"),
+ ).toBeInTheDocument();
+ expect(screen.getByText("See it")).toBeInTheDocument();
+
+ expect(screen.queryByTestId("entity-picker-modal")).not.toBeInTheDocument();
+ });
+
+ it("shows an error toast when x-ray dashboard creation fails", async () => {
+ fetchMock.get("path:/api/automagic-dashboards/table/10", 500);
+
+ setup();
+
+ await userEvent.click(await screen.findByText("Create a dashboard"));
+
+ const dialog = await screen.findByTestId("entity-picker-modal");
+
+ await userEvent.click(await screen.findByText("Recent items"));
+
+ expect(
+ await within(dialog).findByText("Foo Bar Table"),
+ ).toBeInTheDocument();
+
+ await userEvent.click(within(dialog).getByText("Foo Bar Table"));
+
+ expect(
+ await screen.findByText("Failed to create dashboard"),
+ ).toBeInTheDocument();
});
it("shows success banner when first 3 steps are completed", async () => {
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubXrayPickerModal.tsx b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubXrayPickerModal.tsx
index 6e6115f1be2..feed1c7fbb9 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubXrayPickerModal.tsx
+++ b/frontend/src/metabase/embedding/embedding-hub/components/EmbeddingHubXrayPickerModal.tsx
@@ -1,29 +1,77 @@
-import { push } from "react-router-redux";
+import cx from "classnames";
+import { dissoc } from "icepick";
import { t } from "ttag";
+import { Api, dashboardApi } from "metabase/api";
+import { invalidateTags, listTag } from "metabase/api/tags";
+import { Link } from "metabase/common/components/Link";
import { DataPickerModal } from "metabase/common/components/Pickers/DataPicker";
-import { RETURN_TO_SETUP_GUIDE_PARAM } from "metabase/embedding/constants";
+import { useToast } from "metabase/common/hooks";
+import CS from "metabase/css/core/index.css";
import { useDispatch } from "metabase/redux";
-import type { TableId } from "metabase-types/api";
+import { AutoApi } from "metabase/services";
+import * as Urls from "metabase/urls";
+import type { Dashboard, TableId } from "metabase-types/api";
interface EmbeddingHubXrayPickerModalProps {
opened: boolean;
onClose: () => void;
- fromEmbeddingSetupGuide?: boolean;
}
export const EmbeddingHubXrayPickerModal = ({
opened,
onClose,
- fromEmbeddingSetupGuide,
}: EmbeddingHubXrayPickerModalProps) => {
const dispatch = useDispatch();
+ const [sendToast] = useToast();
- function handleTableSelect(tableId: TableId) {
- const params = fromEmbeddingSetupGuide
- ? `?${RETURN_TO_SETUP_GUIDE_PARAM}=true`
- : "";
- dispatch(push(`/auto/dashboard/table/${tableId}${params}`));
+ async function handleTableSelect(tableId: TableId) {
+ onClose();
+
+ try {
+ const xrayDashboard: Dashboard = await AutoApi.dashboard({
+ subPath: `table/${tableId}`,
+ });
+
+ const { data: savedDashboard } = await dispatch(
+ dashboardApi.endpoints.saveDashboard.initiate(
+ dissoc(xrayDashboard, "id"),
+ ),
+ );
+
+ if (!savedDashboard) {
+ throw new Error("Failed to save x-ray dashboard");
+ }
+
+ dispatch(
+ Api.util.invalidateTags([
+ ...invalidateTags(null, ["collection"]),
+ listTag("embedding-hub-checklist"),
+ ]),
+ );
+
+ const savedDashboardUrl = Urls.dashboard(savedDashboard);
+ sendToast({
+ message: (
+ <div className={cx(CS.flex, CS.alignCenter)}>
+ {t`Your dashboard was saved`}
+ <Link
+ className={cx(CS.link, CS.textBold, CS.ml1)}
+ to={savedDashboardUrl}
+ >
+ {t`See it`}
+ </Link>
+ </div>
+ ),
+ icon: "dashboard",
+ });
+ } catch {
+ sendToast({
+ icon: "warning",
+ toastColor: "error",
+ message: t`Failed to create dashboard`,
+ });
+ }
}
if (!opened) {
diff --git a/frontend/src/metabase/embedding/embedding-hub/hooks/use-get-embedding-hub-steps.ts b/frontend/src/metabase/embedding/embedding-hub/hooks/use-get-embedding-hub-steps.ts
index 74ee11d81b8..fe5bacb51f3 100644
--- a/frontend/src/metabase/embedding/embedding-hub/hooks/use-get-embedding-hub-steps.ts
+++ b/frontend/src/metabase/embedding/embedding-hub/hooks/use-get-embedding-hub-steps.ts
@@ -36,12 +36,7 @@ export const useGetEmbeddingHubSteps = (): EmbeddingHubStep[] => {
title: t`Get embed snippet`,
description: t`Embed a dashboard, question, the query builder or the collection browser. Configure the experience and customize the appearance.`,
onClick: () => {
- openEmbedModal({
- initialState: {
- isGuest: true,
- useExistingUserSession: true,
- },
- });
+ openEmbedModal({ initialState: {} });
},
variant: "outline",
},
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx
deleted file mode 100644
index 1cf798f2b4e..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import { t } from "ttag";
-
-import { SdkIframeStepEnableEmbeddingSection } from "metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeStepEnableEmbeddingSection";
-import { useSdkIframeEmbedSetupContext } from "metabase/embedding/embedding-iframe-sdk-setup/context";
-import {
- DEFAULT_EXPERIENCE,
- useHandleExperienceChange,
-} from "metabase/embedding/embedding-iframe-sdk-setup/hooks/use-handle-experience-change";
-import { getAuthTypeForSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/get-auth-type-for-settings";
-import { isQuestionOrDashboardExperience } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-experience";
-import { isStepWithResource } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-step-with-resource";
-import { Card, Radio, Stack, Text } from "metabase/ui";
-
-import { getResourceTypeFromExperience } from "../../utils/get-resource-type-from-experience";
-
-import { DatabaseRoutingWarning } from "./DatabaseRoutingWarning";
-
-export const AuthenticationSection = () => {
- const {
- experience,
- isSimpleEmbedFeatureAvailable,
- isFirstStep,
- currentStep,
- settings,
- updateSettings,
- resource,
- } = useSdkIframeEmbedSetupContext();
- const handleEmbedExperienceChange = useHandleExperienceChange();
-
- const resourceType = getResourceTypeFromExperience(experience);
-
- if (!isFirstStep) {
- return null;
- }
-
- const authType = getAuthTypeForSettings(settings);
-
- const handleAuthTypeChange = (value: string) => {
- const isGuest = value === "guest-embed";
- const isSso = value === "sso";
-
- // Reset experience to default when switching to guest embeds from non-supported experience
- const shouldSwitchExperience =
- isGuest &&
- !isStepWithResource(currentStep) &&
- !isQuestionOrDashboardExperience(experience);
-
- if (shouldSwitchExperience) {
- handleEmbedExperienceChange(DEFAULT_EXPERIENCE);
- }
-
- updateSettings({
- isGuest,
- isSso,
- });
- };
-
- return (
- <Card p="md">
- <Stack gap="md" p="xs">
- <Text size="lg" fw="bold">
- {t`Authentication`}
- </Text>
-
- <Radio.Group value={authType} onChange={handleAuthTypeChange}>
- <Stack gap="sm">
- <Radio value="guest-embed" label={t`Guest`} />
-
- <Radio
- value="sso"
- label={
- // eslint-disable-next-line metabase/no-literal-metabase-strings -- Public Facing string
- t`Metabase account (SSO)`
- }
- disabled={!isSimpleEmbedFeatureAvailable}
- />
- </Stack>
- </Radio.Group>
-
- {authType === "guest-embed" && resource && resourceType && (
- <DatabaseRoutingWarning
- resource={resource}
- resourceType={resourceType}
- />
- )}
-
- <SdkIframeStepEnableEmbeddingSection />
- </Stack>
- </Card>
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/MetabaseAccountSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/MetabaseAccountSection.tsx
deleted file mode 100644
index 0952298c535..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/MetabaseAccountSection.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { jt, t } from "ttag";
-
-import { useDocsUrl } from "metabase/common/hooks";
-import {
- SETUP_SSO_CAMPAIGN,
- UTM_LOCATION,
-} from "metabase/embedding/embedding-iframe-sdk-setup/analytics";
-import { useSdkIframeEmbedSetupContext } from "metabase/embedding/embedding-iframe-sdk-setup/context";
-import { getAuthSubTypeForSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/get-auth-sub-type-for-settings";
-import { Alert, Anchor, Card, Icon, Radio, Stack, Text } from "metabase/ui";
-
-const utmTags = {
- utm_source: "product",
- utm_medium: "docs",
- utm_campaign: SETUP_SSO_CAMPAIGN,
- utm_content: UTM_LOCATION,
-};
-
-export const MetabaseAccountSection = () => {
- const { isSsoEnabledAndConfigured, settings, updateSettings } =
- useSdkIframeEmbedSetupContext();
-
- const isGuestEmbed = !!settings.isGuest;
-
- // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- Only for admins
- const { url: setupSsoUrl } = useDocsUrl("embedding/sdk/authentication", {
- utm: utmTags,
- });
-
- if (isGuestEmbed) {
- return null;
- }
-
- const authSubType = getAuthSubTypeForSettings(settings);
-
- const handleAuthSubTypeChange = (value: string) => {
- const useExistingUserSession = value === "user-session";
-
- updateSettings({ useExistingUserSession });
- };
-
- return (
- <>
- <Card p="md">
- <Stack gap="md">
- <Text size="lg" fw="bold">
- {
- // eslint-disable-next-line metabase/no-literal-metabase-strings -- Public Facing string
- t`Metabase account`
- }
- </Text>
-
- <Radio.Group value={authSubType} onChange={handleAuthSubTypeChange}>
- <Stack gap="sm">
- <Radio
- disabled={!isSsoEnabledAndConfigured}
- value="sso"
- label={t`Single sign-on`}
- />
-
- <Radio
- value="user-session"
- label={t`Existing session (local testing only)`}
- />
- </Stack>
- </Radio.Group>
- </Stack>
- </Card>
-
- {!isSsoEnabledAndConfigured && !!settings.useExistingUserSession && (
- <Alert icon={<Icon name="warning" size={16} />} color="warning">
- <Text size="md" lh="lg">
- {jt`The code below will only work for local testing. To get production ready code, configure ${(
- <Anchor
- key="configure-sso"
- href={setupSsoUrl}
- target="_blank"
- size="md"
- lh="lg"
- >
- {t`JWT SSO or SAML`}
- </Anchor>
- )}.`}
- </Text>
- </Alert>
- )}
- </>
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/AuthenticationCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/AuthenticationCard.tsx
new file mode 100644
index 00000000000..00becdbe44f
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/AuthenticationCard.tsx
@@ -0,0 +1,103 @@
+import { t } from "ttag";
+
+import { Card, Radio, Stack, Text } from "metabase/ui";
+
+import { useSdkIframeEmbedSetupContext } from "../../context";
+import { getAuthTypeForSettings } from "../../utils/get-auth-type-for-settings";
+import { getResourceTypeFromExperience } from "../../utils/get-resource-type-from-experience";
+import { SetupSsoAlert } from "../Common/SetupSsoAlert";
+import { DatabaseRoutingWarning } from "../DatabaseRoutingWarning";
+
+import { EnableGuestEmbedsSection } from "./EnableGuestEmbedsSection";
+import { EnableModularEmbeddingSection } from "./EnableModularEmbeddingSection";
+
+/**
+ * Authentication step of the embed setup wizard: lets the admin pick SSO or
+ * Guest auth, and surfaces the matching "enable + accept terms" CTA under the
+ * selected option.
+ */
+export const AuthenticationCard = () => {
+ const {
+ experience,
+ isSimpleEmbedFeatureAvailable,
+ isSsoEnabledAndConfigured,
+ currentStep,
+ settings,
+ updateSettings,
+ resource,
+ isSimpleEmbeddingEnabled,
+ isSimpleEmbeddingTermsAccepted,
+ isGuestEmbedsEnabled,
+ isGuestEmbedsTermsAccepted,
+ } = useSdkIframeEmbedSetupContext();
+
+ const resourceType = getResourceTypeFromExperience(experience);
+ const authType = getAuthTypeForSettings(settings);
+
+ const showSsoNotConfiguredWarning =
+ !isSsoEnabledAndConfigured && authType === "sso";
+
+ const handleAuthTypeChange = (value: string) => {
+ updateSettings({
+ isGuest: value === "guest-embed",
+ isSso: value === "sso",
+ });
+ };
+
+ return (
+ <Card p="md">
+ <Stack gap="md" p="xs">
+ <Text size="lg" fw="bold">
+ {t`Authentication`}
+ </Text>
+
+ <Radio.Group value={authType} onChange={handleAuthTypeChange}>
+ <Stack gap="md">
+ <Stack gap="sm">
+ <Radio
+ value="sso"
+ label={
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- Public Facing string
+ t`Metabase account (SSO)`
+ }
+ disabled={!isSimpleEmbedFeatureAvailable}
+ />
+ {authType === "sso" &&
+ isSimpleEmbedFeatureAvailable &&
+ isSimpleEmbeddingEnabled !== undefined && (
+ <EnableModularEmbeddingSection
+ key={currentStep}
+ isEnabled={isSimpleEmbeddingEnabled}
+ termsAccepted={isSimpleEmbeddingTermsAccepted}
+ />
+ )}
+ </Stack>
+
+ <Stack gap="sm">
+ <Radio value="guest-embed" label={t`Guest`} />
+ {authType === "guest-embed" && (
+ <>
+ {resource && resourceType && (
+ <DatabaseRoutingWarning
+ resource={resource}
+ resourceType={resourceType}
+ />
+ )}
+ {isGuestEmbedsEnabled !== undefined && (
+ <EnableGuestEmbedsSection
+ key={currentStep}
+ isEnabled={isGuestEmbedsEnabled}
+ termsAccepted={isGuestEmbedsTermsAccepted}
+ />
+ )}
+ </>
+ )}
+ </Stack>
+ </Stack>
+ </Radio.Group>
+
+ {showSsoNotConfiguredWarning && <SetupSsoAlert />}
+ </Stack>
+ </Card>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableGuestEmbedsSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableGuestEmbedsSection.tsx
new file mode 100644
index 00000000000..c37535529df
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableGuestEmbedsSection.tsx
@@ -0,0 +1,123 @@
+import { useRef, useState } from "react";
+import { match } from "ts-pattern";
+import { jt, t } from "ttag";
+
+import { useUpdateSettingsMutation } from "metabase/api";
+import { useToast } from "metabase/common/hooks";
+import { Anchor, Button, Group, Icon, Stack, Text } from "metabase/ui";
+
+import { UsageConditionsInfoIcon } from "./UsageConditionsInfoIcon";
+
+interface Props {
+ isEnabled: boolean;
+ termsAccepted: boolean;
+}
+
+/**
+ * Rendered under the Guest radio when guest embeds (`enable-embedding-static`)
+ * aren't enabled yet or the AGPL usage conditions haven't been accepted. Lets
+ * the admin enable the feature and accept the terms in a single click from
+ * inside the wizard.
+ */
+export const EnableGuestEmbedsSection = ({
+ isEnabled,
+ termsAccepted,
+}: Props) => {
+ const [updateSettings] = useUpdateSettingsMutation();
+ const [sendToast] = useToast();
+
+ const isAccepted = isEnabled && termsAccepted;
+
+ // Freeze visibility so the "Enabled" button state stays on screen
+ // after the user enables the setting.
+ const [showSection] = useState(!isAccepted);
+ const initialDataRef = useRef({ isEnabled, termsAccepted });
+
+ const handleEnable = async () => {
+ try {
+ await updateSettings({
+ "enable-embedding-static": true,
+ ...(!termsAccepted && { "show-static-embed-terms": false }),
+ });
+ } catch (error) {
+ sendToast({ message: t`Failed to enable guest embeds` });
+ }
+ };
+
+ if (!showSection) {
+ return null;
+ }
+
+ const usageConditionsLink = (
+ <Anchor
+ key="usage-conditions"
+ href="https://metabase.com/license/embedding"
+ target="_blank"
+ >
+ {t`usage conditions`}
+ </Anchor>
+ );
+
+ const { title, buttonCaption } =
+ match(initialDataRef.current)
+ .with({ isEnabled: false, termsAccepted: false }, () => ({
+ title: jt`To continue, enable guest embeds and agree to the ${usageConditionsLink}.`,
+ buttonCaption: t`Agree and enable`,
+ }))
+ .with({ isEnabled: true, termsAccepted: false }, () => ({
+ title: jt`Agree to the ${usageConditionsLink} to continue.`,
+ buttonCaption: t`Agree and continue`,
+ }))
+ .with({ isEnabled: false, termsAccepted: true }, () => ({
+ title: t`Enable guest embeds to get started.`,
+ buttonCaption: t`Enable and continue`,
+ }))
+ .otherwise(() => null) ?? {};
+
+ if (!title) {
+ return null;
+ }
+
+ return (
+ <Stack gap={0} pl="xl" data-testid="enable-embedding-card" mt="xs" mb="sm">
+ <Text fz="md" c="text-primary">
+ {title}
+
+ {!termsAccepted && (
+ <UsageConditionsInfoIcon>
+ <GuestEmbedsTooltipContent />
+ </UsageConditionsInfoIcon>
+ )}
+ </Text>
+
+ <Group justify="flex-start" mt="xs">
+ <Button
+ variant={isAccepted ? "default" : "filled"}
+ onClick={handleEnable}
+ size="xs"
+ disabled={isAccepted}
+ leftSection={isAccepted && <Icon name="check" />}
+ >
+ {isAccepted ? "Enabled" : buttonCaption}
+ </Button>
+ </Group>
+ </Stack>
+ );
+};
+
+const GuestEmbedsTooltipContent = () => (
+ <>
+ <Text fz="sm" lh="lg">
+ {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
+ {t`When you embed charts or dashboards from Metabase in your
+ own application, that application isn't subject to the Affero
+ General Public License that covers the rest of Metabase,
+ provided you keep the Metabase logo and the "Powered by
+ Metabase" visible on those embeds.`}
+ </Text>
+
+ <Text fz="sm" lh="lg">
+ {t`You should, however, read the license text linked above as that is the actual license that you will be agreeing to by enabling this feature.`}
+ </Text>
+ </>
+);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableModularEmbeddingSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableModularEmbeddingSection.tsx
new file mode 100644
index 00000000000..d2544e8340f
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/EnableModularEmbeddingSection.tsx
@@ -0,0 +1,115 @@
+import { useRef, useState } from "react";
+import { match } from "ts-pattern";
+import { t } from "ttag";
+
+import { useUpdateSettingsMutation } from "metabase/api";
+import { useToast } from "metabase/common/hooks";
+import { Button, Group, Icon, Stack, Text } from "metabase/ui";
+
+import { UsageConditionsInfoIcon } from "./UsageConditionsInfoIcon";
+
+interface Props {
+ isEnabled: boolean;
+ termsAccepted: boolean;
+}
+
+/**
+ * Rendered under the SSO radio when modular embedding
+ * (`enable-embedding-simple`) isn't enabled yet or its terms haven't been
+ * accepted. Lets the admin enable the feature and accept the terms in a
+ * single click from inside the wizard.
+ */
+export const EnableModularEmbeddingSection = ({
+ isEnabled,
+ termsAccepted,
+}: Props) => {
+ const [updateSettings] = useUpdateSettingsMutation();
+ const [sendToast] = useToast();
+
+ const isAccepted = isEnabled && termsAccepted;
+
+ // Freeze visibility so the "Enabled" button state stays on screen
+ // after the user enables the setting.
+ const [showSection] = useState(!isAccepted);
+ const initialDataRef = useRef({ isEnabled, termsAccepted });
+
+ const handleEnable = async () => {
+ try {
+ await updateSettings({
+ "enable-embedding-simple": true,
+ ...(!termsAccepted && { "show-simple-embed-terms": false }),
+ });
+ } catch (error) {
+ sendToast({ message: t`Failed to enable modular embedding` });
+ }
+ };
+
+ if (!showSection) {
+ return null;
+ }
+
+ const { title, buttonCaption } =
+ match(initialDataRef.current)
+ .with({ isEnabled: false, termsAccepted: false }, () => ({
+ title: t`To continue, enable modular embedding and agree to the usage conditions.`,
+ buttonCaption: t`Agree and enable`,
+ }))
+ .with({ isEnabled: true, termsAccepted: false }, () => ({
+ title: t`Agree to the usage conditions to continue.`,
+ buttonCaption: t`Agree and continue`,
+ }))
+ .with({ isEnabled: false, termsAccepted: true }, () => ({
+ title: t`Enable modular embedding to get started.`,
+ buttonCaption: t`Enable and continue`,
+ }))
+ .otherwise(() => null) ?? {};
+
+ if (!title) {
+ return null;
+ }
+
+ return (
+ <Stack gap={0} pl="xl" data-testid="enable-embedding-card" mt="xs" mb="sm">
+ <Text fz="md" c="text-primary">
+ {title}
+
+ {!termsAccepted && (
+ <UsageConditionsInfoIcon>
+ <ModularEmbeddingTooltipContent />
+ </UsageConditionsInfoIcon>
+ )}
+ </Text>
+
+ <Group justify="flex-start" mt="xs">
+ <Button
+ variant={isAccepted ? "default" : "filled"}
+ onClick={handleEnable}
+ size="xs"
+ disabled={isAccepted}
+ leftSection={isAccepted && <Icon name="check" />}
+ >
+ {isAccepted ? "Enabled" : buttonCaption}
+ </Button>
+ </Group>
+ </Stack>
+ );
+};
+
+const ModularEmbeddingTooltipContent = () => (
+ <>
+ <Text fz="sm" lh="lg">
+ {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
+ {t`When using modular embedding, each end user must have their own Metabase account.`}
+ </Text>
+
+ <Text fz="sm" lh="lg">
+ {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
+ {t`Sharing Metabase accounts is a security risk. Even if you filter data on the client side, each user could use their token to view any data visible to that shared user account.`}
+ </Text>
+
+ <Text fz="sm" lh="lg">
+ {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
+ {t`That, and we consider shared accounts to be unfair usage. Fair usage involves giving each end-user of the embedded analytics their own Metabase account.`}
+ </Text>
+ </>
+);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/UsageConditionsInfoIcon.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/UsageConditionsInfoIcon.tsx
new file mode 100644
index 00000000000..97da9262784
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/UsageConditionsInfoIcon.tsx
@@ -0,0 +1,32 @@
+import type { ReactNode } from "react";
+
+import { HoverCard, Icon, Stack } from "metabase/ui";
+
+/**
+ * Small info icon with a hover-card, used by both enable sections to surface
+ * per-embedding-type caveats next to the "agree to usage conditions" copy. The
+ * caller passes the actual tooltip body as `children`.
+ */
+export const UsageConditionsInfoIcon = ({
+ children,
+}: {
+ children: ReactNode;
+}) => (
+ <HoverCard position="bottom" withArrow>
+ <HoverCard.Target>
+ <Icon
+ name="info"
+ size={14}
+ c="text-secondary"
+ ml="sm"
+ style={{ verticalAlign: "middle" }}
+ />
+ </HoverCard.Target>
+
+ <HoverCard.Dropdown>
+ <Stack maw={340} p="md" gap="md">
+ {children}
+ </Stack>
+ </HoverCard.Dropdown>
+ </HoverCard>
+);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/index.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/index.ts
new file mode 100644
index 00000000000..82c8297b6d0
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/AuthenticationCard/index.ts
@@ -0,0 +1 @@
+export { AuthenticationCard } from "./AuthenticationCard";
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Common/SetupSsoAlert.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Common/SetupSsoAlert.tsx
new file mode 100644
index 00000000000..75e98337371
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Common/SetupSsoAlert.tsx
@@ -0,0 +1,43 @@
+import { jt, t } from "ttag";
+
+import { useDocsUrl } from "metabase/common/hooks";
+import { Alert, Anchor, Icon, Text } from "metabase/ui";
+
+import { SETUP_SSO_CAMPAIGN, UTM_LOCATION } from "../../analytics";
+
+const utmTags = {
+ utm_source: "product",
+ utm_medium: "docs",
+ utm_campaign: SETUP_SSO_CAMPAIGN,
+ utm_content: UTM_LOCATION,
+};
+
+export const SetupSsoAlert = () => {
+ // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- Only for admins
+ const { url: setupSsoUrl } = useDocsUrl("embedding/sdk/authentication", {
+ utm: utmTags,
+ });
+
+ return (
+ <Alert
+ icon={
+ <Icon name="warning_triangle_filled" c="text-secondary" size={16} />
+ }
+ color="warning"
+ >
+ <Text size="md" lh="lg">
+ {jt`This embed will only work for local testing. To get production ready code, configure ${(
+ <Anchor
+ key="configure-sso"
+ href={setupSsoUrl}
+ target="_blank"
+ size="md"
+ lh="lg"
+ >
+ {t`JWT SSO or SAML`}
+ </Anchor>
+ )}.`}
+ </Text>
+ </Alert>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/DatabaseRoutingWarning.tsx
similarity index 100%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.tsx
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/DatabaseRoutingWarning.tsx
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/DatabaseRoutingWarning.unit.spec.tsx
similarity index 100%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/DatabaseRoutingWarning.unit.spec.tsx
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/DatabaseRoutingWarning.unit.spec.tsx
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddedAnalyticsCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddedAnalyticsCard.tsx
deleted file mode 100644
index 2d09d19d0e0..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddedAnalyticsCard.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { t } from "ttag";
-
-import { useSdkIframeEmbedSetupContext } from "metabase/embedding/embedding-iframe-sdk-setup/context";
-
-import { EnableEmbeddingCard } from "./EnableEmbeddingCard";
-
-export const EnableEmbeddedAnalyticsCard = () => {
- const { isSimpleEmbeddingEnabled, isSimpleEmbeddingTermsAccepted } =
- useSdkIframeEmbedSetupContext();
-
- // Not yet fetched
- if (isSimpleEmbeddingEnabled === undefined) {
- return null;
- }
-
- return (
- <EnableEmbeddingCard
- embeddingType="modular-embedding"
- isEnabled={isSimpleEmbeddingEnabled}
- termsAccepted={isSimpleEmbeddingTermsAccepted}
- settingsToUpdate={{
- "enable-embedding-simple": true,
- ...(!isSimpleEmbeddingTermsAccepted && {
- "show-simple-embed-terms": false,
- }),
- }}
- errorMessage={t`Failed to enable modular embedding`}
- />
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddingCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddingCard.tsx
deleted file mode 100644
index 94f352a75bb..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddingCard.tsx
+++ /dev/null
@@ -1,201 +0,0 @@
-import { useRef, useState } from "react";
-import { match } from "ts-pattern";
-import { jt, t } from "ttag";
-
-import { useUpdateSettingsMutation } from "metabase/api";
-import { useToast } from "metabase/common/hooks";
-import {
- Anchor,
- Button,
- Group,
- HoverCard,
- Icon,
- Stack,
- Text,
-} from "metabase/ui";
-import type { EnterpriseSettings } from "metabase-types/api";
-
-interface EmbeddingControlCardProps {
- embeddingType: "guest-embeds" | "modular-embedding";
- isEnabled: boolean;
- termsAccepted: boolean;
- settingsToUpdate: Partial<EnterpriseSettings>;
- errorMessage: string;
-}
-
-export const EnableEmbeddingCard = ({
- embeddingType,
- isEnabled,
- termsAccepted,
- settingsToUpdate,
- errorMessage,
-}: EmbeddingControlCardProps) => {
- const [updateSettings] = useUpdateSettingsMutation();
- const [sendToast] = useToast();
-
- const isAccepted = isEnabled && termsAccepted;
-
- // Freeze the card visibility to show even when we enabled the embedding setting.
- // This allows us to show the "Enabled" button state and not hide the card.
- const [showCard] = useState(!isAccepted);
-
- const handleEnableEmbedding = async () => {
- try {
- await updateSettings(settingsToUpdate);
- } catch (error) {
- sendToast({ message: errorMessage });
- }
- };
-
- const initialDataRef = useRef({ isEnabled, termsAccepted });
-
- if (!showCard) {
- return null;
- }
-
- const embeddingTypeLocalized = match(embeddingType)
- .with("guest-embeds", () => t`guest embeds`)
- .with("modular-embedding", () => t`modular embedding`)
- .exhaustive();
-
- const data = match(initialDataRef.current)
- .with(
- {
- isEnabled: false,
- termsAccepted: false,
- },
- () => ({
- title:
- embeddingType === "guest-embeds"
- ? jt`To continue, enable guest embeds and agree to the ${(
- <Anchor
- key="usage-conditions"
- href="https://metabase.com/license/embedding"
- target="_blank"
- >
- {t`usage conditions`}
- </Anchor>
- )}.`
- : t`To continue, enable ${embeddingTypeLocalized} and agree to the usage conditions.`,
- buttonCaption: t`Agree and enable`,
- }),
- )
- .with(
- {
- isEnabled: true,
- termsAccepted: false,
- },
- () => ({
- title:
- embeddingType === "guest-embeds"
- ? jt`Agree to the ${(
- <Anchor
- key="usage-conditions"
- href="https://metabase.com/license/embedding"
- target="_blank"
- >
- {t`usage conditions`}
- </Anchor>
- )} to continue.`
- : t`Agree to the usage conditions to continue.`,
- buttonCaption: t`Agree and continue`,
- }),
- )
- .with(
- {
- isEnabled: false,
- termsAccepted: true,
- },
- () => ({
- title: t`Enable ${embeddingTypeLocalized} to get started.`,
- buttonCaption: t`Enable and continue`,
- }),
- )
- .otherwise(() => null);
-
- if (!data) {
- return null;
- }
-
- const { title, buttonCaption } = data;
-
- return (
- <Stack gap={0} data-testid="enable-embedding-card">
- <Text fz="md" c="text-primary">
- {title}
-
- {!termsAccepted && (
- <HoverCard position="bottom" withArrow>
- <HoverCard.Target>
- <Icon
- name="info"
- size={14}
- c="text-secondary"
- ml="sm"
- style={{ verticalAlign: "middle" }}
- />
- </HoverCard.Target>
-
- <HoverCard.Dropdown>
- <Stack maw={340} p="md" gap="md">
- {match(embeddingType)
- .with("guest-embeds", () => <GuestEmbedsTooltipContent />)
- .with("modular-embedding", () => (
- <ModularEmbeddingTooltipContent />
- ))
- .exhaustive()}
- </Stack>
- </HoverCard.Dropdown>
- </HoverCard>
- )}
- </Text>
-
- <Group justify="flex-end" mt="md">
- <Button
- variant={isAccepted ? "default" : "filled"}
- onClick={handleEnableEmbedding}
- disabled={isAccepted}
- leftSection={isAccepted && <Icon name="check" />}
- >
- {isAccepted ? "Enabled" : buttonCaption}
- </Button>
- </Group>
- </Stack>
- );
-};
-
-const GuestEmbedsTooltipContent = () => (
- <>
- <Text fz="sm" lh="lg">
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
- {t`When you embed charts or dashboards from Metabase in your
- own application, that application isn't subject to the Affero
- General Public License that covers the rest of Metabase,
- provided you keep the Metabase logo and the "Powered by
- Metabase" visible on those embeds.`}
- </Text>
-
- <Text fz="sm" lh="lg">
- {t`You should, however, read the license text linked above as that is the actual license that you will be agreeing to by enabling this feature.`}
- </Text>
- </>
-);
-
-const ModularEmbeddingTooltipContent = () => (
- <>
- <Text fz="sm" lh="lg">
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
- {t`When using modular embedding, each end user must have their own Metabase account.`}
- </Text>
-
- <Text fz="sm" lh="lg">
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
- {t`Sharing Metabase accounts is a security risk. Even if you filter data on the client side, each user could use their token to view any data visible to that shared user account.`}
- </Text>
-
- <Text fz="sm" lh="lg">
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Only admins, at the moment, should see this */}
- {t`That, and we consider shared accounts to be unfair usage. Fair usage involves giving each end-user of the embedded analytics their own Metabase account.`}
- </Text>
- </>
-);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableGuestEmbedsCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableGuestEmbedsCard.tsx
deleted file mode 100644
index c9753ba45c4..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/EnableGuestEmbedsCard.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { t } from "ttag";
-
-import { useSdkIframeEmbedSetupContext } from "metabase/embedding/embedding-iframe-sdk-setup/context";
-
-import { EnableEmbeddingCard } from "./EnableEmbeddingCard";
-
-export const EnableGuestEmbedsCard = () => {
- const { isGuestEmbedsEnabled, isGuestEmbedsTermsAccepted } =
- useSdkIframeEmbedSetupContext();
-
- // Not yet fetched
- if (isGuestEmbedsEnabled === undefined) {
- return null;
- }
-
- return (
- <EnableEmbeddingCard
- embeddingType="guest-embeds"
- isEnabled={isGuestEmbedsEnabled}
- termsAccepted={isGuestEmbedsTermsAccepted}
- settingsToUpdate={{
- "enable-embedding-static": true,
- ...(!isGuestEmbedsTermsAccepted && {
- "show-static-embed-terms": false,
- }),
- }}
- errorMessage={t`Failed to enable guest embeds`}
- />
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/GetCodeStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/GetCodeStep.tsx
deleted file mode 100644
index 2be5ac92179..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/GetCodeStep.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import { t } from "ttag";
-
-import { useUpdateSettingsMutation } from "metabase/api";
-import { CodeEditor } from "metabase/common/components/CodeEditor";
-import { EmbedServerSnippetLanguageSelect } from "metabase/embedding/components/EmbedServerSnippetLanguageSelect/EmbedServerSnippetLanguageSelect";
-import { MoreServerSnippetExamplesLink } from "metabase/embedding/components/MoreServerSnippetExamplesLink/MoreServerSnippetExamplesLink";
-import { MetabaseAccountSection } from "metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/MetabaseAccountSection";
-import { CopyCodeSnippetButton } from "metabase/embedding/embedding-iframe-sdk-setup/components/GetCode/CopyCodeSnippetButton";
-import { PublishQuestionEmptyState } from "metabase/embedding/embedding-iframe-sdk-setup/components/GetCode/PublishQuestionEmptyState";
-import { useSdkIframeEmbedServerSnippet } from "metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-server-snippet";
-import { Card, Flex, Stack, Text } from "metabase/ui";
-import type { SettingKey } from "metabase-types/api";
-
-import { trackEmbedWizardCodeCopied } from "../analytics";
-import { useSdkIframeEmbedSetupContext } from "../context";
-import { useSdkIframeEmbedSnippet } from "../hooks/use-sdk-iframe-embed-snippet";
-
-export const GetCodeStep = () => {
- const { experience, resource, settings } = useSdkIframeEmbedSetupContext();
- const [updateInstanceSettings] = useUpdateSettingsMutation();
-
- const isGuestEmbed = !!settings.isGuest;
-
- const serverSnippetData = useSdkIframeEmbedServerSnippet();
- const snippet = useSdkIframeEmbedSnippet();
-
- const trackSnippetCopied = (snippetType: "frontend" | "server") => {
- trackEmbedWizardCodeCopied({
- experience,
- resource,
- snippetType,
- settings,
- });
- };
-
- const handleFrontendSnippetCopied = () => {
- trackSnippetCopied("frontend");
-
- // Embedding Hub: track step completion
- // Test embed = guest or existing user session (for quick testing)
- // Production embed = full SSO setup
- const isTestEmbed = settings.isGuest || settings.useExistingUserSession;
-
- const settingKey: SettingKey = isTestEmbed
- ? "embedding-hub-test-embed-snippet-created"
- : "embedding-hub-production-embed-snippet-created";
-
- updateInstanceSettings({ [settingKey]: true });
- };
-
- const handleServerSnippetCopied = () => trackSnippetCopied("server");
-
- return (
- <Stack gap="md" flex={1}>
- {!isGuestEmbed && <MetabaseAccountSection />}
-
- {!isGuestEmbed || resource?.enable_embedding ? (
- <>
- <Card p="md">
- <Text size="lg" fw="bold" mb="md">
- {t`Embed code`}
- </Text>
-
- <Stack gap="sm">
- <div onCopy={handleFrontendSnippetCopied}>
- <CodeEditor
- language="html"
- value={snippet}
- readOnly
- lineNumbers={false}
- />
- </div>
-
- <CopyCodeSnippetButton
- snippet={snippet}
- onCopy={handleFrontendSnippetCopied}
- />
- </Stack>
- </Card>
-
- {!!serverSnippetData && (
- <Card p="md">
- <Flex align="baseline" justify="space-between">
- <Text size="lg" fw="bold" mb="md">
- {t`Server code`}
- </Text>
-
- <EmbedServerSnippetLanguageSelect
- languageOptions={serverSnippetData.serverSnippetOptions}
- selectedOptionId={serverSnippetData.selectedServerSnippetId}
- onChangeOption={serverSnippetData.setSelectedServerSnippetId}
- />
- </Flex>
-
- <Stack gap="sm">
- <CodeEditor
- language={serverSnippetData.serverSnippetOption.language}
- value={serverSnippetData.serverSnippetOption.source}
- readOnly
- lineNumbers={false}
- />
-
- <CopyCodeSnippetButton
- snippet={serverSnippetData.serverSnippetOption.source}
- onCopy={handleServerSnippetCopied}
- />
-
- <MoreServerSnippetExamplesLink />
- </Stack>
- </Card>
- )}
- </>
- ) : (
- <PublishQuestionEmptyState />
- )}
- </Stack>
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupModal.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupModal.tsx
index 7182bc9be72..d4564cab1fe 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupModal.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeEmbedSetupModal.tsx
@@ -1,4 +1,3 @@
-import cx from "classnames";
import { useMemo, useState } from "react";
import { ResizableBox } from "react-resizable";
import { match } from "ts-pattern";
@@ -8,8 +7,6 @@ import "react-resizable/css/styles.css";
import noResultsSource from "assets/img/no_results.svg";
import { useUpdateSettingsMutation } from "metabase/api";
-import CS from "metabase/css/core/index.css";
-import { AuthenticationSection } from "metabase/embedding/embedding-iframe-sdk-setup/components/Authentication/AuthenticationSection";
import { SdkIframeGuestEmbedStatusBar } from "metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeGuestEmbedStatusBar";
import { EMBED_STEPS } from "metabase/embedding/embedding-iframe-sdk-setup/constants";
import { isQuestionOrDashboardSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-settings";
@@ -26,6 +23,7 @@ import {
Image,
Modal,
Stack,
+ Text,
} from "metabase/ui";
import type { SettingKey } from "metabase-types/api";
@@ -118,18 +116,7 @@ export const SdkIframeEmbedSetupContent = () => {
<Box className={S.Sidebar} component="aside">
<Stack className={S.SidebarContent} gap="md">
<Stack gap="md" flex={1}>
- <AuthenticationSection />
-
- <Stack
- gap="md"
- flex={1}
- opacity={allowPreviewAndNavigation ? 1 : 0.5}
- className={cx(
- !allowPreviewAndNavigation && CS.pointerEventsNone,
- )}
- >
- <StepContent />
- </Stack>
+ <StepContent />
</Stack>
</Stack>
@@ -160,7 +147,17 @@ export const SdkIframeEmbedSetupContent = () => {
) : (
<Card h="100%">
<Flex h="100%" align="center" justify="center">
- <Image w={120} h={120} src={noResultsSource} alt="No results" />
+ <Stack align="center" gap="md">
+ <Image
+ w={120}
+ h={120}
+ src={noResultsSource}
+ alt="No results"
+ />
+ <Text c="text-secondary">
+ {t`Preview will appear when you select what to embed`}
+ </Text>
+ </Stack>
</Flex>
</Card>
)}
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeStepEnableEmbeddingSection.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeStepEnableEmbeddingSection.tsx
deleted file mode 100644
index 5a036a594d5..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeStepEnableEmbeddingSection.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { EnableEmbeddedAnalyticsCard } from "metabase/embedding/embedding-iframe-sdk-setup/components/EnableEmbeddedAnalyticsCard";
-import { EnableGuestEmbedsCard } from "metabase/embedding/embedding-iframe-sdk-setup/components/EnableGuestEmbedsCard";
-import { useSdkIframeEmbedSetupContext } from "metabase/embedding/embedding-iframe-sdk-setup/context";
-
-export const SdkIframeStepEnableEmbeddingSection = () => {
- const { isSimpleEmbedFeatureAvailable, currentStep, settings } =
- useSdkIframeEmbedSetupContext();
-
- const isGuestEmbed = !!settings.isGuest;
- const rerenderKey = currentStep;
-
- if (isGuestEmbed) {
- return <EnableGuestEmbedsCard key={rerenderKey} />;
- }
-
- return isSimpleEmbedFeatureAvailable ? (
- <EnableEmbeddedAnalyticsCard key={rerenderKey} />
- ) : null;
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceMissingRecents.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceMissingRecents.tsx
deleted file mode 100644
index aa3fe0bfbfb..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceMissingRecents.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { match } from "ts-pattern";
-import { c, t } from "ttag";
-
-import { Anchor, Icon, Stack, Text } from "metabase/ui";
-import type { IconName } from "metabase-types/api";
-
-import type { SdkIframeEmbedSetupExperience } from "../types";
-
-export const SelectEmbedResourceMissingRecents = ({
- experience,
- openPicker,
-}: {
- experience: SdkIframeEmbedSetupExperience;
- openPicker: () => void;
-}) => {
- const embedIcon = match<SdkIframeEmbedSetupExperience, IconName>(experience)
- .with("dashboard", () => "dashboard")
- .with("browser", () => "collection")
- .otherwise(() => "bar");
-
- return (
- <Stack
- align="center"
- gap="md"
- py="xl"
- data-testid="embed-resource-missing-recents"
- >
- <Icon name={embedIcon} size={48} c="text-tertiary" />
-
- <Stack align="center" gap="xs">
- <Text fw="bold" size="md">
- {getEmptyStateTitle(experience)}
- </Text>
-
- <Text size="sm" c="text-secondary" ta="center">
- {getEmptyStateDescription(experience)}
- </Text>
-
- <Text size="sm" c="text-secondary" ta="center">
- {getSearchLink(experience, openPicker)}
- </Text>
- </Stack>
- </Stack>
- );
-};
-
-const getEmptyStateTitle = (experience: SdkIframeEmbedSetupExperience) =>
- match(experience)
- .with("dashboard", () => t`No recent dashboards`)
- .with("chart", () => t`No recent charts`)
- .with("browser", () => t`No recent collections`)
- .otherwise(() => null);
-
-const getEmptyStateDescription = (experience: SdkIframeEmbedSetupExperience) =>
- match(experience)
- .with("dashboard", () => t`You haven't visited any dashboards recently.`)
- .with("chart", () => t`You haven't visited any charts recently.`)
- .with("browser", () => t`You haven't visited any collections recently.`)
- .otherwise(() => null);
-
-const getSearchLink = (
- experience: SdkIframeEmbedSetupExperience,
- openPicker: () => void,
-) =>
- match(experience)
- .with(
- "dashboard",
- () =>
- c("{0} is a link button to search for dashboards")
- .jt`You can ${<Anchor size="sm" onClick={openPicker} key="picker-link" inline>{t`search for dashboards`}</Anchor>} to embed.`,
- )
- .with(
- "chart",
- () =>
- c("{0} is a link button to search for charts")
- .jt`You can ${<Anchor size="sm" onClick={openPicker} key="picker-link" inline>{t`search for charts`}</Anchor>} to embed.`,
- )
- .otherwise(() => null);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.module.css b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.module.css
deleted file mode 100644
index cf8729c7464..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.module.css
+++ /dev/null
@@ -1,20 +0,0 @@
-.ResourceCard {
- cursor: pointer;
- border: 1px solid var(--mb-color-border);
- transition: border-color 0.2s ease-in-out;
- user-select: none;
-}
-
-.ResourceCard[data-selected="true"] {
- border-color: var(--mb-color-brand);
-}
-
-.ResourceCard:hover {
- background: var(--mb-color-background-hover);
-}
-
-@media (prefers-reduced-motion) {
- .ResourceCard {
- transition: none;
- }
-}
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.tsx
deleted file mode 100644
index 47c11206a97..00000000000
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceRecentItemCard.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { P, match } from "ts-pattern";
-
-import { Card, Group, Icon, Stack, Text } from "metabase/ui";
-import type { IconName } from "metabase-types/api";
-
-import { STEPS_WITHOUT_RESOURCE_SELECTION } from "../constants";
-import type {
- SdkIframeEmbedSetupExperience,
- SdkIframeEmbedSetupRecentItem,
-} from "../types";
-
-import S from "./SelectEmbedResourceRecentItemCard.module.css";
-
-export const SelectEmbedResourceRecentItemCard = ({
- recentItem,
- selectedItemId,
- experience,
- onSelect,
-}: {
- recentItem: SdkIframeEmbedSetupRecentItem;
- experience: SdkIframeEmbedSetupExperience;
-
- selectedItemId?: string | number;
-
- onSelect(
- experience: SdkIframeEmbedSetupExperience,
- id: string | number,
- ): void;
-}) => (
- <Card
- p="md"
- key={recentItem.id}
- onClick={() => onSelect(experience, recentItem.id)}
- className={S.ResourceCard}
- data-selected={selectedItemId === recentItem.id}
- data-testid="embed-recent-item-card"
- >
- <Group align="start" gap="sm">
- <Icon name={getCardIcon(experience)} size={20} c="brand" />
-
- <Stack gap="xs" flex={1}>
- <Text fw="bold">{recentItem.name}</Text>
-
- {recentItem.description && (
- <Text size="sm" c="text-secondary">
- {recentItem.description}
- </Text>
- )}
- </Stack>
- </Group>
- </Card>
-);
-
-const getCardIcon = (experience: SdkIframeEmbedSetupExperience): IconName =>
- match<SdkIframeEmbedSetupExperience, IconName>(experience)
- .with("chart", () => "bar")
- .with("dashboard", () => "dashboard")
- .with("browser", () => "collection")
- .with(P.union(...STEPS_WITHOUT_RESOURCE_SELECTION), () => "question") // these do not require resource selection
- .exhaustive();
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceCard.tsx
new file mode 100644
index 00000000000..b6705d511ff
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceCard.tsx
@@ -0,0 +1,136 @@
+import { useCallback } from "react";
+import { P, match } from "ts-pattern";
+import { t } from "ttag";
+
+import { useListEmbeddingThemesQuery } from "metabase/api/embedding-theme";
+import type {
+ MetabaseColors,
+ MetabaseThemePreset,
+} from "metabase/embedding-sdk/theme";
+import { Card, Checkbox, Divider, Icon, Tooltip } from "metabase/ui";
+
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { BaseAppearanceSection } from "../../Appearance/BaseAppearanceSection";
+import { SimpleThemeSwitcherSection } from "../../Appearance/SimpleThemeSwitcherSection";
+import { ThemeSelectorSection } from "../../Appearance/ThemeSelectorSection";
+import { MetabotLayoutSetting } from "../../MetabotLayoutSetting";
+
+export const AppearanceCard = () => {
+ const { isSimpleEmbedFeatureAvailable, settings, updateSettings } =
+ useSdkIframeEmbedSetupContext();
+
+ const { theme } = settings;
+
+ const { data: savedThemes } = useListEmbeddingThemesQuery(undefined, {
+ skip: !isSimpleEmbedFeatureAvailable,
+ });
+
+ const updateThemeId = useCallback(
+ (themeId: number | undefined) => {
+ updateSettings({
+ theme: themeId ? { id: themeId } : undefined,
+ } satisfies Partial<typeof settings>);
+ },
+ [updateSettings],
+ );
+
+ const initializeCustomTheme = useCallback(
+ (initialColors: Partial<MetabaseColors> | undefined) => {
+ updateSettings({
+ theme: initialColors ? { colors: initialColors } : undefined,
+ } satisfies Partial<typeof settings>);
+ },
+ [updateSettings],
+ );
+
+ const updateThemePreset = useCallback(
+ (preset: MetabaseThemePreset) => {
+ updateSettings({ theme: { preset } } satisfies Partial<typeof settings>);
+ },
+ [updateSettings],
+ );
+
+ const updateColors = useCallback(
+ (nextColors: Partial<MetabaseColors>) => {
+ updateSettings({
+ theme: { ...theme, colors: { ...theme?.colors, ...nextColors } },
+ } satisfies Partial<typeof settings>);
+ },
+ [theme, updateSettings],
+ );
+
+ const resetTheme = useCallback(
+ () =>
+ updateSettings({ theme: undefined } satisfies Partial<typeof settings>),
+ [updateSettings],
+ );
+
+ const hasSavedThemes = (savedThemes?.length ?? 0) > 0;
+ const showHeaderReset =
+ isSimpleEmbedFeatureAvailable && !hasSavedThemes && !!theme?.colors;
+
+ const appearanceSection = match(settings)
+ .with({ template: "exploration" }, () => null)
+ .with({ componentName: "metabase-metabot" }, () => <MetabotLayoutSetting />)
+ .with(
+ { componentName: P.union("metabase-question", "metabase-dashboard") },
+ (settings) => {
+ const label = match(settings.componentName)
+ .with("metabase-dashboard", () => t`Show dashboard title`)
+ .with("metabase-question", () => t`Show chart title`)
+ .exhaustive();
+
+ return (
+ <Checkbox
+ label={label}
+ checked={settings.withTitle}
+ onChange={(e) =>
+ updateSettings({
+ withTitle: e.target.checked,
+ } satisfies Partial<typeof settings>)
+ }
+ />
+ );
+ },
+ )
+ .otherwise(() => null);
+
+ return (
+ <Card p="md">
+ <BaseAppearanceSection
+ icons={
+ showHeaderReset ? (
+ <Tooltip label={t`Reset colors`}>
+ <Icon
+ name="revert"
+ size={16}
+ c="brand"
+ onClick={resetTheme}
+ aria-label={t`Reset colors`}
+ style={{ cursor: "pointer" }}
+ />
+ </Tooltip>
+ ) : null
+ }
+ >
+ {isSimpleEmbedFeatureAvailable ? (
+ <ThemeSelectorSection
+ savedThemes={savedThemes ?? []}
+ theme={theme}
+ onThemeChange={updateThemeId}
+ onCustomSelect={initializeCustomTheme}
+ onColorChange={updateColors}
+ onColorReset={resetTheme}
+ />
+ ) : (
+ <SimpleThemeSwitcherSection
+ preset={theme?.preset}
+ onPresetChange={updateThemePreset}
+ />
+ )}
+ </BaseAppearanceSection>
+ {appearanceSection && <Divider mt="lg" mb="md" />}
+ {appearanceSection}
+ </Card>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx
new file mode 100644
index 00000000000..88c46822886
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.tsx
@@ -0,0 +1,50 @@
+import cx from "classnames";
+
+import CS from "metabase/css/core/index.css";
+import { Stack } from "metabase/ui";
+
+import { UPSELL_CAMPAIGN_BEHAVIOR } from "../../../analytics";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { AuthenticationCard } from "../../AuthenticationCard";
+import { EmbeddingUpsell } from "../../Common/EmbeddingUpsell";
+import { LegacyStaticEmbeddingAlert } from "../../LegacyStaticEmbeddingAlert";
+
+import { AppearanceCard } from "./AppearanceCard";
+import { BehaviorCard } from "./BehaviorCard";
+import { ParametersCard } from "./ParametersCard";
+
+export const AppearanceStep = () => {
+ const {
+ isFirstStep,
+ isSimpleEmbedFeatureAvailable,
+ isSimpleEmbeddingTermsAccepted,
+ } = useSdkIframeEmbedSetupContext();
+
+ // When the wizard lands directly on this step (initialState) on a Pro
+ // instance, the user needs to configure auth first — dim the option cards
+ // so the AuthenticationCard above takes focus.
+ const isDimmed =
+ isFirstStep &&
+ isSimpleEmbedFeatureAvailable &&
+ !isSimpleEmbeddingTermsAccepted;
+ const dimmedProps = {
+ opacity: isDimmed ? 0.5 : 1,
+ className: cx(isDimmed && CS.pointerEventsNone),
+ };
+
+ return (
+ <Stack gap="md">
+ {/* When the wizard is opened with a preselected resource (initialState),
+ the options step is the user's first step and must show the auth
+ controls so they can switch auth type or accept terms. */}
+ {isFirstStep && <AuthenticationCard />}
+ <Stack gap="md" {...dimmedProps}>
+ <BehaviorCard />
+ <ParametersCard />
+ <AppearanceCard />
+ </Stack>
+ <LegacyStaticEmbeddingAlert />
+ <EmbeddingUpsell campaign={UPSELL_CAMPAIGN_BEHAVIOR} />
+ </Stack>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx
new file mode 100644
index 00000000000..944fcb298cb
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/AppearanceStep.unit.spec.tsx
@@ -0,0 +1,77 @@
+import { screen, waitFor } from "__support__/ui";
+import { PLUGIN_EMBEDDING_IFRAME_SDK_SETUP } from "metabase/plugins";
+
+import { setup } from "../../tests/test-setup";
+
+const landOnAppearanceStep = (overrides?: Parameters<typeof setup>[0]) =>
+ setup({
+ initialState: { resourceId: 1, resourceType: "dashboard" },
+ ...overrides,
+ });
+
+const getOptionCardsWrapper = () => {
+ const wrapper = screen.getByText("Behavior").closest("[style*='opacity']");
+ if (!wrapper) {
+ throw new Error("Could not find option cards wrapper with opacity style");
+ }
+ return wrapper as HTMLElement;
+};
+
+describe("AppearanceStep > option cards dim state when landing on this step directly", () => {
+ describe("OSS (simple-embedding plugin disabled)", () => {
+ beforeEach(() => {
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = jest.fn(() => false);
+ });
+
+ it("does not dim the option cards", async () => {
+ // showSimpleEmbedTerms is true in real OSS — the terms popup is
+ // never shown to OSS users, so the setting never flips to false.
+ landOnAppearanceStep({
+ simpleEmbeddingEnabled: false,
+ showSimpleEmbedTerms: true,
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Behavior")).toBeVisible();
+ });
+
+ expect(getOptionCardsWrapper()).toHaveStyle({ opacity: "1" });
+ });
+ });
+
+ describe("Pro (simple-embedding plugin enabled)", () => {
+ beforeEach(() => {
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = jest.fn(() => true);
+ });
+
+ afterEach(() => {
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => false;
+ });
+
+ it("dims the option cards when the user has not accepted the simple-embedding terms", async () => {
+ landOnAppearanceStep({
+ simpleEmbeddingEnabled: true,
+ showSimpleEmbedTerms: true,
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Behavior")).toBeVisible();
+ });
+
+ expect(getOptionCardsWrapper()).toHaveStyle({ opacity: "0.5" });
+ });
+
+ it("does not dim the option cards once the user has accepted the simple-embedding terms", async () => {
+ landOnAppearanceStep({
+ simpleEmbeddingEnabled: true,
+ showSimpleEmbedTerms: false,
+ });
+
+ await waitFor(() => {
+ expect(screen.getByText("Behavior")).toBeVisible();
+ });
+
+ expect(getOptionCardsWrapper()).toHaveStyle({ opacity: "1" });
+ });
+ });
+});
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/BehaviorCard.tsx
similarity index 65%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/BehaviorCard.tsx
index f9553c7adb9..83fa9209599 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedOptionsStep.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/BehaviorCard.tsx
@@ -1,20 +1,14 @@
-import { useCallback, useMemo } from "react";
+import { useMemo } from "react";
import { Link } from "react-router";
import { P, match } from "ts-pattern";
import { c, t } from "ttag";
-import { useListEmbeddingThemesQuery } from "metabase/api/embedding-theme";
import { UpsellGem } from "metabase/common/components/upsells/components/UpsellGem";
import { useDocsUrl, useHasEmailSetup } from "metabase/common/hooks";
-import type {
- MetabaseColors,
- MetabaseThemePreset,
-} from "metabase/embedding-sdk/theme";
import {
Anchor,
Card,
Checkbox,
- Divider,
Flex,
HoverCard,
Icon,
@@ -23,30 +17,11 @@ import {
Tooltip,
} from "metabase/ui";
-import { UPSELL_CAMPAIGN_BEHAVIOR } from "../analytics";
-import { useSdkIframeEmbedSetupContext } from "../context";
-import { getBehaviorDocsUrlParams } from "../utils/get-behavior-docs-url-params";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { getBehaviorDocsUrlParams } from "../../../utils/get-behavior-docs-url-params";
+import { WithNotAvailableForOssOrGuestEmbedsGuard } from "../../Common/WithNotAvailableForOssOrGuestEmbedsGuard";
-import { BaseAppearanceSection } from "./Appearance/BaseAppearanceSection";
-import { SimpleThemeSwitcherSection } from "./Appearance/SimpleThemeSwitcherSection";
-import { ThemeSelectorSection } from "./Appearance/ThemeSelectorSection";
-import { EmbeddingUpsell } from "./Common/EmbeddingUpsell";
-import { WithNotAvailableForOssOrGuestEmbedsGuard } from "./Common/WithNotAvailableForOssOrGuestEmbedsGuard";
-import { LegacyStaticEmbeddingAlert } from "./LegacyStaticEmbeddingAlert";
-import { MetabotLayoutSetting } from "./MetabotLayoutSetting";
-import { ParameterSettings } from "./ParameterSettings";
-
-export const SelectEmbedOptionsStep = () => (
- <Stack gap="md">
- <BehaviorSection />
- <ParametersSection />
- <AppearanceSection />
- <LegacyStaticEmbeddingAlert />
- <EmbeddingUpsell campaign={UPSELL_CAMPAIGN_BEHAVIOR} />
- </Stack>
-);
-
-const BehaviorSection = () => {
+export const BehaviorCard = () => {
const { isSimpleEmbedFeatureAvailable, settings, updateSettings } =
useSdkIframeEmbedSetupContext();
const hasEmailSetup = useHasEmailSetup();
@@ -74,6 +49,17 @@ const BehaviorSection = () => {
/>
),
)
+ .with({ componentName: "metabase-metabot" }, (settings) => (
+ <Checkbox
+ label={t`Allow people to save new questions`}
+ checked={settings.isSaveEnabled}
+ onChange={(e) =>
+ updateSettings({
+ isSaveEnabled: e.target.checked,
+ } satisfies Partial<typeof settings>)
+ }
+ />
+ ))
.with(
{ componentName: "metabase-question", questionId: P.nonNullable },
(settings) => (
@@ -301,147 +287,3 @@ const BehaviorSection = () => {
</Card>
);
};
-
-const ParametersSection = () => {
- const { experience } = useSdkIframeEmbedSetupContext();
-
- if (experience !== "dashboard" && experience !== "chart") {
- return null;
- }
-
- return (
- <Card p="md">
- <Text size="lg" fw="bold" mb="xs">
- {t`Parameters`}
- </Text>
-
- <Text size="sm" c="text-secondary" mb="lg">
- {experience === "dashboard"
- ? t`Set default values and control visibility`
- : t`Set default values`}
- </Text>
-
- <ParameterSettings />
- </Card>
- );
-};
-
-const AppearanceSection = () => {
- const { isSimpleEmbedFeatureAvailable, settings, updateSettings } =
- useSdkIframeEmbedSetupContext();
-
- const { theme } = settings;
-
- const { data: savedThemes } = useListEmbeddingThemesQuery(undefined, {
- skip: !isSimpleEmbedFeatureAvailable,
- });
-
- const updateThemeId = useCallback(
- (themeId: number | undefined) => {
- updateSettings({
- theme: themeId ? { id: themeId } : undefined,
- } satisfies Partial<typeof settings>);
- },
- [updateSettings],
- );
-
- const initializeCustomTheme = useCallback(
- (initialColors: Partial<MetabaseColors> | undefined) => {
- updateSettings({
- theme: initialColors ? { colors: initialColors } : undefined,
- } satisfies Partial<typeof settings>);
- },
- [updateSettings],
- );
-
- const updateThemePreset = useCallback(
- (preset: MetabaseThemePreset) => {
- updateSettings({ theme: { preset } } satisfies Partial<typeof settings>);
- },
- [updateSettings],
- );
-
- const updateColors = useCallback(
- (nextColors: Partial<MetabaseColors>) => {
- updateSettings({
- theme: { ...theme, colors: { ...theme?.colors, ...nextColors } },
- } satisfies Partial<typeof settings>);
- },
- [theme, updateSettings],
- );
-
- const resetTheme = useCallback(
- () =>
- updateSettings({ theme: undefined } satisfies Partial<typeof settings>),
- [updateSettings],
- );
-
- const hasSavedThemes = (savedThemes?.length ?? 0) > 0;
- const showHeaderReset =
- isSimpleEmbedFeatureAvailable && !hasSavedThemes && !!theme?.colors;
-
- const appearanceSection = match(settings)
- .with({ template: "exploration" }, () => null)
- .with({ componentName: "metabase-metabot" }, () => <MetabotLayoutSetting />)
- .with(
- { componentName: P.union("metabase-question", "metabase-dashboard") },
- (settings) => {
- const label = match(settings.componentName)
- .with("metabase-dashboard", () => t`Show dashboard title`)
- .with("metabase-question", () => t`Show chart title`)
- .exhaustive();
-
- return (
- <Checkbox
- label={label}
- checked={settings.withTitle}
- onChange={(e) =>
- updateSettings({
- withTitle: e.target.checked,
- } satisfies Partial<typeof settings>)
- }
- />
- );
- },
- )
- .otherwise(() => null);
-
- return (
- <Card p="md">
- <BaseAppearanceSection
- icons={
- showHeaderReset ? (
- <Tooltip label={t`Reset colors`}>
- <Icon
- name="revert"
- size={16}
- c="brand"
- onClick={resetTheme}
- aria-label={t`Reset colors`}
- style={{ cursor: "pointer" }}
- />
- </Tooltip>
- ) : null
- }
- >
- {isSimpleEmbedFeatureAvailable ? (
- <ThemeSelectorSection
- savedThemes={savedThemes ?? []}
- theme={theme}
- onThemeChange={updateThemeId}
- onCustomSelect={initializeCustomTheme}
- onColorChange={updateColors}
- onColorReset={resetTheme}
- />
- ) : (
- <SimpleThemeSwitcherSection
- preset={theme?.preset}
- onPresetChange={updateThemePreset}
- />
- )}
- </BaseAppearanceSection>
- {appearanceSection && <Divider mt="lg" mb="md" />}
- {appearanceSection}
- </Card>
- );
-};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/ParametersCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/ParametersCard.tsx
new file mode 100644
index 00000000000..7c33a87e60d
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/AppearanceStep/ParametersCard.tsx
@@ -0,0 +1,30 @@
+import { t } from "ttag";
+
+import { Card, Text } from "metabase/ui";
+
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { ParameterSettings } from "../../ParameterSettings";
+
+export const ParametersCard = () => {
+ const { experience } = useSdkIframeEmbedSetupContext();
+
+ if (experience !== "dashboard" && experience !== "chart") {
+ return null;
+ }
+
+ return (
+ <Card p="md">
+ <Text size="lg" fw="bold" mb="xs">
+ {t`Parameters`}
+ </Text>
+
+ <Text size="sm" c="text-secondary" mb="lg">
+ {experience === "dashboard"
+ ? t`Set default values and control visibility`
+ : t`Set default values`}
+ </Text>
+
+ <ParameterSettings />
+ </Card>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/EmbedCodeCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/EmbedCodeCard.tsx
new file mode 100644
index 00000000000..db90804e0ec
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/EmbedCodeCard.tsx
@@ -0,0 +1,62 @@
+import { c, t } from "ttag";
+
+import { CodeEditor } from "metabase/common/components/CodeEditor";
+import { useDocsUrl } from "metabase/common/hooks";
+import { Anchor, Card, Divider, Stack, Text } from "metabase/ui";
+
+import { UTM_LOCATION } from "../../../analytics";
+import { CopyCodeSnippetButton } from "../../GetCode/CopyCodeSnippetButton";
+
+interface EmbedCodeCardProps {
+ snippet: string;
+ onCopy: () => void;
+}
+
+const utmTags = {
+ utm_source: "product",
+ utm_campaign: "embedding_get_code",
+ utm_content: UTM_LOCATION,
+};
+
+export const EmbedCodeCard = ({ snippet, onCopy }: EmbedCodeCardProps) => {
+ // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- Only for admins
+ const { url: docsUrl } = useDocsUrl("embedding/modular-embedding", {
+ anchor: "add-the-embedding-script-to-your-app",
+ utm: utmTags,
+ });
+
+ const docsLink = (
+ <Anchor key="docs" href={docsUrl} target="_blank">
+ {t`docs`}
+ </Anchor>
+ );
+
+ return (
+ <Card p="md">
+ <Stack gap="xs" mb="md">
+ <Text size="lg" fw="bold">
+ {t`Embed code`}
+ </Text>
+ <Text size="sm" c="text-secondary">
+ {c("{0} is a link labeled 'docs'")
+ .jt`Add this snippet to your app. To modify this code and tweak additional options, refer to the ${docsLink}.`}
+ </Text>
+ </Stack>
+
+ <Divider mb="md" />
+
+ <Stack gap="sm">
+ <div onCopy={onCopy}>
+ <CodeEditor
+ language="html"
+ value={snippet}
+ readOnly
+ lineNumbers={false}
+ />
+ </div>
+
+ <CopyCodeSnippetButton snippet={snippet} onCopy={onCopy} />
+ </Stack>
+ </Card>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/GetCodeStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/GetCodeStep.tsx
new file mode 100644
index 00000000000..d1472a5878e
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/GetCodeStep.tsx
@@ -0,0 +1,75 @@
+import { useUpdateSettingsMutation } from "metabase/api";
+import { Stack } from "metabase/ui";
+import type { SettingKey } from "metabase-types/api";
+
+import { trackEmbedWizardCodeCopied } from "../../../analytics";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { useSdkIframeEmbedServerSnippet } from "../../../hooks/use-sdk-iframe-embed-server-snippet";
+import { useSdkIframeEmbedSnippet } from "../../../hooks/use-sdk-iframe-embed-snippet";
+import { PublishQuestionEmptyState } from "../../GetCode/PublishQuestionEmptyState";
+
+import { EmbedCodeCard } from "./EmbedCodeCard";
+import { MetabaseAccountCard } from "./MetabaseAccountCard";
+import { ServerCodeCard } from "./ServerCodeCard";
+
+export const GetCodeStep = () => {
+ const { experience, resource, settings } = useSdkIframeEmbedSetupContext();
+ const [updateInstanceSettings] = useUpdateSettingsMutation();
+
+ const isGuestEmbed = !!settings.isGuest;
+
+ const serverSnippetData = useSdkIframeEmbedServerSnippet();
+ const snippet = useSdkIframeEmbedSnippet();
+
+ const trackSnippetCopied = (snippetType: "frontend" | "server") => {
+ trackEmbedWizardCodeCopied({
+ experience,
+ resource,
+ snippetType,
+ settings,
+ });
+ };
+
+ const handleFrontendSnippetCopied = () => {
+ trackSnippetCopied("frontend");
+
+ // Embedding Hub: track step completion
+ // Test embed = guest or existing user session (for quick testing)
+ // Production embed = full SSO setup
+ const isTestEmbed = settings.isGuest || settings.useExistingUserSession;
+
+ const settingKey: SettingKey = isTestEmbed
+ ? "embedding-hub-test-embed-snippet-created"
+ : "embedding-hub-production-embed-snippet-created";
+
+ updateInstanceSettings({ [settingKey]: true });
+ };
+
+ const handleServerSnippetCopied = () => trackSnippetCopied("server");
+
+ const showCode = !isGuestEmbed || resource?.enable_embedding;
+
+ return (
+ <Stack gap="md" flex={1}>
+ {!isGuestEmbed && <MetabaseAccountCard />}
+
+ {showCode ? (
+ <>
+ <EmbedCodeCard
+ snippet={snippet}
+ onCopy={handleFrontendSnippetCopied}
+ />
+
+ {!!serverSnippetData && (
+ <ServerCodeCard
+ serverSnippetData={serverSnippetData}
+ onCopy={handleServerSnippetCopied}
+ />
+ )}
+ </>
+ ) : (
+ <PublishQuestionEmptyState />
+ )}
+ </Stack>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/MetabaseAccountCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/MetabaseAccountCard.tsx
new file mode 100644
index 00000000000..a545454fc53
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/MetabaseAccountCard.tsx
@@ -0,0 +1,94 @@
+import { jt, t } from "ttag";
+
+import { useDocsUrl } from "metabase/common/hooks";
+import { Alert, Anchor, Card, Icon, Radio, Stack, Text } from "metabase/ui";
+
+import { SETUP_SSO_CAMPAIGN, UTM_LOCATION } from "../../../analytics";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { getAuthSubTypeForSettings } from "../../../utils/get-auth-sub-type-for-settings";
+
+const utmTags = {
+ utm_source: "product",
+ utm_medium: "docs",
+ utm_campaign: SETUP_SSO_CAMPAIGN,
+ utm_content: UTM_LOCATION,
+};
+
+export const MetabaseAccountCard = () => {
+ const { isSsoEnabledAndConfigured, settings, updateSettings } =
+ useSdkIframeEmbedSetupContext();
+
+ const isGuestEmbed = !!settings.isGuest;
+
+ // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- Only for admins
+ const { url: setupSsoUrl } = useDocsUrl("embedding/sdk/authentication", {
+ utm: utmTags,
+ });
+
+ if (isGuestEmbed) {
+ return null;
+ }
+
+ const authSubType = getAuthSubTypeForSettings(settings);
+
+ const handleAuthSubTypeChange = (value: string) => {
+ const useExistingUserSession = value === "user-session";
+
+ updateSettings({ useExistingUserSession });
+ };
+
+ return (
+ <Card p="md">
+ <Stack gap="md">
+ <Text size="lg" fw="bold">
+ {
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- Public Facing string
+ t`Metabase account`
+ }
+ </Text>
+
+ <Radio.Group value={authSubType} onChange={handleAuthSubTypeChange}>
+ <Stack gap="sm">
+ <Radio
+ disabled={!isSsoEnabledAndConfigured}
+ value="sso"
+ label={t`Single sign-on`}
+ />
+
+ <Radio
+ value="user-session"
+ label={t`Existing session (local testing only)`}
+ />
+ </Stack>
+ </Radio.Group>
+
+ {!isSsoEnabledAndConfigured && !!settings.useExistingUserSession && (
+ <Alert
+ icon={
+ <Icon
+ name="warning_triangle_filled"
+ c="text-secondary"
+ size={16}
+ />
+ }
+ color="warning"
+ >
+ <Text size="md" lh="lg">
+ {jt`The code below will only work for local testing. To get production ready code, configure ${(
+ <Anchor
+ key="configure-sso"
+ href={setupSsoUrl}
+ target="_blank"
+ size="md"
+ lh="lg"
+ >
+ {t`JWT SSO or SAML`}
+ </Anchor>
+ )}.`}
+ </Text>
+ </Alert>
+ )}
+ </Stack>
+ </Card>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/ServerCodeCard.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/ServerCodeCard.tsx
new file mode 100644
index 00000000000..66da6d522d5
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/GetCodeStep/ServerCodeCard.tsx
@@ -0,0 +1,53 @@
+import { t } from "ttag";
+
+import { CodeEditor } from "metabase/common/components/CodeEditor";
+import { EmbedServerSnippetLanguageSelect } from "metabase/embedding/components/EmbedServerSnippetLanguageSelect/EmbedServerSnippetLanguageSelect";
+import { MoreServerSnippetExamplesLink } from "metabase/embedding/components/MoreServerSnippetExamplesLink/MoreServerSnippetExamplesLink";
+import { Card, Flex, Stack, Text } from "metabase/ui";
+
+import type { useSdkIframeEmbedServerSnippet } from "../../../hooks/use-sdk-iframe-embed-server-snippet";
+import { CopyCodeSnippetButton } from "../../GetCode/CopyCodeSnippetButton";
+
+type ServerSnippetData = NonNullable<
+ ReturnType<typeof useSdkIframeEmbedServerSnippet>
+>;
+
+interface ServerCodeCardProps {
+ serverSnippetData: ServerSnippetData;
+ onCopy: () => void;
+}
+
+export const ServerCodeCard = ({
+ serverSnippetData,
+ onCopy,
+}: ServerCodeCardProps) => (
+ <Card p="md">
+ <Flex align="baseline" justify="space-between">
+ <Text size="lg" fw="bold" mb="md">
+ {t`Server code`}
+ </Text>
+
+ <EmbedServerSnippetLanguageSelect
+ languageOptions={serverSnippetData.serverSnippetOptions}
+ selectedOptionId={serverSnippetData.selectedServerSnippetId}
+ onChangeOption={serverSnippetData.setSelectedServerSnippetId}
+ />
+ </Flex>
+
+ <Stack gap="sm">
+ <CodeEditor
+ language={serverSnippetData.serverSnippetOption.language}
+ value={serverSnippetData.serverSnippetOption.source}
+ readOnly
+ lineNumbers={false}
+ />
+
+ <CopyCodeSnippetButton
+ snippet={serverSnippetData.serverSnippetOption.source}
+ onCopy={onCopy}
+ />
+
+ <MoreServerSnippetExamplesLink />
+ </Stack>
+ </Card>
+);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ExperienceCard.tsx
similarity index 62%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ExperienceCard.tsx
index 1661914168e..2df87614212 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedExperienceStep.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ExperienceCard.tsx
@@ -3,17 +3,20 @@ import { t } from "ttag";
import { useMetabotEnabledEmbeddingAware } from "metabase/metabot/hooks";
import { Card, Flex, Radio, Stack, Text } from "metabase/ui";
-import { UPSELL_CAMPAIGN_EXPERIENCE } from "../analytics";
-import { getEmbedExperiences } from "../constants";
-import { useSdkIframeEmbedSetupContext } from "../context";
-import { useHandleExperienceChange } from "../hooks/use-handle-experience-change";
-import type { SdkIframeEmbedSetupExperience } from "../types";
+import { getEmbedExperiences } from "../../../constants";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { useHandleExperienceChange } from "../../../hooks/use-handle-experience-change";
+import type { SdkIframeEmbedSetupExperience } from "../../../types";
+import { hasAuthToSelect } from "../../../utils/has-auth-to-select";
+import { SetupSsoAlert } from "../../Common/SetupSsoAlert";
-import { EmbeddingUpsell } from "./Common/EmbeddingUpsell";
-
-export const SelectEmbedExperienceStep = () => {
- const { isSimpleEmbedFeatureAvailable, experience, settings } =
- useSdkIframeEmbedSetupContext();
+export const ExperienceCard = () => {
+ const {
+ isSimpleEmbedFeatureAvailable,
+ isSsoEnabledAndConfigured,
+ experience,
+ settings,
+ } = useSdkIframeEmbedSetupContext();
const isGuestEmbed = !!settings.isGuest;
const isMetabotAvailable = useMetabotEnabledEmbeddingAware({
@@ -26,10 +29,13 @@ export const SelectEmbedExperienceStep = () => {
isMetabotAvailable,
});
+ const showSsoNotConfiguredWarning =
+ !isSsoEnabledAndConfigured && !hasAuthToSelect(experience);
+
return (
- <>
- <Card p="md" mb="md">
- <Text size="lg" fw="bold" mb="md">
+ <Card p="md">
+ <Stack gap="md">
+ <Text size="lg" fw="bold">
{t`Select your embed experience`}
</Text>
@@ -60,9 +66,9 @@ export const SelectEmbedExperienceStep = () => {
))}
</Stack>
</Radio.Group>
- </Card>
- <EmbeddingUpsell campaign={UPSELL_CAMPAIGN_EXPERIENCE} />
- </>
+ {showSsoNotConfiguredWarning && <SetupSsoAlert />}
+ </Stack>
+ </Card>
);
};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ResourceCard.tsx
similarity index 56%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceStep.tsx
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ResourceCard.tsx
index 096e9b74ac3..057a757e139 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SelectEmbedResourceStep.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/ResourceCard.tsx
@@ -2,31 +2,37 @@ import { useDisclosure } from "@mantine/hooks";
import { match } from "ts-pattern";
import { t } from "ttag";
+import { skipToken, useGetCollectionQuery } from "metabase/api";
import {
CollectionPickerModal,
DashboardPickerModal,
QuestionPickerModal,
} from "metabase/common/components/Pickers";
-import { ActionIcon, Card, Group, Icon, Stack, Text } from "metabase/ui";
-import type { CollectionId } from "metabase-types/api";
+import { Button, Card, Icon, Stack, Text } from "metabase/ui";
+import type { CollectionId, IconName } from "metabase-types/api";
-import { STEPS_WITHOUT_RESOURCE_SELECTION } from "../constants";
-import { useSdkIframeEmbedSetupContext } from "../context";
+import { EXPERIENCES_WITHOUT_RESOURCE_SELECTION } from "../../../constants";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
import type {
SdkIframeEmbedSetupExperience,
SdkIframeEmbedSetupRecentItem,
SdkIframeEmbedSetupRecentItemType,
-} from "../types";
-import { getResourceIdFromSettings } from "../utils/get-default-sdk-iframe-embed-setting";
-
-import { SelectEmbedResourceMissingRecents } from "./SelectEmbedResourceMissingRecents";
-import { SelectEmbedResourceRecentItemCard } from "./SelectEmbedResourceRecentItemCard";
+} from "../../../types";
+import { getResourceIdFromSettings } from "../../../utils/get-default-sdk-iframe-embed-setting";
+
+// The picker uses the "recents" id to open on the Recent items tab while still
+// being able to resolve to a valid initial path.
+const PICKER_RECENTS_VALUE = {
+ id: "recents" as CollectionId,
+ model: "collection" as const,
+};
-export const SelectEmbedResourceStep = () => {
+export const ResourceCard = () => {
const {
experience,
settings,
updateSettings,
+ resource,
recentDashboards,
recentQuestions,
recentCollections,
@@ -36,7 +42,14 @@ export const SelectEmbedResourceStep = () => {
const [isPickerOpen, { open: openPicker, close: closePicker }] =
useDisclosure(false);
- // If a step does not allow resource selection, hide it.
+ const selectedItemId = getResourceIdFromSettings(settings);
+
+ const { data: selectedCollection } = useGetCollectionQuery(
+ experience === "browser" && selectedItemId != null
+ ? { id: selectedItemId as CollectionId }
+ : skipToken,
+ );
+
if (!hasResourceSelectionStep(experience)) {
return null;
}
@@ -47,7 +60,17 @@ export const SelectEmbedResourceStep = () => {
.with("chart", () => recentQuestions)
.exhaustive();
- const selectedItemId = getResourceIdFromSettings(settings);
+ const selectedResourceName = match(experience)
+ .with("dashboard", () => resource?.name)
+ .with("chart", () => resource?.name)
+ .with("browser", () => selectedCollection?.name)
+ .exhaustive();
+
+ const fallbackResourceName = recentItems.find(
+ (item) => item.id === selectedItemId,
+ )?.name;
+
+ const { title, icon, placeholder, label } = getResourceCopy(experience);
const updateEmbedSettings = (
experience: SdkIframeEmbedSetupExperience,
@@ -114,35 +137,6 @@ export const SelectEmbedResourceStep = () => {
});
};
- const renderSelectResourceList = () => {
- if (recentItems.length === 0) {
- return (
- <SelectEmbedResourceMissingRecents
- experience={experience}
- openPicker={openPicker}
- />
- );
- }
-
- return (
- <Stack gap="md">
- <Text c="text-secondary" mb="md">
- {getEmbedDescription(experience)}
- </Text>
-
- {recentItems.map((recentItem) => (
- <SelectEmbedResourceRecentItemCard
- key={recentItem.id}
- recentItem={recentItem}
- experience={experience}
- onSelect={updateEmbedSettings}
- selectedItemId={selectedItemId}
- />
- ))}
- </Stack>
- );
- };
-
const renderPickerModal = () => {
if (!isPickerOpen) {
return null;
@@ -152,11 +146,7 @@ export const SelectEmbedResourceStep = () => {
return (
<DashboardPickerModal
title={t`Select a dashboard`}
- value={
- selectedItemId
- ? { id: selectedItemId, model: "dashboard" }
- : undefined
- }
+ value={PICKER_RECENTS_VALUE}
onChange={handlePickerModalResourceSelect}
onClose={closePicker}
options={MODAL_OPTIONS}
@@ -168,9 +158,7 @@ export const SelectEmbedResourceStep = () => {
return (
<QuestionPickerModal
title={t`Select a chart`}
- value={
- selectedItemId ? { id: selectedItemId, model: "card" } : undefined
- }
+ value={PICKER_RECENTS_VALUE}
onChange={handlePickerModalResourceSelect}
onClose={closePicker}
options={MODAL_OPTIONS}
@@ -181,11 +169,8 @@ export const SelectEmbedResourceStep = () => {
if (experience === "browser") {
return (
<CollectionPickerModal
- title={t`Select a collection`}
- value={{
- id: selectedItemId ?? "root",
- model: "collection",
- }}
+ title={t`Select default collection`}
+ value={PICKER_RECENTS_VALUE}
onChange={handlePickerModalResourceSelect}
onClose={closePicker}
options={COLLECTION_MODAL_OPTIONS}
@@ -196,33 +181,29 @@ export const SelectEmbedResourceStep = () => {
return null;
};
- const browseResourceTitle = match(experience)
- .with("dashboard", () => t`Browse dashboards`)
- .with("browser", () => t`Browse collections`)
- .with("chart", () => t`Browse questions`)
- .exhaustive();
-
return (
<>
- <Card p="md" mb="md">
- <Group justify="space-between" mb="md">
+ <Card p="md">
+ <Stack gap="md">
<Text size="lg" fw="bold">
- {getEmbedTitle(experience)}
+ {title}
</Text>
- <ActionIcon
- size="lg"
- title={browseResourceTitle}
+ <Button
+ variant="default"
+ leftSection={<Icon name={icon} c="brand" size={16} />}
+ rightSection={<Icon name="chevrondown" size={12} />}
onClick={openPicker}
data-testid="embed-browse-entity-button"
- c="text-primary"
- bd="1px solid var(--mb-color-border)"
+ aria-label={label}
+ fullWidth
+ styles={{ label: { flex: 1, textAlign: "left" } }}
>
- <Icon name="search" size={16} />
- </ActionIcon>
- </Group>
-
- {renderSelectResourceList()}
+ <Text fw="bold">
+ {selectedResourceName ?? fallbackResourceName ?? placeholder}
+ </Text>
+ </Button>
+ </Stack>
</Card>
{renderPickerModal()}
@@ -230,21 +211,35 @@ export const SelectEmbedResourceStep = () => {
);
};
-const getEmbedTitle = (experience: string) =>
- match(experience)
- .with("dashboard", () => t`Select a dashboard to embed`)
- .with("chart", () => t`Select a chart to embed`)
- .with("browser", () => t`Select a collection to embed`)
- .with("exploration", () => t`Exploration embed setup`)
- .otherwise(() => t`Select content to embed`);
-
-const getEmbedDescription = (experience: string) =>
- match(experience)
- .with("dashboard", () => t`Choose from your recently visited dashboards`)
- .with("chart", () => t`Choose from your recently visited charts`)
- .with("browser", () => t`Choose a collection to start browsing from`)
- .with("exploration", () => null)
- .otherwise(() => t`Choose your content to embed`);
+type ResourceExperience = Exclude<
+ SdkIframeEmbedSetupExperience,
+ (typeof EXPERIENCES_WITHOUT_RESOURCE_SELECTION)[number]
+>;
+
+const getResourceCopy = (experience: ResourceExperience) =>
+ match<
+ ResourceExperience,
+ { title: string; icon: IconName; placeholder: string; label: string }
+ >(experience)
+ .with("dashboard", () => ({
+ title: t`Select a dashboard to embed`,
+ icon: "dashboard",
+ placeholder: t`Select a dashboard`,
+ label: t`Change dashboard`,
+ }))
+ .with("chart", () => ({
+ title: t`Select a chart to embed`,
+ icon: "bar",
+ placeholder: t`Select a chart`,
+ label: t`Change chart`,
+ }))
+ .with("browser", () => ({
+ title: t`Select initial collection`,
+ icon: "collection",
+ placeholder: t`Select initial collection`,
+ label: t`Change initial collection`,
+ }))
+ .exhaustive();
const MODAL_OPTIONS = {
showPersonalCollections: true,
@@ -262,8 +257,8 @@ const hasResourceSelectionStep = (
experience: SdkIframeEmbedSetupExperience,
): experience is Exclude<
SdkIframeEmbedSetupExperience,
- (typeof STEPS_WITHOUT_RESOURCE_SELECTION)[number]
+ (typeof EXPERIENCES_WITHOUT_RESOURCE_SELECTION)[number]
> =>
!(
- STEPS_WITHOUT_RESOURCE_SELECTION as SdkIframeEmbedSetupExperience[]
+ EXPERIENCES_WITHOUT_RESOURCE_SELECTION as SdkIframeEmbedSetupExperience[]
).includes(experience);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/SelectEmbedExperienceStep.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/SelectEmbedExperienceStep.tsx
new file mode 100644
index 00000000000..bfe88b3cdd4
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/steps/SelectEmbedExperienceStep/SelectEmbedExperienceStep.tsx
@@ -0,0 +1,49 @@
+import cx from "classnames";
+
+import CS from "metabase/css/core/index.css";
+import { Box, Stack } from "metabase/ui";
+
+import { UPSELL_CAMPAIGN_EXPERIENCE } from "../../../analytics";
+import { useSdkIframeEmbedSetupContext } from "../../../context";
+import { hasAuthToSelect } from "../../../utils/has-auth-to-select";
+import { hasResourceToSelect } from "../../../utils/has-resource-to-select";
+import { AuthenticationCard } from "../../AuthenticationCard";
+import { EmbeddingUpsell } from "../../Common/EmbeddingUpsell";
+
+import { ExperienceCard } from "./ExperienceCard";
+import { ResourceCard } from "./ResourceCard";
+
+export const SelectEmbedExperienceStep = () => {
+ const { allowPreviewAndNavigation, experience } =
+ useSdkIframeEmbedSetupContext();
+
+ const showAuth = hasAuthToSelect(experience);
+ const showResource = hasResourceToSelect(experience);
+
+ // Authentication is interactive even when preview/navigation is disabled
+ // (otherwise the user couldn't switch auth type or accept terms to unblock).
+ const dimmedProps = {
+ opacity: allowPreviewAndNavigation ? 1 : 0.5,
+ className: cx(!allowPreviewAndNavigation && CS.pointerEventsNone),
+ };
+
+ return (
+ <Stack gap="md">
+ <Box {...dimmedProps}>
+ <ExperienceCard />
+ </Box>
+
+ {showAuth && <AuthenticationCard />}
+
+ {showResource && (
+ <Box {...dimmedProps}>
+ <ResourceCard />
+ </Box>
+ )}
+
+ <Box {...dimmedProps}>
+ <EmbeddingUpsell campaign={UPSELL_CAMPAIGN_EXPERIENCE} />
+ </Box>
+ </Stack>
+ );
+};
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
index 05151015ae8..0835edcdaa8 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup-embedding-hub.unit.spec.tsx
@@ -39,7 +39,6 @@ describe("Embed flow > embedding hub step completion tracking", () => {
await userEvent.click(authRadio);
expect(authRadio).toBeChecked();
- await userEvent.click(screen.getByRole("button", { name: "Next" }));
await userEvent.click(screen.getByRole("button", { name: "Next" }));
await userEvent.click(screen.getByRole("button", { name: "Get code" }));
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
index d7a4ee4bbc6..6daf6c4d9dd 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/SdkIframeEmbedSetup.unit.spec.tsx
@@ -3,7 +3,6 @@ import userEvent from "@testing-library/user-event";
import {
setupCardEndpoints,
setupCardQueryMetadataEndpoint,
- setupDatabasesEndpoints,
} from "__support__/server-mocks";
import { screen, waitFor } from "__support__/ui";
import { PLUGIN_EMBEDDING_IFRAME_SDK_SETUP } from "metabase/plugins";
@@ -50,14 +49,17 @@ describe("Embed flow > forward and backward navigation", () => {
screen.getByText("Select your embed experience"),
).toBeInTheDocument();
- await userEvent.click(screen.getByRole("button", { name: "Next" }));
+ // The resource picker is part of the first step
expect(screen.getByText("Select a dashboard to embed")).toBeInTheDocument();
- expect(screen.getByRole("button", { name: "Back" })).toBeEnabled();
+ expect(
+ screen.getByTestId("embed-browse-entity-button"),
+ ).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: "Next" }));
expect(screen.getByText("Behavior")).toBeInTheDocument();
expect(screen.getByText("Appearance")).toBeInTheDocument();
+ expect(screen.getByRole("button", { name: "Back" })).toBeEnabled();
expect(
screen.getByRole("button", { name: "Get code" }),
).toBeInTheDocument();
@@ -75,39 +77,145 @@ describe("Embed flow > forward and backward navigation", () => {
it("navigates backward to the previous step", async () => {
setup({ simpleEmbeddingEnabled: true });
- // Select embed type > select resource > select embed options
- await userEvent.click(screen.getByRole("button", { name: "Next" }));
+ // First step (experience + resource) > select embed options
await userEvent.click(screen.getByRole("button", { name: "Next" }));
expect(screen.getByText("Behavior")).toBeInTheDocument();
expect(screen.getByText("Appearance")).toBeInTheDocument();
- // Back to select resource
- await userEvent.click(screen.getByRole("button", { name: "Back" }));
- expect(screen.getByText("Select a dashboard to embed")).toBeInTheDocument();
-
- // Back to select embed type
+ // Back to first step
await userEvent.click(screen.getByRole("button", { name: "Back" }));
expect(
screen.getByText("Select your embed experience"),
).toBeInTheDocument();
+ expect(screen.getByText("Select a dashboard to embed")).toBeInTheDocument();
expect(
screen.queryByRole("button", { name: "Back" }),
).not.toBeInTheDocument();
});
- it("skips the 'select resource' step for exploration", async () => {
+ it("hides the resource picker for exploration on the first step", async () => {
setup({ simpleEmbeddingEnabled: true });
await userEvent.click(screen.getByRole("radio", { name: /Exploration/ }));
- // Clicking next skips "select resource" and go directly to "select embed options"
+ // The resource picker is not shown for the exploration experience
+ expect(
+ screen.queryByText("Select a dashboard to embed"),
+ ).not.toBeInTheDocument();
+
+ // Clicking next goes directly to "select embed options"
await userEvent.click(screen.getByRole("button", { name: "Next" }));
expect(screen.getByText("Behavior")).toBeInTheDocument();
expect(screen.getByText("Appearance")).toBeInTheDocument();
+ });
+
+ it("hides the authentication and resource cards when Exploration is selected", async () => {
+ setup({ simpleEmbeddingEnabled: true });
+
+ expect(screen.getByText("Authentication")).toBeInTheDocument();
+ expect(screen.getByText("Select a dashboard to embed")).toBeInTheDocument();
+
+ await userEvent.click(screen.getByRole("radio", { name: /Exploration/ }));
+
+ expect(screen.queryByText("Authentication")).not.toBeInTheDocument();
+ expect(
+ screen.queryByText("Select a dashboard to embed"),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByText("Select initial collection"),
+ ).not.toBeInTheDocument();
+ });
+
+ it("hides the authentication card but keeps the resource card (as a collection picker) when Browser is selected", async () => {
+ setup({ simpleEmbeddingEnabled: true });
+
+ expect(screen.getByText("Authentication")).toBeInTheDocument();
+ expect(screen.getByText("Select a dashboard to embed")).toBeInTheDocument();
+
+ await userEvent.click(screen.getByRole("radio", { name: /Browser/ }));
+ expect(screen.queryByText("Authentication")).not.toBeInTheDocument();
expect(
screen.queryByText("Select a dashboard to embed"),
).not.toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: "Change initial collection" }),
+ ).toBeInTheDocument();
+ });
+
+ it("renders the SSO radio above the Guest radio in the authentication card", () => {
+ setup({ simpleEmbeddingEnabled: true });
+
+ const radios = screen.getAllByRole("radio");
+ const ssoIndex = radios.findIndex((r) => r.getAttribute("value") === "sso");
+ const guestIndex = radios.findIndex(
+ (r) => r.getAttribute("value") === "guest-embed",
+ );
+
+ expect(ssoIndex).toBeGreaterThanOrEqual(0);
+ expect(guestIndex).toBeGreaterThanOrEqual(0);
+ expect(ssoIndex).toBeLessThan(guestIndex);
+ });
+
+ it("selects Guest when initialState.isGuest is true, even with SSO configured", () => {
+ setup({
+ simpleEmbeddingEnabled: true,
+ jwtReady: true,
+ initialState: { isGuest: true, useExistingUserSession: true },
+ });
+
+ expect(screen.getByDisplayValue("guest-embed")).toBeChecked();
+ expect(screen.getByDisplayValue("sso")).not.toBeChecked();
+ });
+
+ describe("SSO not configured warnings", () => {
+ const warningText =
+ /This embed will only work for local testing\. To get production ready code, configure/;
+
+ it("shows a warning on the authentication card when SSO is selected but not configured", () => {
+ setup({ simpleEmbeddingEnabled: true, jwtReady: false });
+
+ expect(screen.getByDisplayValue("sso")).toBeChecked();
+ expect(screen.getByText("Authentication")).toBeInTheDocument();
+ expect(screen.getByText(warningText)).toBeInTheDocument();
+ });
+
+ it("hides the warning when Guest is selected", async () => {
+ setup({ simpleEmbeddingEnabled: true, jwtReady: false });
+
+ await userEvent.click(screen.getByRole("radio", { name: "Guest" }));
+
+ expect(screen.queryByText(warningText)).not.toBeInTheDocument();
+ });
+
+ it("hides the warning when SSO is configured", () => {
+ setup({ simpleEmbeddingEnabled: true, jwtReady: true });
+
+ expect(screen.queryByText(warningText)).not.toBeInTheDocument();
+ });
+
+ it.each(["Exploration", "Browser"])(
+ "shows a warning on the experience card when %s is selected and SSO is not configured",
+ async (experienceLabel) => {
+ setup({ simpleEmbeddingEnabled: true, jwtReady: false });
+
+ await userEvent.click(
+ screen.getByRole("radio", { name: new RegExp(experienceLabel) }),
+ );
+
+ expect(screen.getByText(warningText)).toBeInTheDocument();
+ // Authentication card is hidden so its warning is gone
+ expect(screen.queryByText("Authentication")).not.toBeInTheDocument();
+ },
+ );
+
+ it("hides the experience card warning when Exploration is selected and SSO is configured", async () => {
+ setup({ simpleEmbeddingEnabled: true, jwtReady: true });
+
+ await userEvent.click(screen.getByRole("radio", { name: /Exploration/ }));
+
+ expect(screen.queryByText(warningText)).not.toBeInTheDocument();
+ });
});
it("disables next and back buttons when simple embedding is disabled", () => {
@@ -123,7 +231,6 @@ describe("Embed flow > forward and backward navigation", () => {
const mockDatabase = createMockDatabase();
const mockCard = createMockCard({ id: 456 });
- setupDatabasesEndpoints([mockDatabase]);
setupCardEndpoints(mockCard);
setupCardQueryMetadataEndpoint(
mockCard,
@@ -155,7 +262,6 @@ describe("Embed flow > Pro feature upsell indicators", () => {
const mockDatabase = createMockDatabase();
const mockCard = createMockCard({ id: 456 });
- setupDatabasesEndpoints([mockDatabase]);
setupCardEndpoints(mockCard);
setupCardQueryMetadataEndpoint(
mockCard,
@@ -197,7 +303,6 @@ describe("Embed flow > Pro feature upsell indicators", () => {
const mockDatabase = createMockDatabase();
const mockCard = createMockCard({ id: 456 });
- setupDatabasesEndpoints([mockDatabase]);
setupCardEndpoints(mockCard);
setupCardQueryMetadataEndpoint(
mockCard,
@@ -238,8 +343,6 @@ describe("Embed flow > Pro feature upsell indicators", () => {
});
it("disables Pro checkboxes for OSS users (dashboard)", () => {
- setupDatabasesEndpoints([createMockDatabase()]);
-
setup({
simpleEmbeddingEnabled: false,
initialState: {
@@ -269,8 +372,7 @@ describe("Embed flow > Pro feature upsell indicators", () => {
hasEmailSetup: true,
});
- // Navigate to options step: Next (experience) → Next (resource)
- await userEvent.click(screen.getByRole("button", { name: "Next" }));
+ // Navigate to options step: Next (combined experience + resource step)
await userEvent.click(screen.getByRole("button", { name: "Next" }));
expect(
@@ -290,3 +392,34 @@ describe("Embed flow > Pro feature upsell indicators", () => {
PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => false;
});
});
+
+describe("Embed flow > Metabot", () => {
+ beforeEach(() => {
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = jest.fn(() => true);
+ });
+
+ afterEach(() => {
+ PLUGIN_EMBEDDING_IFRAME_SDK_SETUP.isEnabled = () => false;
+ });
+
+ it("toggles the save option for Metabot", async () => {
+ setup({
+ simpleEmbeddingEnabled: true,
+ metabotEnabled: true,
+ });
+
+ // Switch to Metabot experience
+ await userEvent.click(screen.getByRole("radio", { name: /Metabot/ }));
+ await userEvent.click(screen.getByRole("button", { name: "Next" }));
+
+ const saveCheckbox = await screen.findByRole("checkbox", {
+ name: "Allow people to save new questions",
+ });
+
+ expect(saveCheckbox).toBeEnabled();
+ expect(saveCheckbox).not.toBeChecked();
+
+ await userEvent.click(saveCheckbox);
+ expect(saveCheckbox).toBeChecked();
+ });
+});
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
index f0b8bbb9c3c..de55db721f8 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
@@ -3,8 +3,10 @@ import fetchMock from "fetch-mock";
import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
findRequests,
+ setupCollectionByIdEndpoint,
setupDashboardEndpoints,
setupDashboardQueryMetadataEndpoint,
+ setupDatabasesEndpoints,
setupNotificationChannelsEndpoints,
setupRecentViewsAndSelectionsEndpoints,
setupSearchEndpoints,
@@ -16,6 +18,7 @@ import { renderWithProviders, waitFor } from "__support__/ui";
import type { SdkIframeEmbedSetupModalInitialState } from "metabase/plugins";
import { createMockState } from "metabase/redux/store/mocks";
import {
+ createMockCollection,
createMockDashboard,
createMockDashboardQueryMetadata,
createMockDatabase,
@@ -32,6 +35,7 @@ export const setup = (options?: {
jwtReady?: boolean;
initialState?: SdkIframeEmbedSetupModalInitialState;
hasEmailSetup?: boolean;
+ metabotEnabled?: boolean;
}) => {
const { enterprisePlugins } = options ?? {};
@@ -56,10 +60,16 @@ export const setup = (options?: {
"jwt-enabled": options?.jwtReady ?? false,
"jwt-configured": options?.jwtReady ?? false,
"jwt-enabled-and-configured": options?.jwtReady ?? false,
+ "embedded-metabot-enabled?": options?.metabotEnabled ?? false,
+ "llm-metabot-configured?": options?.metabotEnabled ?? false,
});
setupRecentViewsAndSelectionsEndpoints([], ["selections", "views"]);
setupSearchEndpoints([]);
+ setupDatabasesEndpoints([mockDatabase]);
+ setupCollectionByIdEndpoint({
+ collections: [createMockCollection({ id: "root", name: "Our analytics" })],
+ });
setupDashboardEndpoints(mockDashboard);
setupDashboardQueryMetadataEndpoint(
mockDashboard,
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/constants.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/constants.ts
index 9d3ebd8b028..147ef237c56 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/constants.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/constants.ts
@@ -1,9 +1,8 @@
import { t } from "ttag";
-import { GetCodeStep } from "./components/GetCodeStep";
-import { SelectEmbedExperienceStep } from "./components/SelectEmbedExperienceStep";
-import { SelectEmbedOptionsStep } from "./components/SelectEmbedOptionsStep";
-import { SelectEmbedResourceStep } from "./components/SelectEmbedResourceStep";
+import { AppearanceStep } from "./components/steps/AppearanceStep/AppearanceStep";
+import { GetCodeStep } from "./components/steps/GetCodeStep/GetCodeStep";
+import { SelectEmbedExperienceStep } from "./components/steps/SelectEmbedExperienceStep/SelectEmbedExperienceStep";
import type {
SdkIframeEmbedSetupExperience,
SdkIframeEmbedSetupStep,
@@ -68,10 +67,9 @@ export const getEmbedExperiences = ({
type EmbedStepConfig = {
id: SdkIframeEmbedSetupStep;
component: React.ComponentType;
- skipFor?: SdkIframeEmbedSetupExperience[];
};
-export const STEPS_WITHOUT_RESOURCE_SELECTION = [
+export const EXPERIENCES_WITHOUT_RESOURCE_SELECTION = [
"exploration",
"metabot",
] as const satisfies SdkIframeEmbedSetupExperience[];
@@ -81,14 +79,9 @@ export const EMBED_STEPS: EmbedStepConfig[] = [
id: "select-embed-experience",
component: SelectEmbedExperienceStep,
},
- {
- id: "select-embed-resource",
- component: SelectEmbedResourceStep,
- skipFor: STEPS_WITHOUT_RESOURCE_SELECTION,
- },
{
id: "select-embed-options",
- component: SelectEmbedOptionsStep,
+ component: AppearanceStep,
},
{
id: "get-code",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-handle-experience-change.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-handle-experience-change.ts
index 0447b5908a9..6a67f821247 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-handle-experience-change.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-handle-experience-change.ts
@@ -10,8 +10,6 @@ import type { SdkIframeEmbedSetupExperience } from "metabase/embedding/embedding
import { determineDashboardId } from "metabase/embedding/embedding-iframe-sdk-setup/utils/determine-dashboard-id";
import { getDefaultSdkIframeEmbedSettings } from "metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting";
-export const DEFAULT_EXPERIENCE = "dashboard";
-
export const useHandleExperienceChange = () => {
const {
isSimpleEmbedFeatureAvailable,
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts
index 6c9f77d9ca6..8ee8c4de45d 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/hooks/use-sdk-iframe-embed-navigation.ts
@@ -1,4 +1,3 @@
-import { useMemo } from "react";
import { match } from "ts-pattern";
import type { SdkIframeEmbedSetupStep } from "metabase/embedding/embedding-iframe-sdk-setup/types";
@@ -8,7 +7,10 @@ import {
trackEmbedWizardOptionsCompleted,
trackEmbedWizardResourceSelectionCompleted,
} from "../analytics";
-import { EMBED_STEPS } from "../constants";
+import {
+ EMBED_STEPS,
+ EXPERIENCES_WITHOUT_RESOURCE_SELECTION,
+} from "../constants";
import type { SdkIframeEmbedSetupContextType } from "../context";
export function useSdkIframeEmbedNavigation({
@@ -40,17 +42,12 @@ export function useSdkIframeEmbedNavigation({
> & {
defaultStep: SdkIframeEmbedSetupStep;
}) {
- const availableSteps = useMemo(() => {
- // Exclude non-applicable steps for the current embed type
- return EMBED_STEPS.filter((step) => !step.skipFor?.includes(experience));
- }, [experience]);
-
const handleNext = () => {
- const currentIndex = availableSteps.findIndex(
+ const currentIndex = EMBED_STEPS.findIndex(
(step) => step.id === currentStep,
);
- const nextStep = availableSteps[currentIndex + 1];
+ const nextStep = EMBED_STEPS[currentIndex + 1];
match(currentStep)
.with("select-embed-experience", () => {
@@ -59,13 +56,18 @@ export function useSdkIframeEmbedNavigation({
defaultExperience: defaultSettings.experience,
settings,
});
- })
- .with("select-embed-resource", () => {
- trackEmbedWizardResourceSelectionCompleted({
- experience,
- currentSettings: settings,
- defaultResourceId: defaultSettings.resourceId,
- });
+
+ if (
+ !EXPERIENCES_WITHOUT_RESOURCE_SELECTION.includes(
+ experience as (typeof EXPERIENCES_WITHOUT_RESOURCE_SELECTION)[number],
+ )
+ ) {
+ trackEmbedWizardResourceSelectionCompleted({
+ experience,
+ currentSettings: settings,
+ defaultResourceId: defaultSettings.resourceId,
+ });
+ }
})
.with("select-embed-options", () => {
trackEmbedWizardOptionsCompleted({
@@ -86,29 +88,27 @@ export function useSdkIframeEmbedNavigation({
};
const handleBack = () => {
- const currentIndex = availableSteps.findIndex(
+ const currentIndex = EMBED_STEPS.findIndex(
(step) => step.id === currentStep,
);
- const prevStep = availableSteps[currentIndex - 1];
+ const prevStep = EMBED_STEPS[currentIndex - 1];
if (prevStep) {
setCurrentStep(prevStep.id);
}
};
- const currentIndex = availableSteps.findIndex(
- (step) => step.id === currentStep,
- );
+ const currentIndex = EMBED_STEPS.findIndex((step) => step.id === currentStep);
const isFirstStep = currentStep === defaultStep;
- const isLastStep = currentIndex === availableSteps.length - 1;
+ const isLastStep = currentIndex === EMBED_STEPS.length - 1;
const defaultStepIndex = EMBED_STEPS.findIndex(
({ id }) => id === defaultStep,
);
- const canGoNext = currentIndex < availableSteps.length - 1;
+ const canGoNext = currentIndex < EMBED_STEPS.length - 1;
const canGoBack = currentIndex > defaultStepIndex;
return {
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/types.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/types.ts
index f59e60080d6..6defa2d6058 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/types.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/types.ts
@@ -26,7 +26,6 @@ export type SdkIframeEmbedSetupExperience =
export type SdkIframeEmbedSetupStep =
| "select-embed-experience"
- | "select-embed-resource"
| "select-embed-options"
| "get-code";
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
index c043cea7cc7..ea85a84d4c7 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-common-embed-settings.ts
@@ -1,4 +1,4 @@
-import { isQuestionOrDashboardExperience } from "metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-experience";
+import { hasAuthToSelect } from "metabase/embedding/embedding-iframe-sdk-setup/utils/has-auth-to-select";
import { PLUGIN_EMBEDDING_IFRAME_SDK_SETUP } from "metabase/plugins";
import type {
@@ -17,16 +17,15 @@ const GET_ENABLE_GUEST_EMBED_SETTINGS: (data: {
isSimpleEmbedFeatureAvailable,
experience,
}) => {
- const isQuestionOrDashboardEmbed =
- isQuestionOrDashboardExperience(experience);
+ const needsAuthChoice = hasAuthToSelect(experience);
return {
- ...(isQuestionOrDashboardEmbed
+ ...(needsAuthChoice
? {
isGuest: true,
isSso: false,
useExistingUserSession: false,
- ...(isQuestionOrDashboardEmbed && {
+ ...(needsAuthChoice && {
drills: false,
// We force set `downloads` to `true` when the `simple embedding` feature is not enabled (OSS)
...(!isSimpleEmbedFeatureAvailable && {
@@ -53,11 +52,10 @@ const GET_DISABLE_GUEST_EMBED_SETTINGS: (data: {
SdkIframeDashboardEmbedSettings | SdkIframeQuestionEmbedSettings,
"lockedParameters"
> = ({ experience, isSsoEnabledAndConfigured, useExistingUserSession }) => {
- const isQuestionOrDashboardEmbed =
- isQuestionOrDashboardExperience(experience);
+ const needsAuthChoice = hasAuthToSelect(experience);
return {
- ...(isQuestionOrDashboardEmbed
+ ...(needsAuthChoice
? {
isGuest: false,
isSso: true,
@@ -71,7 +69,7 @@ const GET_DISABLE_GUEST_EMBED_SETTINGS: (data: {
useExistingUserSession:
!isSsoEnabledAndConfigured || useExistingUserSession,
}),
- ...(isQuestionOrDashboardEmbed && {
+ ...(needsAuthChoice && {
// Reset hiddenParameters when switching from guest to SSO.
// This is needed because when recentlyCreatedDashboards populates the
// dashboardId or questionId, the embed wizard starts in guest mode and
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
index 2fe22d56693..64a8cc90cc0 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.ts
@@ -87,6 +87,7 @@ export const getDefaultSdkIframeEmbedSettings = ({
"metabot",
(): MetabotEmbedOptions => ({
componentName: "metabase-metabot",
+ isSaveEnabled: false,
}),
)
.exhaustive();
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts
index 60074228e2d..1360c8bfea3 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/get-default-sdk-iframe-embed-setting.unit.spec.ts
@@ -59,7 +59,7 @@ describe("getDefaultSdkIframeEmbedSettings", () => {
{
experience: "metabot",
componentName: "metabase-metabot",
- expectedProps: {},
+ expectedProps: { isSaveEnabled: false },
},
])(
"$experience experience",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-experience.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-auth-to-select.ts
similarity index 50%
rename from frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-experience.ts
rename to frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-auth-to-select.ts
index a043febb032..b1781276519 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/is-question-or-dashboard-experience.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-auth-to-select.ts
@@ -1,6 +1,11 @@
import type { SdkIframeEmbedSetupExperience } from "metabase/embedding/embedding-iframe-sdk-setup/types";
-export const isQuestionOrDashboardExperience = (
+/**
+ * Whether the experience offers an auth choice (SSO vs Guest). True only for
+ * the experiences that support guest embedding — others are SSO-only and
+ * don't need the Authentication card.
+ */
+export const hasAuthToSelect = (
experience: SdkIframeEmbedSetupExperience,
): experience is "dashboard" | "chart" =>
["dashboard", "chart"].includes(experience);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-resource-to-select.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-resource-to-select.ts
new file mode 100644
index 00000000000..788fe58a9b5
--- /dev/null
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/has-resource-to-select.ts
@@ -0,0 +1,11 @@
+import type { SdkIframeEmbedSetupExperience } from "metabase/embedding/embedding-iframe-sdk-setup/types";
+
+/**
+ * Whether the experience needs a specific resource picked by the user
+ * (dashboard, chart, or initial collection for the browser). Exploration and
+ * Metabot have nothing to select.
+ */
+export const hasResourceToSelect = (
+ experience: SdkIframeEmbedSetupExperience,
+): experience is "dashboard" | "chart" | "browser" =>
+ ["dashboard", "chart", "browser"].includes(experience);