Browse Source

fix: disable renaming for built-in pages

Tienson Qin 1 year ago
parent
commit
dbd6f7d780
1 changed files with 10 additions and 0 deletions
  1. 10 0
      deps/outliner/src/logseq/outliner/core.cljs

+ 10 - 0
deps/outliner/src/logseq/outliner/core.cljs

@@ -284,6 +284,15 @@
                                                (pr-str (->> res first (d/entity db) :block/tags first :block/title)))
                                  :type :warning}})))))
 
+(defn ^:api validate-built-in-pages
+  "Validates built-in pages shouldn't be modified"
+  [entity]
+  (when (ldb/built-in? entity)
+    (throw (ex-info "Rename built-in pages"
+                    {:type :notification
+                     :payload {:message "Built-in pages can't be edited"
+                               :type :warning}}))))
+
 (extend-type Entity
   otree/INode
   (-save [this txs-state conn repo _date-formatter {:keys [retract-attributes? retract-attributes]
@@ -327,6 +336,7 @@
                        (and (or (ldb/page? block-entity) (seq (:block/tags block-entity)))
                             (:block/title m*)
                             (not= (:block/title m*) (:block/title block-entity))))
+              (validate-built-in-pages block-entity)
               (validate-unique-by-name-tag-and-block-type db (:block/title m*) block-entity))
           m (cond-> m*
               db-based?