From 31a1f36baef59cd734b2414b5a6acaf57bdda6dc Mon Sep 17 00:00:00 2001
From: Anton Kulyk <kuliks.anton@gmail.com>
Date: Wed, 25 May 2022 17:25:55 +0100
Subject: [PATCH] Respect advanced permissions for model persistence (#22860)

* Expose `persisted-models-enabled` to authenticated

* Remove `isAdmin` check for showing peristence toggle
---
 .../DatabaseEditApp/Sidebar/Sidebar.jsx       | 48 +++++++++----------
 src/metabase/public_settings.clj              |  2 +-
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/frontend/src/metabase/admin/databases/components/DatabaseEditApp/Sidebar/Sidebar.jsx b/frontend/src/metabase/admin/databases/components/DatabaseEditApp/Sidebar/Sidebar.jsx
index e052e44a5c3..e0240b1fd9e 100644
--- a/frontend/src/metabase/admin/databases/components/DatabaseEditApp/Sidebar/Sidebar.jsx
+++ b/frontend/src/metabase/admin/databases/components/DatabaseEditApp/Sidebar/Sidebar.jsx
@@ -67,31 +67,29 @@ const DatabaseEditAppSidebar = ({
                 successText={t`Scan triggered!`}
               />
             </li>
-            {isAdmin &&
-              isModelPersistenceEnabled &&
-              database.supportsPersistence() && (
-                <li className="mt2">
-                  {database.isPersisted() ? (
-                    <ActionButton
-                      actionFn={() => unpersistDatabase(database.id)}
-                      className="Button"
-                      normalText={t`Disable model persistence`}
-                      activeText={t`Disabling…`}
-                      failedText={t`Failed`}
-                      successText={t`Done`}
-                    />
-                  ) : (
-                    <ActionButton
-                      actionFn={() => persistDatabase(database.id)}
-                      className="Button"
-                      normalText={t`Enable model persistence`}
-                      activeText={t`Enabling…`}
-                      failedText={t`Failed`}
-                      successText={t`Done`}
-                    />
-                  )}
-                </li>
-              )}
+            {isModelPersistenceEnabled && database.supportsPersistence() && (
+              <li className="mt2">
+                {database.isPersisted() ? (
+                  <ActionButton
+                    actionFn={() => unpersistDatabase(database.id)}
+                    className="Button"
+                    normalText={t`Disable model persistence`}
+                    activeText={t`Disabling…`}
+                    failedText={t`Failed`}
+                    successText={t`Done`}
+                  />
+                ) : (
+                  <ActionButton
+                    actionFn={() => persistDatabase(database.id)}
+                    className="Button"
+                    normalText={t`Enable model persistence`}
+                    activeText={t`Enabling…`}
+                    failedText={t`Failed`}
+                    successText={t`Done`}
+                  />
+                )}
+              </li>
+            )}
           </ol>
         </div>
 
diff --git a/src/metabase/public_settings.clj b/src/metabase/public_settings.clj
index bea4f9ba1c1..5c78d4b1315 100644
--- a/src/metabase/public_settings.clj
+++ b/src/metabase/public_settings.clj
@@ -211,7 +211,7 @@
   (deferred-tru "Allow persisting models into the source database.")
   :type       :boolean
   :default    false
-  :visibility :admin)
+  :visibility :authenticated)
 
 (defsetting persisted-model-refresh-interval-hours
   (deferred-tru "Hour interval to refresh persisted models.")
-- 
GitLab