diff --git a/frontend/src/metabase/entities/collections.js b/frontend/src/metabase/entities/collections.js index 410628afa801e669c7edb751dba5dbe45cc28b96..5f36d19aa28a1b6582c6c2828723fa4e7ec3c91e 100644 --- a/frontend/src/metabase/entities/collections.js +++ b/frontend/src/metabase/entities/collections.js @@ -8,17 +8,37 @@ import { createSelector } from "reselect"; import { GET } from "metabase/lib/api"; -import { - getUser, - getUserDefaultCollectionId, - getUserPersonalCollectionId, -} from "metabase/selectors/user"; +import { getUser, getUserPersonalCollectionId } from "metabase/selectors/user"; import { t } from "ttag"; const listCollectionsTree = GET("/api/collection/tree"); const listCollections = GET("/api/collection"); +export const ROOT_COLLECTION = { + id: "root", + name: t`Our analytics`, + location: "", + path: [], +}; + +export const PERSONAL_COLLECTION = { + id: undefined, // to be filled in by getExpandedCollectionsById + name: t`My personal collection`, + location: "/", + path: [ROOT_COLLECTION.id], + can_write: true, +}; + +// fake collection for admins that contains all other user's collections +export const PERSONAL_COLLECTIONS = { + id: "personal", // placeholder id + name: t`All personal collections`, + location: "/", + path: [ROOT_COLLECTION.id], + can_write: false, +}; + const Collections = createEntity({ name: "collections", path: "/api/collection", @@ -86,7 +106,8 @@ const Collections = createEntity({ (state, { params }) => (params ? params.collectionId : undefined), (state, { location }) => location && location.query ? location.query.collectionId : undefined, - getUserDefaultCollectionId, + () => ROOT_COLLECTION.id, + getUserPersonalCollectionId, ], (collections, ...collectionIds) => { for (const collectionId of collectionIds) { @@ -169,31 +190,6 @@ export const getCollectionType = (collectionId: string, state: {}) => ? "other" : null; -export const ROOT_COLLECTION = { - id: "root", - name: t`Our analytics`, - location: "", - path: [], -}; - -// the user's personal collection -export const PERSONAL_COLLECTION = { - id: undefined, // to be filled in by getExpandedCollectionsById - name: t`My personal collection`, - location: "/", - path: ["root"], - can_write: true, -}; - -// fake collection for admins that contains all other user's collections -export const PERSONAL_COLLECTIONS = { - id: "personal", // placeholder id - name: t`All personal collections`, - location: "/", - path: ["root"], - can_write: false, -}; - type UserId = number; // a "real" collection diff --git a/frontend/src/metabase/selectors/user.js b/frontend/src/metabase/selectors/user.js index d9676fe8ecce8c33f19c81ba0bf369fa39992b0a..07f75ae45e34f1cce251f2cb5a20e9e473b4c101 100644 --- a/frontend/src/metabase/selectors/user.js +++ b/frontend/src/metabase/selectors/user.js @@ -16,9 +16,3 @@ export const getUserPersonalCollectionId = createSelector( [getUser], user => (user && user.personal_collection_id) || null, ); - -export const getUserDefaultCollectionId = createSelector( - [getUser, getUserIsAdmin, getUserPersonalCollectionId], - (user, isAdmin, personalCollectionId) => - isAdmin ? null : personalCollectionId, -); diff --git a/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js b/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js index 314d52d7f7dcfcc3ea6a47e2d35f89bd36521add..5a993ba61b0589d1cb957813db4c250f3a9c1d03 100644 --- a/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js +++ b/frontend/test/metabase/scenarios/collections/permissions.cy.spec.js @@ -654,6 +654,17 @@ describe("collection permissions", () => { }); }); }); + + it("should offer to save items to 'Our analytics' if user has a 'curate' access to it", () => { + cy.signIn("normal"); + + cy.visit("/question/new"); + cy.findByText("Native query").click(); + cy.get(".ace_content").type("select * from people"); + cy.findByText("Save").click(); + + cy.get(".AdminSelect").findByText("Our analytics"); + }); }); function clickRevert(event_name, index = 0) { diff --git a/frontend/test/metabase/scenarios/native/native.cy.spec.js b/frontend/test/metabase/scenarios/native/native.cy.spec.js index 46fa2ba2965aa184fb17fddc876e7d5f0e3b8327..4d43eb4c4d03ff4944f7bf7cfcdf997392bc736c 100644 --- a/frontend/test/metabase/scenarios/native/native.cy.spec.js +++ b/frontend/test/metabase/scenarios/native/native.cy.spec.js @@ -229,7 +229,6 @@ describe("scenarios > question > native", () => { cy.findByText("Simple question").click(); popover().within(() => { cy.findByText("Saved Questions").click(); - cy.findByText("Robert Tableton's Personal Collection").click(); cy.findByText(QUESTION).click(); });