mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 04:11:41 +02:00
♻️ Components refactor: generator for duplicate component
This commit is contained in:
parent
47804429c0
commit
02c455dcba
2 changed files with 34 additions and 27 deletions
|
@ -465,35 +465,9 @@
|
|||
(watch [it state _]
|
||||
(let [libraries (wsh/get-libraries state)
|
||||
library (get libraries library-id)
|
||||
component (ctkl/get-component (:data library) component-id)
|
||||
new-name (:name component)
|
||||
|
||||
components-v2 (features/active-feature? state "components/v2")
|
||||
|
||||
main-instance-page (when components-v2
|
||||
(ctf/get-component-page (:data library) component))
|
||||
|
||||
new-component-id (when components-v2
|
||||
(uuid/next))
|
||||
|
||||
[new-component-shape new-component-shapes ; <- null in components-v2
|
||||
new-main-instance-shape new-main-instance-shapes]
|
||||
(cflh/duplicate-component component new-component-id (:data library))
|
||||
|
||||
changes (-> (pcb/empty-changes it nil)
|
||||
(pcb/with-page main-instance-page)
|
||||
(pcb/with-objects (:objects main-instance-page))
|
||||
(pcb/add-objects new-main-instance-shapes {:ignore-touched true})
|
||||
(pcb/add-component (if components-v2
|
||||
new-component-id
|
||||
(:id new-component-shape))
|
||||
(:path component)
|
||||
new-name
|
||||
new-component-shapes
|
||||
[]
|
||||
(:id new-main-instance-shape)
|
||||
(:id main-instance-page)
|
||||
(:annotation component)))]
|
||||
(cflh/generate-duplicate-component library component-id components-v2))]
|
||||
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue