Skip to content
Snippets Groups Projects
Unverified Commit 4a44cbbc authored by Alexander Lesnenko's avatar Alexander Lesnenko Committed by GitHub
Browse files

hide snippets folders from the collections sidebar (#16576)


* hide snippets folders from the collections sidebar

* namespace test thing

Co-authored-by: default avatarhowon lee <hlee.howon@gmail.com>
parent ffec85fa
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,7 @@ describeWithToken("scenarios > question > snippets", () => {
cy.findByText("snippet 1");
});
it.skip("should not display snippet folder as part of collections (metabase#14907)", () => {
it("should not display snippet folder as part of collections (metabase#14907)", () => {
cy.server();
cy.route("GET", "/api/collection/root").as("collections");
......
......@@ -71,12 +71,15 @@
{:name \"F\"
:children [{:name \"G\"}]}]}]}
{:name \"H\"}]"
[]
[namespace]
{namespace (s/maybe su/NonBlankString)}
(collection/collections->tree
(db/select Collection
{:where (collection/visible-collection-ids->honeysql-filter-clause
:id
(collection/permissions-set->visible-collection-ids @api/*current-user-permissions-set*))})))
{:where [:and
[:= :namespace namespace]
(collection/visible-collection-ids->honeysql-filter-clause
:id
(collection/permissions-set->visible-collection-ids @api/*current-user-permissions-set*))]})))
;;; --------------------------------- Fetching a single Collection & its 'children' ----------------------------------
......@@ -343,8 +346,8 @@
(into []
(comp cat (map select-name) (distinct))
(for [model [:card :dashboard :snippet :pulse :collection]]
(:select (collection-children-query model {:id 1 :location "/"} nil))))
)
(:select (collection-children-query model {:id 1 :location "/"} nil)))))
(defn- collection-children*
[collection models {:keys [sort-info] :as options}]
......
......@@ -183,6 +183,24 @@
(collection-tree-names-only (map :id [parent-collection child-collection])
(mt/user-http-request :rasta :get 200 "collection/tree")))))))
(testing "Namespace parameter"
(mt/with-temp* [Collection [{normal-id :id} {:name "Normal Collection"}]
Collection [{coins-id :id} {:name "Coin Collection", :namespace "currency"}]]
(let [ids [normal-id coins-id]]
(testing "shouldn't show Collections of a different `:namespace` by default"
(is (= [{:name "Normal Collection", :children []}]
(collection-tree-names-only ids (mt/user-http-request :rasta :get 200 "collection/tree")))))
(perms/grant-collection-read-permissions! (group/all-users) coins-id)
(testing "By passing `:namespace` we should be able to see Collections of that `:namespace`"
(testing "?namespace=currency"
(is (= [{:name "Coin Collection", :children []}]
(collection-tree-names-only ids (mt/user-http-request :rasta :get 200 "collection/tree?namespace=currency")))))
(testing "?namespace=stamps"
(is (= []
(collection-tree-names-only ids (mt/user-http-request :rasta :get 200 "collection/tree?namespace=stamps")))))))))
(testing "Tree should elide Collections for which we have no permissions (#14280)"
;; Create hierarchy like
;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment