mirror of
https://github.com/logseq/logseq.git
synced 2026-05-27 14:14:24 +00:00
fix: namespaced pages converted to tags
result in invalid graph. This wasn't a use case we supported before and if we do decide to support it should be purposefully done and available from all parts of the UI, not just conversion
This commit is contained in:
@@ -151,7 +151,7 @@
|
||||
(when (and db-based? (ldb/internal-page? page))
|
||||
{:title (t :page/convert-to-tag)
|
||||
:options {:on-click (fn []
|
||||
(db-page-handler/convert-to-tag! page))}})
|
||||
(db-page-handler/convert-page-to-tag! page))}})
|
||||
|
||||
(when (and db-based? (ldb/class? page) (not (:logseq.property/built-in? page)))
|
||||
{:title (t :page/convert-tag-to-page)
|
||||
|
||||
@@ -608,7 +608,7 @@
|
||||
(:db/id page)))
|
||||
|
||||
(and class? page? id)
|
||||
(p/let [_ (db-page-handler/convert-to-tag! page-entity)]
|
||||
(p/let [_ (db-page-handler/convert-page-to-tag! page-entity)]
|
||||
id)
|
||||
|
||||
:else
|
||||
|
||||
@@ -42,18 +42,21 @@
|
||||
(when (valid-tag? repo (db/entity repo [:block/uuid block-id]) tag-entity)
|
||||
(db-property-handler/set-block-property! block-id :block/tags (:db/id tag-entity)))))
|
||||
|
||||
(defn convert-to-tag!
|
||||
(defn convert-page-to-tag!
|
||||
"Converts a Page to a Tag"
|
||||
[page-entity]
|
||||
(if (db/page-exists? (:block/title page-entity) #{:logseq.class/Tag})
|
||||
(notification/show! (str "A tag with the name \"" (:block/title page-entity) "\" already exists.") :warning false)
|
||||
(let [txs [(db-class/build-new-class (db/get-db)
|
||||
{:db/id (:db/id page-entity)
|
||||
:block/title (:block/title page-entity)
|
||||
:block/created-at (:block/created-at page-entity)})
|
||||
[:db/retract (:db/id page-entity) :block/tags :logseq.class/Page]]]
|
||||
(cond (db/page-exists? (:block/title page-entity) #{:logseq.class/Tag})
|
||||
(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)
|
||||
:else
|
||||
(let [txs [(db-class/build-new-class (db/get-db)
|
||||
{:db/id (:db/id page-entity)
|
||||
:block/title (:block/title page-entity)
|
||||
:block/created-at (:block/created-at page-entity)})
|
||||
[:db/retract (:db/id page-entity) :block/tags :logseq.class/Page]]]
|
||||
|
||||
(db/transact! (state/get-current-repo) txs {:outliner-op :save-block}))))
|
||||
(db/transact! (state/get-current-repo) txs {:outliner-op :save-block}))))
|
||||
|
||||
(defn convert-tag-to-page!
|
||||
[entity]
|
||||
@@ -61,7 +64,7 @@
|
||||
(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." :warning false)
|
||||
(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/<get-tag-objects (state/get-current-repo) (:db/id entity))]
|
||||
(let [convert-fn
|
||||
(fn convert-fn []
|
||||
|
||||
Reference in New Issue
Block a user