From e8ab1cea490fb7a441330d0bff180e41855cc782 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Thu, 22 Aug 2024 10:33:34 -0400 Subject: [PATCH] enhance: users can navigate to public built-in nodes like task ones We spent a good amount of effort making tasks customizable. It should be easy for users to navigate to Task or status page to customize them --- deps/db/src/logseq/db.cljs | 4 +++- deps/db/src/logseq/db/frontend/entity_util.cljs | 2 +- deps/db/src/logseq/db/frontend/property.cljs | 6 ++++++ src/main/frontend/components/cmdk/core.cljs | 2 +- src/main/frontend/components/property.cljs | 4 ++-- src/main/frontend/db/async.cljs | 2 +- src/main/frontend/worker/search.cljs | 15 +++++++++++---- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/deps/db/src/logseq/db.cljs b/deps/db/src/logseq/db.cljs index 74abbfa0b..d2f91476b 100644 --- a/deps/db/src/logseq/db.cljs +++ b/deps/db/src/logseq/db.cljs @@ -15,7 +15,8 @@ [logseq.db.frontend.rules :as rules] [logseq.db.sqlite.common-db :as sqlite-common-db] [logseq.db.sqlite.util :as sqlite-util] - [logseq.db.frontend.content :as db-content])) + [logseq.db.frontend.content :as db-content] + [logseq.db.frontend.property :as db-property])) ;; Use it as an input argument for datalog queries (def block-attrs @@ -94,6 +95,7 @@ (def whiteboard? sqlite-util/whiteboard?) (def journal? sqlite-util/journal?) (def hidden? sqlite-util/hidden?) +(def public-built-in-property? db-property/public-built-in-property?) (defn sort-by-order [blocks] diff --git a/deps/db/src/logseq/db/frontend/entity_util.cljs b/deps/db/src/logseq/db/frontend/entity_util.cljs index 1b3ac0bc8..6733871b9 100644 --- a/deps/db/src/logseq/db/frontend/entity_util.cljs +++ b/deps/db/src/logseq/db/frontend/entity_util.cljs @@ -6,4 +6,4 @@ "Whether the current graph is db-only" [db] (when db - (= "db" (:kv/value (d/entity db :logseq.kv/db-type))))) + (= "db" (:kv/value (d/entity db :logseq.kv/db-type))))) \ No newline at end of file diff --git a/deps/db/src/logseq/db/frontend/property.cljs b/deps/db/src/logseq/db/frontend/property.cljs index 898ad3167..c04432157 100644 --- a/deps/db/src/logseq/db/frontend/property.cljs +++ b/deps/db/src/logseq/db/frontend/property.cljs @@ -319,3 +319,9 @@ [(:block/title (d/entity db k)) (ref->property-value-contents db v)])) (into {}))) + +(defn public-built-in-property? + "Indicates whether built-in property can be seen and edited by users" + [entity] + ;; No need to do :built-in? check yet since user properties can't set this + (get-in entity [:block/schema :public?])) \ No newline at end of file diff --git a/src/main/frontend/components/cmdk/core.cljs b/src/main/frontend/components/cmdk/core.cljs index d1c5247f8..787b6f804 100644 --- a/src/main/frontend/components/cmdk/core.cljs +++ b/src/main/frontend/components/cmdk/core.cljs @@ -257,7 +257,7 @@ repo (state/get-current-repo) current-page (when-let [id (page-util/get-current-page-id)] (db/entity id)) - opts {:limit 100 :built-in? config/dev?}] + opts {:limit 100 :dev? config/dev? :built-in? true}] (swap! !results assoc-in [group :status] :loading) (swap! !results assoc-in [:current-page :status] :loading) (p/let [blocks (search/block-search repo @!input opts) diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 171d76ac8..15ae18e86 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -147,7 +147,7 @@ ;; existing property selected or entered (if property (do - (when (and (not (get-in property [:block/schema :public?])) + (when (and (not (ldb/public-built-in-property? property)) (ldb/built-in? property)) (notification/show! "This is a private built-in property that can't be used." :error)) property) @@ -865,7 +865,7 @@ (when-let [ent (db/entity id)] (or ;; built-in - (and (not (get-in ent [:block/schema :public?])) + (and (not (ldb/public-built-in-property? ent)) ;; TODO: Use ldb/built-in? when intermittent lazy loading issue fixed (get db-property/built-in-properties (:db/ident ent))) ;; other position diff --git a/src/main/frontend/db/async.cljs b/src/main/frontend/db/async.cljs index a5c5c1cbd..5dfadcea8 100644 --- a/src/main/frontend/db/async.cljs +++ b/src/main/frontend/db/async.cljs @@ -62,7 +62,7 @@ ;; remove private built-in properties (remove #(and (:db/ident %) (db-property/logseq-property? (:db/ident %)) - (not (get-in % [:block/schema :public?]))))))) + (not (ldb/public-built-in-property? %))))))) (defn