Skip to content

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

feat(sdk): native questions should hide filter and summarize from toolbar (#63082)

Phoomparin Mano1280bb454dfb
diff --git a/e2e/test-component/scenarios/embedding-sdk/sdk-question-native.cy.spec.tsx b/e2e/test-component/scenarios/embedding-sdk/sdk-question-native.cy.spec.tsx
index 70b56b74249..9f7fd213927 100644
--- a/e2e/test-component/scenarios/embedding-sdk/sdk-question-native.cy.spec.tsx
+++ b/e2e/test-component/scenarios/embedding-sdk/sdk-question-native.cy.spec.tsx
@@ -115,4 +115,22 @@ describe("scenarios > embedding-sdk > interactive-question > native", () => {
});
});
});
+
+ it("should not show filter/summarize/breakout buttons for native questions", () => {
+ mountInteractiveQuestion({});
+
+ getSdkRoot().within(() => {
+ cy.log("should show native question data");
+ cy.findByText("test question").should("be.visible");
+
+ cy.log("should not show Filter button");
+ cy.findByText("Filter").should("not.exist");
+
+ cy.log("should not show Summarize button");
+ cy.findByText("Summarize").should("not.exist");
+
+ cy.log("should not show Group button");
+ cy.findByText("Group").should("not.exist");
+ });
+ });
});
diff --git a/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkQuestionDefaultView/SdkQuestionDefaultView.tsx b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkQuestionDefaultView/SdkQuestionDefaultView.tsx
index 987f7bc6355..a6718913156 100644
--- a/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkQuestionDefaultView/SdkQuestionDefaultView.tsx
+++ b/enterprise/frontend/src/embedding-sdk-bundle/components/private/SdkQuestionDefaultView/SdkQuestionDefaultView.tsx
@@ -1,7 +1,7 @@
import { useDisclosure } from "@mantine/hooks";
import cx from "classnames";
import type { ReactElement } from "react";
-import { useEffect } from "react";
+import { useEffect, useMemo } from "react";
import { t } from "ttag";
import {
@@ -23,6 +23,7 @@ import {
PopoverBackButton,
Stack,
} from "metabase/ui";
+import * as Lib from "metabase-lib";
import {
FlexibleSizeComponent,
@@ -98,6 +99,16 @@ export const SdkQuestionDefaultView = ({
const [isSaveModalOpen, { open: openSaveModal, close: closeSaveModal }] =
useDisclosure(false);
+ const isNativeQuestion = useMemo(() => {
+ if (!question) {
+ return false;
+ }
+
+ const { isNative } = Lib.queryDisplayInfo(question.query());
+
+ return isNative;
+ }, [question]);
+
useEffect(() => {
if (isNewQuestion && !isQuestionSaved) {
// When switching to new question, open the notebook editor
@@ -205,17 +216,25 @@ export const SdkQuestionDefaultView = ({
<ChartTypeDropdown />
<QuestionSettingsDropdown />
</Button.Group>
- <Divider
- mx="xs"
- orientation="vertical"
- // we have to do this for now because Mantine's divider overrides this color no matter what
- color="var(--mb-color-border) !important"
- />
+
+ {!isNativeQuestion && (
+ <Divider
+ mx="xs"
+ orientation="vertical"
+ // we have to do this for now because Mantine's divider overrides this color no matter what
+ color="var(--mb-color-border) !important"
+ />
+ )}
+ </>
+ )}
+
+ {!isNativeQuestion && (
+ <>
+ <FilterDropdown />
+ <SummarizeDropdown />
+ <BreakoutDropdown />
</>
)}
- <FilterDropdown />
- <SummarizeDropdown />
- <BreakoutDropdown />
</>
)}
</Group>