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
Data apps start enabled; data actions export under collections/data_actions (#85313)
Alexander Polyankin62aad85db3b2
diff --git a/enterprise/backend/src/metabase_enterprise/data_apps/api.clj b/enterprise/backend/src/metabase_enterprise/data_apps/api.cljindex 2a9f9d03bf0..ab634b12e2a 100644--- a/enterprise/backend/src/metabase_enterprise/data_apps/api.clj+++ b/enterprise/backend/src/metabase_enterprise/data_apps/api.clj@@ -84,10 +84,9 @@(def ^:private create-defaults"What a new app starts with: an empty bundle, and unless its request says otherwise, the bundle path the app- template builds to and disabled until it is ready to be served."+ template builds to; it is enabled, like an app an import creates."{:bundle_path "dist/index.js"- :bundle ""- :enabled false})+ :bundle ""})(def ^:private UpdateDataAppRequest[:map {:closed true}@@ -216,7 +215,7 @@(api/check-403 (remote-sync/model-editable? :model/DataApp app)))(api.macros/defendpoint :post "/" :- DataAppResponse- "Create a data app with its resource collection and an empty bundle. It is disabled unless the request says+ "Create a data app with its resource collection and an empty bundle. It is enabled unless the request saysotherwise."[_route-params_query-paramsdiff --git a/enterprise/backend/test/metabase_enterprise/data_apps/api_test.clj b/enterprise/backend/test/metabase_enterprise/data_apps/api_test.cljindex 01d1f7324cd..ea0a877862a 100644--- a/enterprise/backend/test/metabase_enterprise/data_apps/api_test.clj+++ b/enterprise/backend/test/metabase_enterprise/data_apps/api_test.clj@@ -421,15 +421,15 @@(deftest create-defaults-test(mt/with-premium-features #{:data-apps}(mt/with-model-cleanup [:model/DataApp :model/Collection :model/PermissionsGroup]- (testing "an app created from its slug alone is a disabled app with an empty bundle and its collection"+ (testing "app created from its slug alone is enabled, with an empty bundle and its collection"(is (=? {:name "demo":display_name "demo":bundle_path "dist/index.js"- :enabled false+ :enabled true:resource_collection_id pos-int?}(mt/user-http-request :crowberto :post 200 "ee/apps" {:name "demo"})))(is (= 0 (alength ^bytes (t2/select-one-fn :bundle :model/DataApp :name "demo"))))- (is (=? {:name "demo" :enabled false} (mt/user-http-request :crowberto :get 200 "ee/apps/demo")))))))+ (is (=? {:name "demo" :enabled true} (mt/user-http-request :crowberto :get 200 "ee/apps/demo")))))))(deftest replace-bundle-endpoint-test(mt/test-helpers-set-global-values!@@ -537,7 +537,7 @@(deftest disabled-apps-are-listed-only-to-superusers-test(mt/with-premium-features #{:data-apps}(mt/with-model-cleanup [:model/DataApp :model/Collection :model/PermissionsGroup]- (let [{:keys [id]} (mt/user-http-request :crowberto :post 200 "ee/apps" {:name "demo"})]+ (let [{:keys [id]} (mt/user-http-request :crowberto :post 200 "ee/apps" {:name "demo" :enabled false})](group-access/add-groups! (t2/select-one :model/DataApp :id id) [(:id (perms/all-users-group))])(testing "an assigned user doesn't see the disabled app"(is (not-any? #(= "demo" (:name %)) (mt/user-http-request :rasta :get 200 "ee/apps"))))diff --git a/enterprise/backend/test/metabase_enterprise/data_apps/serialization_test.clj b/enterprise/backend/test/metabase_enterprise/data_apps/serialization_test.cljindex df5e1bdcc61..f6086b5d187 100644--- a/enterprise/backend/test/metabase_enterprise/data_apps/serialization_test.clj+++ b/enterprise/backend/test/metabase_enterprise/data_apps/serialization_test.clj@@ -87,7 +87,7 @@(mt/with-premium-features #{:data-apps}(mt/with-model-cleanup [:model/DataApp :model/Collection :model/PermissionsGroup](ts/with-random-dump-dir [dump-dir "data-app-round-trip-"]- (let [app (insert-app!)+ (let [app (insert-app! :enabled false)collection-entity-id (t2/select-one-fn :entity_id :model/Collection :id (:resource_collection_id app))](export! dump-dir :with-collections? true)(testing "the app's collection is exported with it, like any collection"@@ -105,6 +105,8 @@:allowed_hosts ["https://api.example.com"]}imported))(is (= "console.log(1)" (bundle-text imported)))+ (testing "new app starts enabled, like one created through the API"+ (is (true? (:enabled imported))))(testing "the import links the collection the manifest names without importing group assignments"(is (=? {:entity_id collection-entity-id :namespace :data-apps}(t2/select-one :model/Collection :id (:resource_collection_id imported))))diff --git a/src/metabase/actions/models.clj b/src/metabase/actions/models.cljindex fd690682d84..764af8ca04f 100644--- a/src/metabase/actions/models.clj+++ b/src/metabase/actions/models.clj@@ -677,7 +677,7 @@(or (nil? collection_id)(= collection/data-actions-ns(some-> (actions.db/collection-namespace-with-entity-id collection_id) keyword))))- (serdes/storage-default-collection-path action ctx (name collection/data-actions-ns))+ (serdes/storage-default-collection-path action ctx (serdes/collection-namespace-folder collection/data-actions-ns))(serdes/storage-default-collection-path action ctx)))(defmethod serdes/load-one! "Action" [ingested maybe-local]diff --git a/src/metabase/models/serialization.clj b/src/metabase/models/serialization.cljindex fc59cc98c41..44e6eadabbe 100644--- a/src/metabase/models/serialization.clj+++ b/src/metabase/models/serialization.clj@@ -776,12 +776,12 @@(defn collection-namespace-folder"The folder under `collections/` that holds the collections of `collection-namespace`, `main` for the default one.- The `data-apps` namespace is the `data_apps` folder, spelled like the top-level directory of the apps themselves."+ A dashed namespace is spelled with an underscore, like the top-level `data_apps` directory of the apps themselves."[collection-namespace](case (some-> collection-namespace keyword):snippets "snippets":transforms "transforms"- :data-actions "data-actions"+ :data-actions "data_actions":data-apps "data_apps""main"))diff --git a/test/metabase/actions/models_test.clj b/test/metabase/actions/models_test.cljindex 53a2e245703..cf97e8569a2 100644--- a/test/metabase/actions/models_test.clj+++ b/test/metabase/actions/models_test.clj@@ -482,12 +482,12 @@(is (not (t2/exists? :model/Action :entity_id entity-id))))))(deftest storage-path-test- (testing "actions without a model in the data actions root or namespace are stored in the data-actions folder"+ (testing "actions without a model in the data actions root or namespace are stored in the data_actions folder"(mt/with-temp [:model/Collection {folder-eid :entity_id} {:namespace "data-actions"}:model/Collection {app-eid :entity_id} {:namespace "data-apps"}](let [folder-label (fn [action](:label (second (serdes/storage-path (assoc action :serdes/meta [{:model "Action"}]) {}))))]- (is (= "data-actions" (folder-label {:name "At root" :entity_id "x" :model_id nil :collection_id nil})))- (is (= "data-actions" (folder-label {:name "In folder" :entity_id "x" :model_id nil :collection_id folder-eid})))+ (is (= "data_actions" (folder-label {:name "At root" :entity_id "x" :model_id nil :collection_id nil})))+ (is (= "data_actions" (folder-label {:name "In folder" :entity_id "x" :model_id nil :collection_id folder-eid})))(is (= "main" (folder-label {:name "App copy" :entity_id "x" :model_id nil :collection_id app-eid})))(is (= "main" (folder-label {:name "On a model" :entity_id "x" :model_id "model-eid" :collection_id nil})))))))