Browse Source

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
Gabriel Horner 1 year ago
parent
commit
9291e8b3b0

+ 3 - 1
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]

+ 1 - 1
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)))))

+ 6 - 0
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?]))

+ 1 - 1
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)

+ 2 - 2
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

+ 1 - 1
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 <get-all-properties
   "Returns all public properties as property maps including their

+ 11 - 4
src/main/frontend/worker/search.cljs

@@ -253,9 +253,10 @@ DROP TRIGGER IF EXISTS blocks_au;
   "Options:
    * :page - the page to specifically search on
    * :limit - Number of result to limit search results. Defaults to 100
-   * :built-in?  - Whether to return built-in pages for db graphs. Defaults to false"
-  [repo conn search-db q {:keys [limit page enable-snippet?
-                                 built-in?] :as option
+   * :dev? - Allow all nodes to be seen for development. Defaults to false
+   * :built-in?  - Whether to return public built-in nodes for db graphs. Defaults to false"
+  [repo conn search-db q {:keys [limit page enable-snippet?  built-in? dev?]
+                          :as option
                           :or {enable-snippet? true}}]
   (when-not (string/blank? q)
     (p/let [match-input (get-match-input q)
@@ -280,7 +281,13 @@ DROP TRIGGER IF EXISTS blocks_au;
                                 (let [{:keys [id page title snippet]} result
                                       block-id (uuid id)]
                                   (when-let [block (d/entity @conn [:block/uuid block-id])]
-                                    (when-not (and (not built-in?) (ldb/built-in? block))
+                                    (when (if dev?
+                                            true
+                                            (if built-in?
+                                              (or (not (ldb/built-in? block))
+                                                 (ldb/class? block)
+                                                 (ldb/public-built-in-property? block))
+                                              (not (ldb/built-in? block))))
                                       {:db/id (:db/id block)
                                        :block/uuid block-id
                                        :block/title (or snippet title)