Repository: penpot/penpot
File: frontend/src/app/main/data/workspace/shapes.cljs (ClojureScript)

Code before:
                         :ignore-parents? ignore-parents?))

            add-component-to-variant? (and
                                       ;; Any of the shapes is a head
                                       (some (comp ctc/instance-head? objects) ids)
                                       ;; Any ancestor of the destination parent is a variant
                                       (->> (cfh/get-parents-with-self objects parent-id)
                                            (some ctc/is-variant?)))

            add-new-variant? (and
                              ;; The parent is a variant container
                              (-> parent-id objects ctc/is-variant-container?)
                               ;; Any of the shapes is a main instance
                              (some (comp ctc/main-instance? objects) ids))

            undo-id (js/Symbol)]

        (rx/of (dwu/start-undo-transaction undo-id)
               (dch/commit-changes changes)
               (dwco/expand-collapse parent-id)
               (ptk/data-event :layout/update {:ids (concat all-parents ids)})
               (dwu/commit-undo-transaction undo-id)
               (when add-component-to-variant?
                 (ptk/event ::ev/event {::ev/name "add-component-to-variant"}))
               (when add-new-variant?
                 (ptk/event ::ev/event {::ev/name "add-new-variant" :trigger "move-shapes-in-layers-tab"})))))))


Review comment (suggestion):
We already have a specialized property for indicate the location where is originated: `::ev/origin`, we should continue to use it in order to have all events normalized.

The value for **origin** here should be something `workspace:relocate-shapes` or `workspace:reorder-shapes-in-layers`

Code after:

            add-component-to-variant? (and
                                       ;; Any of the shapes is a head
                                       (some (comp ctc/instance-head? objects) ids)
                                       ;; Any ancestor of the destination parent is a variant
                                       (->> (cfh/get-parents-with-self objects parent-id)
                                            (some ctc/is-variant?)))

            add-new-variant? (and
                              ;; The parent is a variant container
                              (-> parent-id objects ctc/is-variant-container?)
                               ;; Any of the shapes is a main instance
                              (some (comp ctc/main-instance? objects) ids))

            undo-id (js/Symbol)]

        (rx/of (dwu/start-undo-transaction undo-id)
               (dch/commit-changes changes)
               (dwco/expand-collapse parent-id)
               (ptk/data-event :layout/update {:ids (concat all-parents ids)})
               (dwu/commit-undo-transaction undo-id)
               (when add-component-to-variant?
                 (ev/event {::ev/name "add-component-to-variant"}))
               (when add-new-variant?
                 (ev/event {::ev/name "add-new-variant" ::ev/origin "workspace:move-shapes-in-layers-tab"})))))))