浏览代码

chore: rename public property to publishing-public?

Since #11673 will provide a lower level public? property,
made sense to rename to avoid confusion between public and public?.
Also start deprecating :name config in built-in-properties as it
is barely used and is somewhat confusing
Gabriel Horner 9 月之前
父节点
当前提交
3a62177082

+ 8 - 7
deps/db/src/logseq/db/frontend/property.cljs

@@ -48,7 +48,8 @@
        seen in when :public? is set. Valid values are :page, :block and :never. Property can
        be viewed in any context if not set
    * :title - Property's :block/title
-   * :name - Property's :block/name as a keyword. If none given, one is derived from the db/ident
+   * :name - Property's :block/name as a keyword. If none given, one is derived from the db/ident.
+      TODO: This is barely used for old properties. Deprecate this and move to gp-exporter
    * :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties
    * :queryable? - Boolean for whether property can be queried in the query builder
    * :closed-values - Vec of closed-value maps for properties with choices. Map
@@ -406,12 +407,12 @@
 
      :logseq.property/icon {:title "Icon"
                             :schema {:type :map}}
-     :logseq.property/public {:title "Publishing Public?"
-                              :schema
-                              {:type :checkbox
-                               :hide? true
-                               :view-context :page
-                               :public? true}}
+     :logseq.property/publishing-public? {:title "Publishing Public?"
+                                          :schema
+                                          {:type :checkbox
+                                           :hide? true
+                                           :view-context :page
+                                           :public? true}}
      :logseq.property/exclude-from-graph-view {:title "Excluded from Graph view?"
                                                :schema
                                                {:type :checkbox

+ 1 - 1
deps/db/src/logseq/db/frontend/schema.cljs

@@ -2,7 +2,7 @@
   "Main datascript schemas for the Logseq app"
   (:require [clojure.set :as set]))
 
-(def version 59)
+(def version 60)
 
 ;; A page is a special block, a page can corresponds to multiple files with the same ":block/name".
 (def ^:large-vars/data-var schema

+ 6 - 4
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -406,10 +406,12 @@
 (def built-in-property-name-to-idents
   "Map of all built-in keyword property names to their idents. Using in-memory property
   names because these are legacy names already in a user's file graph"
-  (->> db-property/built-in-properties
-       (map (fn [[k v]]
-              [(:name v) k]))
-       (into {})))
+  (merge (->> (dissoc db-property/built-in-properties :logseq.property/publishing-public?)
+              (map (fn [[k v]]
+                     [(:name v) k]))
+              (into {}))
+         ;; TODO: Move 3 remaining :name config from built-in-properties to here
+         {:public :logseq.property/publishing-public?}))
 
 (def all-built-in-property-names
   "All built-in property names as a set of keywords"

+ 2 - 2
deps/publishing/src/logseq/publishing/db.cljs

@@ -50,7 +50,7 @@
   (let [pages (->> (d/q
                     '[:find ?p
                       :in $ %
-                      :where (property ?p :logseq.property/public true) [?p :block/name]]
+                      :where (property ?p :logseq.property/publishing-public? true) [?p :block/name]]
                     db
                     (rules/extract-rules rules/db-query-dsl-rules [:property]))
                    (map first)
@@ -72,7 +72,7 @@
   (->> (d/q
         '[:find ?p
           :in $ %
-          :where (property ?p :logseq.property/public false) [?p :block/name]]
+          :where (property ?p :logseq.property/publishing-public? false) [?p :block/name]]
         db
         (rules/extract-rules rules/db-query-dsl-rules [:property]))
        (map first)

+ 4 - 2
src/main/frontend/components/page_menu.cljs

@@ -10,7 +10,6 @@
             [frontend.handler.file-sync :as file-sync-handler]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
-            [frontend.handler.property.util :as pu]
             [frontend.handler.shell :as shell]
             [frontend.handler.user :as user-handler]
             [frontend.mobile.util :as mobile-util]
@@ -55,7 +54,9 @@
           whiteboard? (ldb/whiteboard? page)
           block? (and page (util/uuid-string? page-name) (not whiteboard?))
           contents? (= page-name "contents")
-          public? (pu/get-block-property-value page :logseq.property/public)
+          public? (if db-based?
+                    (:logseq.property/publishing-public? page)
+                    (get-in page [:block/properties :public]))
           _favorites-updated? (state/sub :favorites/updated?)
           favorited? (page-handler/favorited? page-title)
           developer-mode? (state/sub [:ui/developer-mode?])
@@ -139,6 +140,7 @@
              :options {:on-click
                        (fn []
                          (page-handler/update-public-attribute!
+                          repo
                           page
                           (if public? false true)))}})
 

+ 6 - 4
src/main/frontend/handler/page.cljs

@@ -24,7 +24,6 @@
             [frontend.handler.notification :as notification]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.property :as property-handler]
-            [frontend.handler.property.util :as pu]
             [frontend.handler.ui :as ui-handler]
             [frontend.mobile.util :as mobile-util]
             [frontend.modules.outliner.op :as outliner-op]
@@ -45,7 +44,8 @@
             [logseq.db :as ldb]
             [logseq.graph-parser.db :as gp-db]
             [logseq.graph-parser.text :as text]
-            [promesa.core :as p]))
+            [promesa.core :as p]
+            [frontend.handler.file-based.page-property :as file-page-property]))
 
 (def <create! page-common-handler/<create!)
 (def <delete! page-common-handler/<delete!)
@@ -169,8 +169,10 @@
     (state/set-journals-length! (+ (:journals-length @state/state) 7))))
 
 (defn update-public-attribute!
-  [page value]
-  (property-handler/add-page-property! page (pu/get-pid :logseq.property/public) value))
+  [repo page value]
+  (if (config/db-based-graph? repo)
+    (db-property-handler/set-block-property! [:block/uuid (:block/uuid page)] :logseq.property/publishing-public? value)
+    (file-page-property/add-property! page :public value)))
 
 (defn get-page-ref-text
   [page]

+ 2 - 1
src/main/frontend/worker/db/migrate.cljs

@@ -625,7 +625,8 @@
                      :logseq.property.history/block :logseq.property.history/property
                      :logseq.property.history/ref-value :logseq.property.history/scalar-value]}]
    [58 {:fix remove-duplicated-contents-page}]
-   [59 {:properties [:logseq.property/created-by]}]])
+   [59 {:properties [:logseq.property/created-by]}]
+   [60 {:fix (rename-properties {:logseq.property/public :logseq.property/publishing-public?})}]])
 
 (let [max-schema-version (apply max (map first schema-version->updates))]
   (assert (<= db-schema/version max-schema-version))