The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
allow getting transforms in root collection (#68731)
John Swansonbf811415087c
diff --git a/enterprise/backend/test/metabase_enterprise/transforms/api_test.clj b/enterprise/backend/test/metabase_enterprise/transforms/api_test.cljindex c559ecf707d..2c4619f61d8 100644--- a/enterprise/backend/test/metabase_enterprise/transforms/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/transforms/api_test.clj@@ -1507,6 +1507,44 @@(finally(t2/delete! :model/Transform :id (:id transform))))))))))))))+(deftest root-collection-items-include-transforms-test+ (testing "GET /api/collection/root/items"+ (testing "Includes transforms in root collection items"+ (mt/with-premium-features #{:transforms}+ (mt/with-temp [:model/Transform {transform-id :id}+ {:name "Root Transform"+ :description "A transform at root"}]+ (testing "Transform appears in unfiltered results"+ (let [items (->> (:data (mt/user-http-request :crowberto :get 200+ "collection/root/items"+ :namespace "transforms"))+ (filter #(= "transform" (:model %))))]+ (is (= 1 (count items)))+ (is (= "transform" (:model (first items))))+ (is (= "Root Transform" (:name (first items))))))+ (testing "Transform appears when filtered by models=trans form"++ (let [items (:data (mt/user-http-request :crowberto :get 200+ "collection/root/items"+ :namespace "transforms"+ :models "transform"))]+ (is (= 1 (count items)))+ (is (= transform-id (:id (first items))))))++ (testing "Transform NOT returned when filtering for other models only"+ (let [items (:data (mt/user-http-request :crowberto :get 200+ "collection/root/items"+ :namespace "transforms"+ :models "card"))]+ (is (empty? items))))++ (testing "Non-admin users don't see transforms"+ (let [items (->> (:data (mt/user-http-request :rasta :get 200+ "collection/root/items"+ :namespace "transforms"))+ (filter #(= "transform" (:model %))))]+ (is (empty? items)))))))))+(deftest transforms-appear-in-here-test(testing "GET /api/collection/:id/items"(testing "Transforms in a collection appear in its :here field"diff --git a/src/metabase/collections_rest/api.clj b/src/metabase/collections_rest/api.cljindex 59ace571013..d5f3f478d7a 100644--- a/src/metabase/collections_rest/api.clj+++ b/src/metabase/collections_rest/api.clj@@ -1293,6 +1293,15 @@#{:collection}#{:no_models})))+(def ^:private namespaces-holding-non-collection-types+ "We can't really *know* what namespace something with a `nil` `collection_id` is in, unless it's one of the special+ types that can only live in one namespace.++ If you're looking in the root collection of one of these namespaces, we'll allow you to list any type of model.++ Otherwise, we'll just show you collections."+ #{nil "snippets" "transforms"})+;; TODO (Cam 10/28/25) -- fix this endpoint so it uses kebab-case for query parameters for consistency with the rest;; of the REST API;;@@ -1347,7 +1356,9 @@:show-dashboard-questions? (boolean show_dashboard_questions):collection-type collection_type:include-library? include_library- :models (if-not (or (nil? namespace) (= namespace "snippets")) #{:collection} model-kwds)+ :models (if-not (contains? namespaces-holding-non-collection-types namespace)+ #{:collection}+ model-kwds):pinned-state (keyword pinned_state):sort-info {:sort-column (or (some-> sort_column normalize-sort-choice) :name):sort-direction (or (some-> sort_direction normalize-sort-choice) :asc)