The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Hide Guest embedding status bar when guest embedding is disabled (#68836)
Timofey Kachalov0559e0beee97
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.tsindex 2999428b221..ef03f2b208a 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@@ -1,4 +1,8 @@-import { embedModalEnableEmbeddingCard } from "e2e/support/helpers";+import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";+import {+ embedModalEnableEmbeddingCard,+ openSharingMenu,+} from "e2e/support/helpers";import { getEmbedSidebar } from "./helpers";@@ -27,142 +31,162 @@ const DATA_BY_EMBEDDING_TYPE = {},} as const;-Object.entries(DATA_BY_EMBEDDING_TYPE).forEach(([key, value]) => {- describe(`scenarios > embedding > sdk iframe embed setup > enable embed js (EE) > ${key}`, () => {- const {- path,- token,- authMethodLabel,- embeddingSettingName,- showTermsSettingName,- cardTestId,- cardText,- } = value;-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- if (token) {- H.activateToken(token);- }-- H.mockEmbedJsToDevServer();- });+describe("scenarios > embedding > sdk iframe embed setup > enable embed js (EE)", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();++ H.mockEmbedJsToDevServer();+ });++ Object.entries(DATA_BY_EMBEDDING_TYPE).forEach(([key, value]) => {+ describe(key, () => {+ const {+ path,+ token,+ authMethodLabel,+ embeddingSettingName,+ showTermsSettingName,+ cardTestId,+ cardText,+ } = value;++ beforeEach(() => {+ if (token) {+ H.activateToken(token);+ }+ });++ it("shows the Enable to Continue button and enables embedding on click", () => {+ H.updateSetting(embeddingSettingName, false);+ H.updateSetting(showTermsSettingName, true);- it("shows the Enable to Continue button and enables embedding on click", () => {- H.updateSetting(embeddingSettingName, false);- H.updateSetting(showTermsSettingName, true);+ cy.visit(path);- cy.visit(path);+ cy.findAllByTestId(cardTestId)+ .first()+ .within(() => {+ cy.findByText("New embed").click();+ });- cy.findAllByTestId(cardTestId)- .first()- .within(() => {- cy.findByText("New embed").click();+ cy.findByLabelText(authMethodLabel).click();++ embedModalEnableEmbeddingCard().within(() => {+ cy.findByText(cardText).should("exist");});- cy.findByLabelText(authMethodLabel).click();+ cy.log("shows tooltip with fair usage info");+ embedModalEnableEmbeddingCard()+ .findByLabelText("info icon")+ .trigger("mouseover");- embedModalEnableEmbeddingCard().within(() => {- cy.findByText(cardText).should("exist");- });+ H.hovercard()+ .contains(+ /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/,+ )+ .should("be.visible");- cy.log("shows tooltip with fair usage info");- embedModalEnableEmbeddingCard()- .findByLabelText("info icon")- .trigger("mouseover");-- H.hovercard()- .contains(- /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/,- )- .should("be.visible");-- embedModalEnableEmbeddingCard()- .findByLabelText("info icon")- .trigger("mouseout");-- cy.findByRole("button", { name: "Agree and enable" }).should(- "be.visible",- );-- cy.log("preview panel should show placeholder");- cy.get('[alt="No results"]').should("be.visible");-- cy.findByRole("button", { name: "Agree and enable" }).click();-- cy.log("button should change to Enabled state");- cy.findByRole("button", { name: /Enabled/ })- .should("be.visible")- .should("be.disabled");-- // Going to the next step and selecting "Orders in a dashboard" explicitely- // 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")- .click();-- cy.log("Preview should load after embedding is enabled");- H.waitForSimpleEmbedIframesToLoad();- H.getSimpleEmbedIframeContent().within(() => {- cy.findByText("Orders in a dashboard", { timeout: 60_000 }).should(+ embedModalEnableEmbeddingCard()+ .findByLabelText("info icon")+ .trigger("mouseout");++ cy.findByRole("button", { name: "Agree and enable" }).should("be.visible",);- });- });- it("shows the enable card with fair usage terms when embedding is already enabled", () => {- H.updateSetting(embeddingSettingName, true);- H.updateSetting(showTermsSettingName, true);+ cy.log("preview panel should show placeholder");+ cy.get('[alt="No results"]').should("be.visible");++ cy.findByRole("button", { name: "Agree and enable" }).click();- cy.visit(path);+ cy.log("button should change to Enabled state");+ cy.findByRole("button", { name: /Enabled/ })+ .should("be.visible")+ .should("be.disabled");- cy.findAllByTestId(cardTestId)- .first()- .within(() => {- cy.findByText("New embed").click();+ // Going to the next step and selecting "Orders in a dashboard" explicitely+ // 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")+ .click();++ cy.log("Preview should load after embedding is enabled");+ H.waitForSimpleEmbedIframesToLoad();+ H.getSimpleEmbedIframeContent().within(() => {+ cy.findByText("Orders in a dashboard", { timeout: 60_000 }).should(+ "be.visible",+ );});+ });- cy.findByLabelText(authMethodLabel).click();+ it("shows the enable card with fair usage terms when embedding is already enabled", () => {+ H.updateSetting(embeddingSettingName, true);+ H.updateSetting(showTermsSettingName, true);- embedModalEnableEmbeddingCard().within(() => {- cy.findByText("Agree to the usage conditions to continue.").should(- "exist",- );+ cy.visit(path);- cy.findByText(cardText).should("not.exist");+ cy.findAllByTestId(cardTestId)+ .first()+ .within(() => {+ cy.findByText("New embed").click();+ });++ cy.findByLabelText(authMethodLabel).click();++ embedModalEnableEmbeddingCard().within(() => {+ cy.findByText("Agree to the usage conditions to continue.").should(+ "exist",+ );++ cy.findByText(cardText).should("not.exist");+ });++ cy.log("shows tooltip with fair usage info");+ getEmbedSidebar().findByLabelText("info icon").trigger("mouseover");++ H.hovercard()+ .contains(+ /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/,+ )+ .should("be.visible");});- cy.log("shows tooltip with fair usage info");- getEmbedSidebar().findByLabelText("info icon").trigger("mouseover");+ it("hides the enable card when embedding is already enabled", () => {+ H.updateSetting(embeddingSettingName, true);+ H.updateSetting(showTermsSettingName, false);++ cy.visit(path);- H.hovercard()- .contains(- /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/,- )- .should("be.visible");+ cy.findAllByTestId(cardTestId)+ .first()+ .within(() => {+ cy.findByText("New embed").click();+ });++ cy.findByLabelText(authMethodLabel).click();++ getEmbedSidebar().contains(cardText).should("not.exist");+ });});+ });- it("hides the enable card when embedding is already enabled", () => {- H.updateSetting(embeddingSettingName, true);- H.updateSetting(showTermsSettingName, false);+ it("shows guest embed status bar when guest embedding is toggled from disabled to enabled state", () => {+ H.updateSetting("enable-embedding-static", false);- cy.visit(path);+ H.visitDashboard(ORDERS_DASHBOARD_ID);- cy.findAllByTestId(cardTestId)- .first()- .within(() => {- cy.findByText("New embed").click();- });+ openSharingMenu("Embed");- cy.findByLabelText(authMethodLabel).click();+ cy.findByTestId("embed-modal-content-status-bar").should("not.exist");- getEmbedSidebar().contains(cardText).should("not.exist");- });+ cy.findByRole("button", { name: "Agree and enable" }).click();++ cy.findByTestId("embed-modal-content-status-bar").should("exist");});});diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeGuestEmbedStatusBar.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeGuestEmbedStatusBar.tsxindex beafa288ccf..81f9f0c1300 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeGuestEmbedStatusBar.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/SdkIframeGuestEmbedStatusBar.tsx@@ -13,6 +13,7 @@ export const SdkIframeGuestEmbedStatusBar = () => {embeddingParameters,isFetching,initialEmbeddingParameters,+ isGuestEmbedsEnabled,} = useSdkIframeEmbedSetupContext();const toggleEmbedding = useToggleResourceEmbedding();@@ -23,7 +24,12 @@ export const SdkIframeGuestEmbedStatusBar = () => {toggleEmbedding?.resourceType === "dashboard" ||toggleEmbedding?.resourceType === "question";- if (!isGuestEmbed || !shouldShowForStep || !shouldShowForResource) {+ if (+ !isGuestEmbed ||+ !isGuestEmbedsEnabled ||+ !shouldShowForStep ||+ !shouldShowForResource+ ) {return null;}diff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/EmbedModalContentStatusBar.tsx b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/EmbedModalContentStatusBar.tsxindex 916e40b8108..9e870b8fe6a 100644--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/EmbedModalContentStatusBar.tsx+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/EmbedModalContentStatusBar.tsx@@ -34,6 +34,7 @@ export const EmbedModalContentStatusBar = ({direction="row"align="center"gap="0.5rem"+ data-testid="embed-modal-content-status-bar"><Text>{!isPublisheddiff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsxindex 040b4f073e5..76f645a48cc 100644--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/StaticEmbedSetupPane.tsx@@ -209,13 +209,7 @@ export const StaticEmbedSetupPane = ({return (<Stack gap={0}>- <Paper- withBorder- shadow="sm"- m="1.5rem 2rem"- p="0.75rem 1rem"- data-testid="embed-modal-content-status-bar"- >+ <Paper withBorder shadow="sm" m="1.5rem 2rem" p="0.75rem 1rem"><EmbedModalContentStatusBarresourceType={resourceType}isPublished={resource.enable_embedding}