Skip to content

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

Don't show metrics in the join step (#67490)

Nick Fitzpatrickdb48071330ea
diff --git a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
index c283252bea6..91e12d06f5d 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
@@ -1446,3 +1446,34 @@ describe("issue #47005", () => {
.should("be.visible");
});
});
+
+describe("issue 66210", () => {
+ const METRIC_NAME = "66210 metric";
+
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+
+ H.createQuestion({
+ name: METRIC_NAME,
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ },
+ type: "metric",
+ });
+
+ cy.visit("/");
+ });
+
+ it("should not allow you to join on metrics", () => {
+ H.startNewQuestion();
+ H.miniPickerBrowseAll().click();
+ H.entityPickerModalItem(1, METRIC_NAME).should("be.visible");
+ H.entityPickerModalItem(1, "Orders").click();
+ H.join();
+ H.miniPickerBrowseAll().click();
+ H.entityPickerModalTab("Data").click();
+ H.entityPickerModalLevel(1).findByText(METRIC_NAME).should("not.exist");
+ });
+});
diff --git a/frontend/src/metabase/common/components/Pickers/DataPicker/components/DataPickerModal.tsx b/frontend/src/metabase/common/components/Pickers/DataPicker/components/DataPickerModal.tsx
index 82a81819968..3bf5c15dede 100644
--- a/frontend/src/metabase/common/components/Pickers/DataPicker/components/DataPickerModal.tsx
+++ b/frontend/src/metabase/common/components/Pickers/DataPicker/components/DataPickerModal.tsx
@@ -82,7 +82,7 @@ export const DataPickerModal = ({
onClose,
shouldDisableItem,
options,
- models,
+ models = ["card", "dataset", "metric", "table"],
}: Props) => {
options = {
...OPTIONS,
@@ -219,19 +219,17 @@ export const DataPickerModal = ({
computedTabs.push({
id: "questions-tab",
displayName: t`Data`,
- models: [
- "card" as const,
- "dataset" as const,
- "metric" as const,
- "table" as const,
- ],
+ models,
folderModels: ["collection", "dashboard", "schema", "database"],
icon: "folder",
extraButtons: [filterButton],
render: ({ onItemSelect }) => (
<QuestionPicker
initialValue={value}
- models={QUESTION_PICKER_MODELS}
+ models={[
+ ...models,
+ ...(models.includes("card") ? ["dashboard" as const] : []),
+ ]}
options={options}
path={questionsPath}
shouldShowItem={shouldShowItem}