diff --git a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs index 084ff6f7f..94b49b1f0 100644 --- a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs +++ b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs @@ -121,25 +121,35 @@ {:type {:from prev-type :to prop-type}}))) (defn- update-built-in-property-values - [props db] + [props db ignored-properties {:block/keys [content name]}] (->> props - (map (fn [[prop val]] - [prop - (case prop - :query-properties - (try - (mapv #(if (#{:page :block :created-at :updated-at} %) % (get-pid db %)) - (edn/read-string val)) - (catch :default e - (js/console.error "Translating query properties failed with:" e) - [])) - :query-sort-by - (if (#{:page :block :created-at :updated-at} val) val (get-pid db val)) - (:logseq.color :logseq.table.headers :logseq.table.hover) - (:block/uuid (db-property/get-closed-value-entity-by-name db prop val)) - :logseq.table.version - (parse-long val) - val)])) + (keep (fn [[prop val]] + (if (= :icon prop) + (do (swap! ignored-properties + conj + {:property prop :value val :location (if name {:page name} {:block content})}) + nil) + [prop + (case prop + :query-properties + (try + (mapv #(if (#{:page :block :created-at :updated-at} %) % (get-pid db %)) + (edn/read-string val)) + (catch :default e + (js/console.error "Translating query properties failed with:" e) + [])) + :query-sort-by + (if (#{:page :block :created-at :updated-at} val) val (get-pid db val)) + (:logseq.color :logseq.table.headers :logseq.table.hover) + (:block/uuid (db-property/get-closed-value-entity-by-name db prop val)) + :logseq.table.version + (parse-long val) + :filters + (try (edn/read-string val) + (catch :default e + (js/console.error "Translating filters failed with:" e) + {})) + val)]))) (into {}))) (defn- handle-changed-property @@ -183,7 +193,9 @@ (defn- update-properties "Updates block property names and values" - [props db page-names-to-uuids properties-text-values {:keys [whiteboard? property-changes import-state]}] + [props db page-names-to-uuids + {:block/keys [properties-text-values] :as block} + {:keys [whiteboard? property-changes import-state]}] (let [prop-name->uuid (if whiteboard? (fn prop-name->uuid [k] (or (get-pid db k) @@ -195,7 +207,11 @@ ;; TODO: Add import support for :template. Ignore for now as they cause invalid property types (if (contains? props :template) {} - (-> (update-built-in-property-values (select-keys props db-property/built-in-properties-keys) db) + (-> (update-built-in-property-values + (select-keys props db-property/built-in-properties-keys) + db + (:ignored-properties import-state) + (select-keys block [:block/name :block/content])) (merge (update-user-property-values user-properties prop-name->uuid properties-text-values property-changes (:ignored-properties import-state))) (update-keys prop-name->uuid))))) @@ -206,13 +222,13 @@ [{:block/keys [properties] :as block} db page-names-to-uuids refs {:keys [import-state] :as options}] (-> (if (seq properties) (let [dissoced-props (into ignored-built-in-properties - ;; TODO: Add import support for these dissoced built-in properties + ;; TODO: Add import support for these dissoced built-in properties [:title :id :created-at :updated-at :card-last-interval :card-repeats :card-last-reviewed :card-next-schedule :card-ease-factor :card-last-score]) properties' (apply dissoc properties dissoced-props) properties-to-infer (if (:template properties') - ;; Ignore template properties as they don't consistently have representative property values + ;; Ignore template properties as they don't consistently have representative property values {} (apply dissoc properties' db-property/built-in-properties-keys)) property-changes (->> properties-to-infer @@ -223,7 +239,9 @@ _ (when (seq property-changes) (prn :PROP-CHANGES property-changes)) options' (assoc options :property-changes property-changes)] (assoc-in block [:block/properties] - (update-properties properties' db page-names-to-uuids (:block/properties-text-values block) options'))) + (update-properties properties' db page-names-to-uuids + (select-keys block [:block/properties-text-values :block/name :block/content]) + options'))) block) (dissoc :block/properties-text-values :block/properties-order :block/invalid-properties))) diff --git a/src/main/frontend/components/imports.cljs b/src/main/frontend/components/imports.cljs index e3987ffb6..d92de3ab5 100644 --- a/src/main/frontend/components/imports.cljs +++ b/src/main/frontend/components/imports.cljs @@ -360,11 +360,15 @@ [:.text-lg.mb-2 (str "Import ignored " (count ignored-props) " " (if (= 1 (count ignored-props)) "property" "properties"))] [:span.text-xs - "To fix this, change these property values to have the correct type and reimport the graph"] + "To fix a property type, change the property value to the correct type and reimport the graph"] (->> ignored-props - (map (fn [{:keys [property value schema]}] + (map (fn [{:keys [property value schema location]}] [(str "Property " (pr-str property) " with value " (pr-str value)) - (str "Property value has type " (get-in schema [:type :to]) " instead of type " (get-in schema [:type :from]))])) + (if (= property :icon) + (if (:page location) + (str "Page icons can't be imported. Go to the page " (pr-str (:page location)) " to manually import it.") + (str "Block icons can't be imported. Manually import it at the block: " (pr-str (:block location)))) + (str "Property value has type " (get-in schema [:type :to]) " instead of type " (get-in schema [:type :from])))])) (map (fn [[k v]] [:dl.my-2.mb-0 [:dt.m-0 [:strong (str k)]]