瀏覽代碼

enhance: disable preferred-format and setting org-mode

for db graphs. Also deprecate in config
Gabriel Horner 2 年之前
父節點
當前提交
211dd6aea7

+ 1 - 0
deps/common/resources/templates/config.edn

@@ -1,6 +1,7 @@
 {:meta/version 1
 
  ;; Set the preferred format.
+ ;; This is _only_ for file graphs.
  ;; Available options:
  ;; - Markdown (default)
  ;; - Org

+ 2 - 1
src/main/frontend/components/settings.cljs

@@ -662,7 +662,8 @@
         enable-git-auto-push? (state/enable-git-auto-push? current-repo)]
 
     [:div.panel-wrap.is-editor
-     (file-format-row t preferred-format)
+     (when-not (config/db-based-graph? (state/get-current-repo))
+       (file-format-row t preferred-format))
      (date-format-row t preferred-date-format)
      (workflow-row t preferred-workflow)
      (show-brackets-row t show-brackets?)

+ 8 - 3
src/main/frontend/handler/common/config_edn.cljs

@@ -88,11 +88,16 @@ nested keys or positional errors e.g. tuples"
 
 (defn detect-deprecations
   "Detects config keys that will or have been deprecated"
-  [path content]
+  [path content {:keys [db-graph?]}]
   (let [body (try (edn/read-string content)
                (catch :default _ ::failed-to-detect))
-        warnings {:editor/command-trigger
-                  "is no longer supported. Please use '/' and report bugs on it."}]
+        warnings (cond->
+                  {:editor/command-trigger
+                   "is no longer supported. Please use '/' and report bugs on it."}
+                   db-graph?
+                   (merge
+                    {:preferred-format
+                     "is not used in DB graphs as there is only markdown mode."}))]
     (cond
       (= body ::failed-to-detect)
       (log/info :msg "Skip deprecation check since config is not valid edn")

+ 1 - 1
src/main/frontend/handler/db_based/editor.cljs

@@ -99,7 +99,7 @@
   "This fn is the db version of file-handler/alter-file"
   [path content]
   (let [file-valid? (if (= path "logseq/config.edn")
-                      (do (config-edn-common-handler/detect-deprecations path content)
+                      (do (config-edn-common-handler/detect-deprecations path content {:db-graph? true})
                           (config-edn-common-handler/validate-config-edn path content repo-config-schema/Config-edn))
                       true)]
 

+ 1 - 1
src/main/frontend/handler/file.cljs

@@ -92,7 +92,7 @@
   [path content]
   (when (or (= path "logseq/config.edn")
             (= (path/dirname path) (global-config-handler/safe-global-config-dir)))
-    (config-edn-common-handler/detect-deprecations path content)))
+    (config-edn-common-handler/detect-deprecations path content {:db-graph? (config/db-based-graph? (state/get-current-repo))})))
 
 (defn- validate-file
   "Returns true if valid and if false validator displays error message. Files

+ 1 - 1
src/test/frontend/handler/common/config_edn_test.cljs

@@ -21,7 +21,7 @@
   (let [error-message (atom nil)]
     (with-redefs [notification/show! (fn [msg _] (reset! error-message msg))
                   rfe/href (constantly "")]
-      (config-edn-common-handler/detect-deprecations "config.edn" config-body)
+      (config-edn-common-handler/detect-deprecations "config.edn" config-body {})
       (str @error-message))))
 
 (deftest validate-config-edn