From 3f3cf8b17fe5829d57d064bede0dee82b997ef8f Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Wed, 10 Jan 2024 12:19:42 -0500 Subject: [PATCH] enhance: migrate imported config to be valid Also improves import ux as Invalid config notification no longer blocks import progress --- src/main/frontend/components/imports.cljs | 10 +++++++--- src/main/frontend/handler/common/config_edn.cljs | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/components/imports.cljs b/src/main/frontend/components/imports.cljs index ca273e45ef..8561365f1d 100644 --- a/src/main/frontend/components/imports.cljs +++ b/src/main/frontend/components/imports.cljs @@ -26,6 +26,7 @@ [logseq.graph-parser :as graph-parser] [medley.core :as medley] [promesa.core :as p] + [borkdude.rewrite-edn :as rewrite] [rum.core :as rum] [frontend.handler.repo :as repo-handler])) @@ -208,10 +209,13 @@ (-> (when config-file (.text config-file)) (p/then (fn [content] - (when content + (let [migrated-content (-> (reduce rewrite/dissoc + (rewrite/parse-string (str content)) + [:preferred-format :property/separated-by-commas]) + str)] (p/do! - (db-editor-handler/save-file! "logseq/config.edn" content)) - (edn/read-string content)))))) + (db-editor-handler/save-file! "logseq/config.edn" migrated-content)) + (edn/read-string migrated-content)))))) (rum/defc confirm-graph-name-dialog diff --git a/src/main/frontend/handler/common/config_edn.cljs b/src/main/frontend/handler/common/config_edn.cljs index 70a3cd2ac5..2f62702248 100644 --- a/src/main/frontend/handler/common/config_edn.cljs +++ b/src/main/frontend/handler/common/config_edn.cljs @@ -97,7 +97,9 @@ nested keys or positional errors e.g. tuples" db-graph? (merge {:preferred-format - "is not used in DB graphs as there is only markdown mode."}))] + "is not used in DB graphs as there is only markdown mode." + :property/separated-by-commas + "is not used in DB graphs"}))] (cond (= body ::failed-to-detect) (log/info :msg "Skip deprecation check since config is not valid edn")