Skip to content

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

add ability to hide Our analytics in MiniPicker and hide it in the table picker in the embedding setup (#70920)

Nicolò Prettoa49e97237f70
diff --git a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
index 32cd6c1caac..235e22496fb 100644
--- a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts
@@ -898,6 +898,9 @@ describe("scenarios - embedding hub", () => {
cy.log("pick first table and column");
H.main().findByText("Pick a table").click();
+ cy.log("Our analytics should be hidden in the table picker");
+ H.miniPicker().findByText("Our analytics").should("not.exist");
+
H.miniPicker().findByText("Sample Database").click();
H.miniPicker().findByText("Orders").click();
diff --git a/frontend/src/metabase/common/components/Pickers/MiniPicker/components/MiniPickerItemList.tsx b/frontend/src/metabase/common/components/Pickers/MiniPicker/components/MiniPickerItemList.tsx
index ae12e25ba82..7e0b3ac0356 100644
--- a/frontend/src/metabase/common/components/Pickers/MiniPicker/components/MiniPickerItemList.tsx
+++ b/frontend/src/metabase/common/components/Pickers/MiniPicker/components/MiniPickerItemList.tsx
@@ -36,6 +36,7 @@ import type {
MiniPickerSchemaItem,
MiniPickerTableItem,
} from "../types";
+import { getOurAnalytics } from "../utils";
import { MiniPickerItem } from "./MiniPickerItem";
import styles from "./MiniPickerItem.module.css";
@@ -132,20 +133,22 @@ function RootItemList() {
}}
/>
)) ?? <MiniPickerListLoader />}
- <MiniPickerItem
- name={rootCollectionError ? t`Collections` : t`Our analytics`}
- model="collection"
- isFolder
- onClick={() => {
- setPath([
- {
- model: "collection",
- id: "root" as any, // cmon typescript, trust me
- name: rootCollectionError ? t`Collections` : t`Our analytics`,
- },
- ]);
- }}
- />
+ {!isHidden(getOurAnalytics()) && (
+ <MiniPickerItem
+ name={rootCollectionError ? t`Collections` : t`Our analytics`}
+ model="collection"
+ isFolder
+ onClick={() => {
+ setPath([
+ {
+ model: "collection",
+ id: "root" as any, // cmon typescript, trust me
+ name: rootCollectionError ? t`Collections` : t`Our analytics`,
+ },
+ ]);
+ }}
+ />
+ )}
</ItemList>
);
}
diff --git a/frontend/src/metabase/common/components/Pickers/MiniPicker/utils.ts b/frontend/src/metabase/common/components/Pickers/MiniPicker/utils.ts
index bfe8def0133..6d24607b36b 100644
--- a/frontend/src/metabase/common/components/Pickers/MiniPicker/utils.ts
+++ b/frontend/src/metabase/common/components/Pickers/MiniPicker/utils.ts
@@ -22,8 +22,18 @@ export const getOurAnalytics = (): MiniPickerFolderItem => ({
model: "collection",
id: "root" as any, // cmon typescript
name: t`Our analytics`,
- here: ["card"],
- below: ["card"],
+ here: ["collection"],
+ below: [
+ "collection",
+ "dashboard",
+ "document",
+ "card",
+ "dataset",
+ "metric",
+ "table",
+ "snippet",
+ "transform",
+ ],
});
export function useGetPathFromValue({
diff --git a/frontend/src/metabase/embedding/embedding-hub/components/SetupPermissionsAndTenantsPage/RlsDataSelector/TableColumnCard.tsx b/frontend/src/metabase/embedding/embedding-hub/components/SetupPermissionsAndTenantsPage/RlsDataSelector/TableColumnCard.tsx
index 5d18533f3d8..daea56a6979 100644
--- a/frontend/src/metabase/embedding/embedding-hub/components/SetupPermissionsAndTenantsPage/RlsDataSelector/TableColumnCard.tsx
+++ b/frontend/src/metabase/embedding/embedding-hub/components/SetupPermissionsAndTenantsPage/RlsDataSelector/TableColumnCard.tsx
@@ -106,10 +106,16 @@ export const TableColumnCard = ({
? { model: "table" as const, id: selection.tableId }
: undefined;
- // Hide tables that are already selected in other cards
const shouldHidePickerItem = useCallback(
- (pickerItem: MiniPickerItem | OmniPickerItem) =>
- pickerItem.model === "table" && selectedTableIds.includes(pickerItem.id),
+ (pickerItem: MiniPickerItem | OmniPickerItem) => {
+ const isAlreadySelected =
+ pickerItem.model === "table" &&
+ selectedTableIds.includes(pickerItem.id);
+ const isOurAnalytics =
+ pickerItem.model === "collection" && pickerItem.id === "root";
+
+ return isAlreadySelected || isOurAnalytics;
+ },
[selectedTableIds],
);