mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -05:00
🐛 Fix components with non existing component-ids for v2 migration
This commit is contained in:
parent
0c682ea75d
commit
6fa22c3a04
1 changed files with 23 additions and 0 deletions
|
@ -436,6 +436,28 @@
|
||||||
(-> file-data
|
(-> file-data
|
||||||
(update :components update-vals fix-container))))
|
(update :components update-vals fix-container))))
|
||||||
|
|
||||||
|
fix-non-existing-component-ids
|
||||||
|
;; Check component ids have valid values.
|
||||||
|
(fn [file-data]
|
||||||
|
(let [libraries (assoc-in libraries [(:id file-data) :data] file-data)]
|
||||||
|
(letfn [(fix-container [container]
|
||||||
|
(d/update-when container :objects update-vals fix-shape))
|
||||||
|
|
||||||
|
(fix-shape [shape]
|
||||||
|
(let [component-id (:component-id shape)
|
||||||
|
component-file (:component-file shape)
|
||||||
|
library (get libraries component-file)]
|
||||||
|
|
||||||
|
(cond-> shape
|
||||||
|
(and (some? component-id)
|
||||||
|
(some? library)
|
||||||
|
(nil? (ctkl/get-component (:data library) component-id)))
|
||||||
|
(ctk/detach-shape))))]
|
||||||
|
|
||||||
|
(-> file-data
|
||||||
|
(update :pages-index update-vals fix-container)
|
||||||
|
(d/update-when :components update-vals fix-container)))))
|
||||||
|
|
||||||
fix-misc-shape-issues
|
fix-misc-shape-issues
|
||||||
(fn [file-data]
|
(fn [file-data]
|
||||||
(letfn [(fix-container [container]
|
(letfn [(fix-container [container]
|
||||||
|
@ -943,6 +965,7 @@
|
||||||
(fix-shape-geometry)
|
(fix-shape-geometry)
|
||||||
(fix-empty-components)
|
(fix-empty-components)
|
||||||
(fix-components-with-component-root)
|
(fix-components-with-component-root)
|
||||||
|
(fix-non-existing-component-ids)
|
||||||
(fix-completly-broken-shapes)
|
(fix-completly-broken-shapes)
|
||||||
(fix-bad-children)
|
(fix-bad-children)
|
||||||
(fix-broken-parents)
|
(fix-broken-parents)
|
||||||
|
|
Loading…
Add table
Reference in a new issue