diff --git a/deps/outliner/src/logseq/outliner/validate.cljs b/deps/outliner/src/logseq/outliner/validate.cljs index ae56e5e2ec..355e960a69 100644 --- a/deps/outliner/src/logseq/outliner/validate.cljs +++ b/deps/outliner/src/logseq/outliner/validate.cljs @@ -37,10 +37,12 @@ :payload {:message "Page name can't be blank." :type :warning}}))))) +(def uneditable-page? ldb/built-in?) + (defn ^:api validate-built-in-pages "Validates built-in pages shouldn't be modified" [entity] - (when (ldb/built-in? entity) + (when (uneditable-page? entity) (throw (ex-info "Rename built-in pages" {:type :notification :payload {:message "Built-in pages can't be edited" diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index fcc36d54c5..647df4113d 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/src/main/frontend/components/page_menu.cljs @@ -148,7 +148,7 @@ :options {:on-click #(commands/exec-plugin-simple-command! pid (assoc cmd :page page-name) action)}})) - (when (and db-based? (ldb/internal-page? page)) + (when (and db-based? (ldb/internal-page? page) (not (:logseq.property/built-in? page))) {:title (t :page/convert-to-tag) :options {:on-click (fn [] (db-page-handler/convert-page-to-tag! page))}}) diff --git a/src/main/frontend/handler/db_based/page.cljs b/src/main/frontend/handler/db_based/page.cljs index 507e4acf06..31cc75a13c 100644 --- a/src/main/frontend/handler/db_based/page.cljs +++ b/src/main/frontend/handler/db_based/page.cljs @@ -49,6 +49,8 @@ (notification/show! (str "A tag with the name \"" (:block/title page-entity) "\" already exists.") :warning false) (:block/parent page-entity) (notification/show! "Namespaced pages can't be tags" :error false) + (outliner-validate/uneditable-page? page-entity) + (notification/show! "Built-in pages can't be edited" :error) :else (let [txs [(db-class/build-new-class (db/get-db) {:db/id (:db/id page-entity) @@ -60,32 +62,34 @@ (defn convert-tag-to-page! [entity] - (if (db/page-exists? (:block/title entity) #{:logseq.class/Page}) - (notification/show! (str "A page with the name \"" (:block/title entity) "\" already exists.") :warning false) - (when-not (:logseq.property/built-in? entity) - (if (seq (:logseq.property.class/_extends entity)) - (notification/show! "This tag cannot be converted because it has tag children. All tag children must be removed or converted before converting this tag." :error false) - (p/let [objects (db-async/ (shui/dialog-confirm! - "Converting a tag to page also removes its tag properties and its tag from all nodes tagged with it. Are you ok with that?" - {:id :convert-tag-to-page - :data-reminder :ok}) - (p/then convert-fn)))))))) + (cond (db/page-exists? (:block/title entity) #{:logseq.class/Page}) + (notification/show! (str "A page with the name \"" (:block/title entity) "\" already exists.") :warning false) + (outliner-validate/uneditable-page? entity) + (notification/show! "Built-in tags can't be edited" :error) + :else + (if (seq (:logseq.property.class/_extends entity)) + (notification/show! "This tag cannot be converted because it has tag children. All tag children must be removed or converted before converting this tag." :error false) + (p/let [objects (db-async/ (shui/dialog-confirm! + "Converting a tag to page also removes its tag properties and its tag from all nodes tagged with it. Are you ok with that?" + {:id :convert-tag-to-page + :data-reminder :ok}) + (p/then convert-fn))))))) (defn