diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 3358f94997..391e828e09 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -463,7 +463,8 @@ [:div#edit-new-property (property-input block *property-key *property-value opts)] - (or (seq properties) + (or (and (seq properties) + (not (pu/all-built-in-properties? (keys (:block/properties block))))) (:page-configure? opts)) [:a {:style {:margin-left 2} :title "Add another property" diff --git a/src/main/frontend/db/restore.cljs b/src/main/frontend/db/restore.cljs index b9da50d41e..403620936d 100644 --- a/src/main/frontend/db/restore.cljs +++ b/src/main/frontend/db/restore.cljs @@ -69,12 +69,18 @@ [conn] (let [txs (keep (fn [[k-keyword {:keys [schema original-name]}]] - (let [k-name (name k-keyword)] - (let [property (d/entity @conn [:block/name k-name])] - (when-not (= {:schema schema - :original-name original-name} - {:schema (:block/schema property) - :original-name (:block/original-name property)}) + (let [k-name (name k-keyword) + property (d/entity @conn [:block/name k-name])] + (when-not (= {:schema schema + :original-name (or original-name k-name)} + {:schema (:block/schema property) + :original-name (:block/original-name property)}) + (if property + {:block/schema schema + :block/original-name (or original-name k-name) + :block/name (util/page-name-sanity-lc k-name) + :block/uuid (:block/uuid property) + :block/type "property"} (outliner-core/block-with-timestamps {:block/schema schema :block/original-name (or original-name k-name) diff --git a/src/main/frontend/db/validate.cljs b/src/main/frontend/db/validate.cljs index db3a32b8a7..7eafa16418 100644 --- a/src/main/frontend/db/validate.cljs +++ b/src/main/frontend/db/validate.cljs @@ -38,7 +38,9 @@ (get-in b [:block/left :db/id])]) page (d/entity db page-id) blocks (:block/_page page) - parent-left->es (group-by parent-left-f blocks) + parent-left->es (->> (group-by parent-left-f blocks) + (remove (fn [[k _v]] (= k [nil nil]))) + (into {})) conflicted (filter #(> (count (second %)) 1) parent-left->es)] (if (seq conflicted) [:conflict-parent-left conflicted] diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 3818a31f3d..e6d6df6527 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -3353,18 +3353,20 @@ ([block-id {:keys [semantic?] :or {semantic? false}}] (when block-id - (if-let [block (db-model/query-block-by-uuid block-id)] - (or (db-model/has-children? block-id) - (valid-dsl-query-block? block) - (valid-custom-query-block? block) - (seq (:block/properties block)) - (seq (:block/alias block)) - (and - (:outliner/block-title-collapse-enabled? (state/get-config)) - (block-with-title? (:block/format block) - (:block/content block) - semantic?))) - false)))) + (let [repo (state/get-current-repo)] + (if-let [block (db/entity [:block/uuid block-id])] + (or (db-model/has-children? block-id) + (valid-dsl-query-block? block) + (valid-custom-query-block? block) + (and (config/db-based-graph? repo) + (seq (:block/properties block)) + (not (pu/all-built-in-properties? (keys (:block/properties block))))) + (and + (:outliner/block-title-collapse-enabled? (state/get-config)) + (block-with-title? (:block/format block) + (:block/content block) + semantic?))) + false))))) (defn all-blocks-with-level "Return all blocks associated with correct level diff --git a/src/main/frontend/handler/property/util.cljs b/src/main/frontend/handler/property/util.cljs index b57445e79b..d3a45db7b3 100644 --- a/src/main/frontend/handler/property/util.cljs +++ b/src/main/frontend/handler/property/util.cljs @@ -4,7 +4,8 @@ [frontend.config :as config] [logseq.graph-parser.property :as gp-property] [logseq.graph-parser.util :as gp-util] - [frontend.db :as db])) + [frontend.db :as db] + [clojure.set :as set])) (defn lookup "Get the value of coll's (a map) `key`" @@ -32,3 +33,16 @@ (defn shape-block? [block] (= :whiteboard-shape (get-property block :ls-type))) + +(defonce *db-built-in-properties (atom {})) + +(defn all-built-in-properties? + [properties] + (let [repo (state/get-current-repo)] + (when (empty? @*db-built-in-properties) + (let [built-in-properties (set (map + (fn [p] + (:block/uuid (db/entity [:block/name (name p)]))) + gp-property/db-built-in-properties-keys))] + (swap! *db-built-in-properties assoc repo built-in-properties))) + (set/subset? (set properties) (get @*db-built-in-properties repo))))