Skip to content

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

Fix LegacyStaticEmbeddingAlert trigger when it is visible (#66812)

Timofey Kachalov551ed1694b5e
diff --git a/e2e/test/scenarios/sharing/public-sharing-embed-button-behavior.cy.spec.js b/e2e/test/scenarios/sharing/public-sharing-embed-button-behavior.cy.spec.js
index 7e01c5a5619..cff7f20288b 100644
--- a/e2e/test/scenarios/sharing/public-sharing-embed-button-behavior.cy.spec.js
+++ b/e2e/test/scenarios/sharing/public-sharing-embed-button-behavior.cy.spec.js
@@ -1,3 +1,9 @@
+import {
+ embedModalContent,
+ legacyStaticEmbeddingButton,
+ openSharingMenu,
+} from "e2e/support/helpers";
+
const { H } = cy;
["dashboard", "question"].forEach((resource) => {
@@ -255,6 +261,33 @@ describe("#39152 sharing an unsaved question", () => {
});
});
+ [
+ { embeddingType: "guest-embed", shouldShowAlert: false },
+ { embeddingType: "static-legacy", shouldShowAlert: true },
+ { embeddingType: null, shouldShowAlert: true },
+ ].forEach(({ embeddingType, shouldShowAlert }) => {
+ it(`should ${shouldShowAlert ? "show" : "not show"} legacy alert for ${embeddingType} embedding type`, () => {
+ cy.get("@resourceId").then((id) => {
+ visitResource(resource, id);
+
+ const apiPath = resource === "question" ? "card" : "dashboard";
+
+ cy.request("PUT", `/api/${apiPath}/${id}`, {
+ enable_embedding: true,
+ embedding_type: embeddingType,
+ });
+
+ openSharingMenu("Embed");
+
+ embedModalContent().should("exist");
+
+ legacyStaticEmbeddingButton().should(
+ shouldShowAlert ? "exist" : "not.exist",
+ );
+ });
+ });
+ });
+
it("should set a proper embedding_type", () => {
cy.get("@resourceId").then((id) => {
visitResource(resource, id);
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/LegacyStaticEmbeddingAlert.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/LegacyStaticEmbeddingAlert.tsx
index 70894b96eb0..066037f795c 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/LegacyStaticEmbeddingAlert.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/LegacyStaticEmbeddingAlert.tsx
@@ -32,7 +32,7 @@ export const LegacyStaticEmbeddingAlert = () => {
}
const shouldShowLegacyStaticEmbeddingAlert =
- resource.enable_embedding && resource.embedding_type === "static-legacy";
+ resource.enable_embedding && resource.embedding_type !== "guest-embed";
if (!shouldShowLegacyStaticEmbeddingAlert) {
return null;