Skip to content

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

Adding collection name to recent documents (#65376)

Nick Fitzpatrick283eae65b613
diff --git a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js b/e2e/test/scenarios/onboarding/command-palette.cy.spec.js
index dd70a96d4c4..6329b33663f 100644
--- a/e2e/test/scenarios/onboarding/command-palette.cy.spec.js
+++ b/e2e/test/scenarios/onboarding/command-palette.cy.spec.js
@@ -7,7 +7,10 @@ import {
ORDERS_DASHBOARD_ID,
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
-import { createMockDashboardCard } from "metabase-types/api/mocks";
+import {
+ createMockDashboardCard,
+ createMockDocument,
+} from "metabase-types/api/mocks";
const { admin } = USERS;
@@ -66,6 +69,7 @@ describe("command palette", () => {
//Request to have an item in the recents list
cy.request(`/api/dashboard/${ORDERS_DASHBOARD_ID}`);
+
cy.visit("/");
cy.findByRole("button", { name: /search/i }).click();
@@ -217,6 +221,31 @@ describe("command palette", () => {
});
});
+ // Making this a separate test for now because it requires the bleeding edge token, which
+ // Enables a bunch of other stuff and messes up the "Renders a searchable command palette"
+ // test. In the future, this can be integrated into the test above, or moved to a BE test
+ it("should display collection names for documents in recents", () => {
+ H.activateToken("bleeding-edge");
+
+ //Create a document so that it appears in the recents list
+ cy.request(
+ "POST",
+ "/api/ee/document",
+ createMockDocument({ collection_id: ADMIN_PERSONAL_COLLECTION_ID }),
+ );
+
+ cy.visit("/");
+
+ cy.findByRole("button", { name: /search/i }).click();
+ H.commandPalette().should("be.visible");
+
+ // UXW-1786
+ cy.findByRole("option", { name: "Test Document" }).should(
+ "contain.text",
+ "Bobby Tables's Personal Collection",
+ );
+ });
+
describe("admin settings links", () => {
it("should render links to all admin settings pages for admins", () => {
cy.visit("/");
diff --git a/enterprise/backend/src/metabase_enterprise/documents/models/document.clj b/enterprise/backend/src/metabase_enterprise/documents/models/document.clj
index 906f9bb4805..9a0f4072fb8 100644
--- a/enterprise/backend/src/metabase_enterprise/documents/models/document.clj
+++ b/enterprise/backend/src/metabase_enterprise/documents/models/document.clj
@@ -117,9 +117,16 @@
:last-viewed-at :last_viewed_at
:pinned [:> [:coalesce :collection_position [:inline 0]] [:inline 0]]}
:search-terms [:name]
+ :joins {:collection [:model/Collection [:= :collection.id :this.collection_id]]}
:render-terms {:document-name :name
:document-id :id
- :collection-position true}})
+ :collection-authority_level :collection.authority_level
+ :collection-location :collection.location
+ :collection-name :collection.name
+ ;; This is used for legacy ranking, in future it will be replaced by :pinned
+ :collection-position true
+ :collection-type :collection.type
+ :archived-directly true}})
;;; ---------------------------------------------- Serialization --------------------------------------------------