mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
commit
5e6ce26742
5 changed files with 36 additions and 20 deletions
|
@ -202,7 +202,7 @@
|
|||
(when (some? head-component)
|
||||
(get-ref-shape (:data head-file) head-component shape))))]
|
||||
|
||||
(d/seek find-ref-shape-in-head parent-heads)))
|
||||
(some find-ref-shape-in-head parent-heads)))
|
||||
|
||||
(defn find-remote-shape
|
||||
"Recursively go back by the :shape-ref of the shape until find the correct shape of the original component"
|
||||
|
|
|
@ -609,24 +609,27 @@
|
|||
(ptk/reify ::detach-selected-components
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
file (wsh/get-local-file state)
|
||||
container (cfh/get-container file :page page-id)
|
||||
libraries (wsh/get-libraries state)
|
||||
selected (->> state
|
||||
(wsh/lookup-selected)
|
||||
(cfh/clean-loops objects))
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
file (wsh/get-local-file state)
|
||||
container (cfh/get-container file :page page-id)
|
||||
libraries (wsh/get-libraries state)
|
||||
selected (->> state
|
||||
(wsh/lookup-selected)
|
||||
(cfh/clean-loops objects))
|
||||
selected-objects (map #(get objects %) selected)
|
||||
can-detach? (every? #(not (ctn/has-any-copy-parent? objects %)) selected-objects)
|
||||
changes (when can-detach?
|
||||
(reduce
|
||||
(fn [changes id]
|
||||
(dwlh/generate-detach-instance changes libraries container id))
|
||||
(-> (pcb/empty-changes it)
|
||||
(pcb/with-container container)
|
||||
(pcb/with-objects objects))
|
||||
selected))]
|
||||
|
||||
changes (reduce
|
||||
(fn [changes id]
|
||||
(dwlh/generate-detach-instance changes libraries container id))
|
||||
(-> (pcb/empty-changes it)
|
||||
(pcb/with-container container)
|
||||
(pcb/with-objects objects))
|
||||
selected)]
|
||||
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
(rx/of (when can-detach?
|
||||
(dch/commit-changes changes)))))))
|
||||
|
||||
(defn nav-to-component-file
|
||||
[file-id component]
|
||||
|
|
|
@ -355,6 +355,9 @@
|
|||
(not (ctn/has-any-copy-parent? objects shape))
|
||||
(cfh/component-touched? objects (:id shape)))))
|
||||
|
||||
can-detach? (and (seq copies)
|
||||
(every? #(not (ctn/has-any-copy-parent? objects %)) copies))
|
||||
|
||||
|
||||
do-detach-component
|
||||
#(st/emit! (dwl/detach-components (map :id copies)))
|
||||
|
@ -420,7 +423,7 @@
|
|||
(when (and (not multi) main-instance? local-component? lacks-annotation? components-v2)
|
||||
{:msg "workspace.shape.menu.create-annotation"
|
||||
:action do-create-annotation})
|
||||
(when (seq copies)
|
||||
(when can-detach?
|
||||
{:msg (if (> (count copies) 1)
|
||||
"workspace.shape.menu.detach-instances-in-bulk"
|
||||
"workspace.shape.menu.detach-instance")
|
||||
|
|
|
@ -522,7 +522,8 @@
|
|||
(when open?
|
||||
[:div {:class (stl/css :element-content)}
|
||||
[:div {:class (stl/css-case :component-wrapper true
|
||||
:with-actions show-menu?)}
|
||||
:with-actions show-menu?
|
||||
:without-actions (not show-menu?))}
|
||||
[:button {:class (stl/css-case :component-name-wrapper true
|
||||
:with-main (and can-swap? (not multi))
|
||||
:swappeable (and can-swap? (not swap-opened?)))
|
||||
|
|
|
@ -51,6 +51,15 @@
|
|||
grid-template-columns: 1fr $s-28;
|
||||
gap: $s-2;
|
||||
}
|
||||
|
||||
&.without-actions {
|
||||
padding-right: 0.5rem;
|
||||
.component-name-wrapper {
|
||||
width: 100%;
|
||||
|
||||
border-radius: $br-8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.component-name-wrapper {
|
||||
|
|
Loading…
Add table
Reference in a new issue