mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix: node created from tables can't be converted to Page
related to https://github.com/logseq/db-test/issues/428
This commit is contained in:
@@ -289,14 +289,7 @@
|
||||
{:type :notification
|
||||
:payload {:message message
|
||||
:type :error
|
||||
:block (into {} block)}}))))
|
||||
;; Guard against classes and properties becoming namespace parents
|
||||
(when (or (entity-util/class? (:block/page block)) (entity-util/property? (:block/page block)))
|
||||
(throw (ex-info "Can't convert this block to page when block is in a property or tag."
|
||||
{:type :notification
|
||||
:payload {:message "Can't convert this block to page when block is in a property or tag."
|
||||
:type :error
|
||||
:block (into {} block)}}))))))))
|
||||
:block (into {} block)}})))))))))
|
||||
|
||||
(defn validate-tags-property
|
||||
"Validates adding a property value to :block/tags for given blocks"
|
||||
|
||||
@@ -171,8 +171,7 @@
|
||||
:build-existing-tx? true})
|
||||
block (db-test/find-block-by-content @conn "block")
|
||||
block-invalid-title (db-test/find-block-by-content @conn #"invalid title")
|
||||
block-invalid-location (db-test/find-block-by-content @conn #"invalid location")
|
||||
block-invalid-in-class (db-test/find-block-by-content @conn "class block")]
|
||||
block-invalid-location (db-test/find-block-by-content @conn #"invalid location")]
|
||||
|
||||
(is (thrown-with-msg?
|
||||
js/Error
|
||||
@@ -217,13 +216,7 @@
|
||||
js/Error
|
||||
#"Can't convert this block to page"
|
||||
(outliner-validate/validate-tags-property @conn [(:db/id block-invalid-location)] :logseq.class/Page))
|
||||
"Block with invalid location can't be tagged with #Page")
|
||||
|
||||
(is (thrown-with-msg?
|
||||
js/Error
|
||||
#"Can't convert this block to page"
|
||||
(outliner-validate/validate-tags-property @conn [(:db/id block-invalid-in-class)] :logseq.class/Page))
|
||||
"Block in class or property can't be tagged with #Page")))
|
||||
"Block with invalid location can't be tagged with #Page")))
|
||||
|
||||
(deftest validate-tags-property-deletion
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
|
||||
@@ -161,11 +161,16 @@
|
||||
|
||||
;; block->page
|
||||
(and (:added datom) block-before (not (ldb/page? block-before))) ; block->page
|
||||
(let [->page-tx [{:db/id id
|
||||
:block/name (common-util/page-name-sanity-lc (:block/title block-after))}
|
||||
[:db/retract id :block/page]]
|
||||
move-parent-to-library-tx (let [block (d/entity db-after (:e datom))
|
||||
block-parent (:block/parent block)]
|
||||
(let [block (d/entity db-after (:e datom))
|
||||
block-parent (:block/parent block)
|
||||
->page-tx (concat
|
||||
[{:db/id id
|
||||
:block/name (common-util/page-name-sanity-lc (:block/title block-after))}
|
||||
[:db/retract id :block/page]]
|
||||
(when (or (ldb/class? block-parent) (ldb/property? block-parent))
|
||||
[[:db/retract id :block/parent]
|
||||
[:db/retract id :block/order]]))
|
||||
move-parent-to-library-tx (do
|
||||
(assert (ldb/page? block-parent))
|
||||
(when (and (nil? (:block/parent block-parent))
|
||||
block-parent
|
||||
|
||||
Reference in New Issue
Block a user