The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Show toggle for enabling saves for question embeds in embed flow (#63908)
Phoomparin Mano137bc61a426a
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.tsindex 696ebc2375d..cf5e83fb254 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@@ -287,39 +287,55 @@ H.describeWithSnowplow(suiteTitle, () => {);});- it("toggles save button for exploration", () => {- navigateToEmbedOptionsStep({ experience: "exploration" });-- H.getSimpleEmbedIframeContent().within(() => {- cy.findByText("Orders").click();- cy.findByText("Visualize").click();- });-- getEmbedSidebar()- .findByLabelText("Allow users to save new questions")- .should("not.be.checked");-- cy.log("save button should be hidden by default");- H.getSimpleEmbedIframeContent().findByText("Save").should("not.exist");+ ["exploration", "chart"].forEach((experience) => {+ it(`toggles save button for ${experience}`, () => {+ navigateToEmbedOptionsStep({+ experience,+ ...(experience === "chart" && { resourceName: QUESTION_NAME }),+ });++ if (experience === "exploration") {+ cy.log("visualize a question to enable the save button");+ H.getSimpleEmbedIframeContent().within(() => {+ cy.findByText("Orders").click();+ cy.findByText("Visualize").click();+ });+ }++ getEmbedSidebar()+ .findByLabelText("Allow people to save new questions")+ .should("not.be.checked");++ cy.log("save button should be hidden by default");+ H.getSimpleEmbedIframeContent().findByText("Save").should("not.exist");++ cy.log("turn on save option");+ getEmbedSidebar()+ .findByLabelText("Allow people to save new questions")+ .click()+ .should("be.checked");++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_option_changed",+ event_detail: "isSaveEnabled",+ });- cy.log("turn on save option");- getEmbedSidebar()- .findByLabelText("Allow users to save new questions")- .click()- .should("be.checked");+ if (experience === "chart") {+ cy.log("select a different visualization to enable the save button");+ H.getSimpleEmbedIframeContent().within(() => {+ cy.findByText("Table").click();+ H.popover().findByText("Number").click();+ });+ }- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "isSaveEnabled",- });+ H.getSimpleEmbedIframeContent().within(() => {+ cy.findByText("Save").should("be.visible");+ });- H.getSimpleEmbedIframeContent().within(() => {- cy.findByText("Save").should("be.visible");+ cy.log("snippet should be updated");+ getEmbedSidebar().findByText("Get Code").click();+ codeBlock().should("contain", 'is-save-enabled="true"');});-- cy.log("snippet should be updated");- getEmbedSidebar().findByText("Get Code").click();- codeBlock().should("contain", 'is-save-enabled="true"');});it("can toggle read-only setting for browser", () => {diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedOptionsStep.tsx b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedOptionsStep.tsxindex 62d5a236eed..716acb3cb06 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedOptionsStep.tsx+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedOptionsStep.tsx@@ -19,8 +19,8 @@ export const SelectEmbedOptionsStep = () => {(experience === "dashboard" && settings.dashboardId) ||(experience === "chart" && settings.questionId);- const isExplorationEmbed = settings.template === "exploration";- const isBrowserEmbed = settings.componentName === "metabase-browser";+ const isBrowserComponent = settings.componentName === "metabase-browser";+ const isQuestionComponent = settings.componentName === "metabase-question";const updateColors = useCallback((nextColors: Partial<MetabaseColors>) => {@@ -58,9 +58,9 @@ export const SelectEmbedOptionsStep = () => {/>)}- {isExplorationEmbed && (+ {isQuestionComponent && (<Checkbox- label={t`Allow users to save new questions`}+ label={t`Allow people to save new questions`}checked={settings.isSaveEnabled}onChange={(e) =>updateSettings({ isSaveEnabled: e.target.checked })@@ -68,7 +68,7 @@ export const SelectEmbedOptionsStep = () => {/>)}- {isBrowserEmbed && (+ {isBrowserComponent && (<Checkboxlabel={t`Allow editing dashboards and questions`}checked={!settings.readOnly}