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 dashboard questions in CollectionBrowser by default (#77941)
Sébastien95267311e529
diff --git a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.schema.ts b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.schema.tsindex f4f3542c6f5..121f5c49134 100644--- a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.schema.ts+++ b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.schema.ts@@ -10,6 +10,7 @@ const propsSchema: Yup.SchemaOf<CollectionBrowserProps> = Yup.object({collectionId: Yup.mixed().optional(),onClick: Yup.mixed().optional(),pageSize: Yup.mixed().optional(),+ showDashboardQuestions: Yup.mixed().optional(),style: Yup.mixed().optional(),visibleColumns: Yup.mixed().optional(),visibleEntityTypes: Yup.mixed().optional(),diff --git a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsxindex 6e487c55dde..6d0f7730658 100644--- a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx+++ b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.tsx@@ -81,6 +81,11 @@ export type CollectionBrowserProps = {*/visibleEntityTypes?: UserFacingEntityName[];+ /**+ * Whether to show questions that belong to a dashboard alongside collection saved questions. Set to false to hide them and keep the list focused on collection content, matching the core Metabase app. Defaults to true.+ */+ showDashboardQuestions?: boolean;+/*** The columns to display in the collection items table. If not provided, all columns will be shown.*/@@ -102,6 +107,7 @@ export const CollectionBrowserInner = ({onClick,pageSize = COLLECTION_PAGE_SIZE,visibleEntityTypes = [...USER_FACING_ENTITY_NAMES],+ showDashboardQuestions = true,EmptyContentComponent = null,visibleColumns = COLLECTION_BROWSER_LIST_COLUMNS,className,@@ -189,6 +195,7 @@ export const CollectionBrowserInner = ({onClick={onClickItem}pageSize={pageSize}models={collectionTypes}+ showDashboardQuestions={showDashboardQuestions}visibleColumns={visibleColumns}EmptyContentComponent={EmptyContentComponent ?? undefined}/>diff --git a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsxindex 26981e09c01..b1fb1280862 100644--- a/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx+++ b/frontend/src/embedding-sdk-bundle/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx@@ -155,6 +155,18 @@ describe("CollectionBrowser", () => {expect(columnTexts).toContain("Description");});+ it("should show dashboard questions by default", async () => {+ await setup();++ expect(getLastItemsRequestParam("show_dashboard_questions")).toBe("true");+ });++ it("should hide dashboard questions when showDashboardQuestions is false", async () => {+ await setup({ props: { showDashboardQuestions: false } });++ expect(getLastItemsRequestParam("show_dashboard_questions")).toBe("false");+ });+it("should resolve collectionId=tenant to user's tenant collection", async () => {const tenantCollection = createMockCollection({id: 999,@@ -186,6 +198,12 @@ describe("CollectionBrowser", () => {});});+function getLastItemsRequestParam(param: string): string | null {+ const calls = fetchMock.callHistory.calls("path:/api/collection/root/items");+ const lastCall = calls[calls.length - 1];+ return new URL(lastCall.url).searchParams.get(param);+}+async function setup({props,collections = TEST_COLLECTIONS,diff --git a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsxindex 0bb5bf65b4e..98190a9c9ac 100644--- a/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx+++ b/frontend/src/metabase/collections/components/CollectionContent/CollectionItemsTable.tsx@@ -76,6 +76,7 @@ export type CollectionItemsTableProps = {loadingPinnedItems: boolean;models: CollectionItemModel[];pageSize: number;+ showDashboardQuestions: boolean;selected: CollectionItem[];selectOnlyTheseItems: (items: CollectionItem[]) => void;toggleItem: (item: CollectionItem) => void;@@ -111,6 +112,7 @@ export const CollectionItemsTable = ({loadingPinnedItems,models = ALL_MODELS,pageSize = COLLECTION_PAGE_SIZE,+ showDashboardQuestions = true,selected,selectOnlyTheseItems,toggleItem,@@ -167,7 +169,7 @@ export const CollectionItemsTable = ({limit: pageSize,offset: pageSize * page,...(showAllItems- ? { show_dashboard_questions: true }+ ? { show_dashboard_questions: showDashboardQuestions }: { pinned_state: "is_not_pinned" }),...unpinnedItemsSorting,}}diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/MetabaseBrowser.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/MetabaseBrowser.tsxindex 675ec454324..c49ee11d605 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/MetabaseBrowser.tsx+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/MetabaseBrowser.tsx@@ -166,6 +166,7 @@ export function MetabaseBrowser({ settings }: MetabaseBrowserProps) {collectionId={view.id}visibleColumns={settings.collectionVisibleColumns}visibleEntityTypes={settings.collectionEntityTypes}+ showDashboardQuestions={settings.collectionShowDashboardQuestions}pageSize={settings.collectionPageSize}onClick={(item) => {const type = match<string, SdkBreadcrumbItemType>(item.model)diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.tsindex 3c02024f460..1cd3906f2bd 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/constants.ts@@ -69,6 +69,7 @@ export const ALLOWED_EMBED_SETTING_KEYS_MAP = {"collectionVisibleColumns","collectionEntityTypes","collectionPageSize",+ "collectionShowDashboardQuestions","dataPickerEntityTypes","withNewQuestion","withNewDashboard",diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.tsindex edb3945f7ff..83e75084b15 100644--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts@@ -188,6 +188,9 @@ export interface BrowserEmbedOptions {/** Which entities to show on the collection browser */collectionEntityTypes?: CollectionBrowserEntityTypes[];+ /** Whether to show questions that belong to a dashboard in the collection browser. Defaults to true. */+ collectionShowDashboardQuestions?: boolean;+/** Which entities to show on the question's data picker */dataPickerEntityTypes?: EmbeddingEntityType[];