mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -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)
|
||||
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
|
||||
"Validate shape is a main instance head, component exists and its main-instance points to this shape."
|
||||
[shape file page libraries report-error]
|
||||
|
@ -1077,13 +1090,12 @@
|
|||
(:id shape))}))
|
||||
(vswap! errors conj {:hint msg
|
||||
:code code
|
||||
:shape shape
|
||||
:file file
|
||||
:page page}))))]
|
||||
:shape shape}))))]
|
||||
|
||||
(dm/assert! (str/format "Shape %s not found" shape-id) (some? shape))
|
||||
|
||||
(validate-parent-children shape file page report-error)
|
||||
(validate-frame shape file page report-error)
|
||||
|
||||
(if (ctk/main-instance? shape)
|
||||
|
||||
|
|
|
@ -438,7 +438,7 @@
|
|||
file
|
||||
page
|
||||
libraries)]
|
||||
(clj->js errors))))
|
||||
(clj->js errors))))
|
||||
|
||||
(defn ^:export fix-orphan-shapes
|
||||
[]
|
||||
|
|
Loading…
Add table
Reference in a new issue