diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewHeader.jsx b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewHeader.jsx index b4826d1b31c53f5c17b2f779bcab54a4f3f34f11..45aa4fe57cf67782ca665fd59ccb8b58a2f630b6 100644 --- a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewHeader.jsx +++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewHeader.jsx @@ -461,7 +461,7 @@ function ViewTitleHeaderRightSide(props) { ); const canSave = Lib.canSave(question.query()); - const isSaveDisabled = !canSave || !isEditable; + const isSaveDisabled = !canSave; const disabledSaveTooltip = getDisabledSaveTooltip( isEditable, requiredTemplateTags, diff --git a/src/metabase/lib/query.cljc b/src/metabase/lib/query.cljc index 202f6f2b1c562e645f483e293636dcf5ee790576..e846d81347c4e7a2279aeadbe8984439e2e8b541 100644 --- a/src/metabase/lib/query.cljc +++ b/src/metabase/lib/query.cljc @@ -76,7 +76,8 @@ (mu/defn can-save :- :boolean "Returns whether the query can be saved." [query :- ::lib.schema/query] - (and (can-run query) + (and (lib.metadata/editable? query) + (can-run query) (boolean (can-save-method query)))) (mu/defn query-with-stages :- ::lib.schema/query diff --git a/test/metabase/lib/query_test.cljc b/test/metabase/lib/query_test.cljc index 5ee4949e27fb5f056680013c0bd1c9abe6868c7a..62156fece1f73571a775f301c25a96aeab7d1f01 100644 --- a/test/metabase/lib/query_test.cljc +++ b/test/metabase/lib/query_test.cljc @@ -188,5 +188,11 @@ (lib.query/query meta/metadata-provider {:database 74001, :type :query, :query {:source-table 74040}}))))) -(deftest ^:parallel can-save-mbql-test - (is (lib.query/can-save lib.tu/venues-query))) +(deftest ^:parallel can-save-test + (mu/disable-enforcement + (are [can-save? query] + (= can-save? (lib.query/can-save query)) + true lib.tu/venues-query + false (assoc lib.tu/venues-query :database nil) ; database unknown - no permissions + true (lib/native-query meta/metadata-provider "SELECT") + false (lib/native-query meta/metadata-provider ""))))