mirror of
https://github.com/penpot/penpot.git
synced 2025-01-27 00:49:28 -05:00
✨ Validate frame-id
This commit is contained in:
parent
629322e505
commit
96a5444357
2 changed files with 16 additions and 4 deletions
|
@ -882,6 +882,19 @@
|
||||||
(str/format "Child %s not found" child-id)
|
(str/format "Child %s not found" child-id)
|
||||||
shape file page)))))))
|
shape file page)))))))
|
||||||
|
|
||||||
|
(defn validate-frame
|
||||||
|
"Validate that the frame-id shape exists and is indeed a frame."
|
||||||
|
[shape file page report-error]
|
||||||
|
(let [frame (ctst/get-shape page (:frame-id shape))]
|
||||||
|
(if (nil? frame)
|
||||||
|
(report-error :frame-not-found
|
||||||
|
(str/format "Frame %s not found" (:frame-id shape))
|
||||||
|
shape file page)
|
||||||
|
(when (not= (:type frame) :frame)
|
||||||
|
(report-error :invalid-frame
|
||||||
|
(str/format "Frame %s is not actually a frame" (:frame-id shape))
|
||||||
|
shape file page)))))
|
||||||
|
|
||||||
(defn validate-component-main-head
|
(defn validate-component-main-head
|
||||||
"Validate shape is a main instance head, component exists and its main-instance points to this shape."
|
"Validate shape is a main instance head, component exists and its main-instance points to this shape."
|
||||||
[shape file page libraries report-error]
|
[shape file page libraries report-error]
|
||||||
|
@ -1077,13 +1090,12 @@
|
||||||
(:id shape))}))
|
(:id shape))}))
|
||||||
(vswap! errors conj {:hint msg
|
(vswap! errors conj {:hint msg
|
||||||
:code code
|
:code code
|
||||||
:shape shape
|
:shape shape}))))]
|
||||||
:file file
|
|
||||||
:page page}))))]
|
|
||||||
|
|
||||||
(dm/assert! (str/format "Shape %s not found" shape-id) (some? shape))
|
(dm/assert! (str/format "Shape %s not found" shape-id) (some? shape))
|
||||||
|
|
||||||
(validate-parent-children shape file page report-error)
|
(validate-parent-children shape file page report-error)
|
||||||
|
(validate-frame shape file page report-error)
|
||||||
|
|
||||||
(if (ctk/main-instance? shape)
|
(if (ctk/main-instance? shape)
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@
|
||||||
file
|
file
|
||||||
page
|
page
|
||||||
libraries)]
|
libraries)]
|
||||||
(clj->js errors))))
|
(clj->js errors))))
|
||||||
|
|
||||||
(defn ^:export fix-orphan-shapes
|
(defn ^:export fix-orphan-shapes
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Add table
Reference in a new issue