mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Fix 'Reset override' menu option still present after remove library
This commit is contained in:
parent
d0fa58c66c
commit
b07e9bdd37
1 changed files with 25 additions and 20 deletions
|
@ -309,19 +309,18 @@
|
||||||
|
|
||||||
find-component #(ctf/resolve-component % current-file workspace-libraries)
|
find-component #(ctf/resolve-component % current-file workspace-libraries)
|
||||||
|
|
||||||
local-or-exists (fn [shape]
|
local-or-exists (fn [shape]
|
||||||
(let [library-id (:component-file shape)]
|
(let [library-id (:component-file shape)]
|
||||||
(or (= library-id current-file-id)
|
(or (= library-id current-file-id)
|
||||||
(some? (get workspace-libraries library-id)))))
|
(some? (get workspace-libraries library-id)))))
|
||||||
|
|
||||||
restorable-copies (->> copies
|
restorable-copies (->> copies
|
||||||
(filter #(nil? (find-component %)))
|
(filter #(nil? (find-component %)))
|
||||||
(filter #(local-or-exists %)))
|
(filter #(local-or-exists %)))
|
||||||
|
|
||||||
|
touched-not-dangling (filter #(and (cph/component-touched? objects (:id %))
|
||||||
touched-components (filter #(cph/component-touched? objects (:id %)) copies)
|
(find-component %)) copies)
|
||||||
|
can-reset-overrides? (or (not components-v2) (seq touched-not-dangling))
|
||||||
can-reset-overrides? (or (not components-v2) (seq touched-components))
|
|
||||||
|
|
||||||
|
|
||||||
;; For when it's only one shape
|
;; For when it's only one shape
|
||||||
|
@ -337,16 +336,22 @@
|
||||||
lacks-annotation? (nil? (:annotation component))
|
lacks-annotation? (nil? (:annotation component))
|
||||||
is-dangling? (nil? component)
|
is-dangling? (nil? component)
|
||||||
|
|
||||||
can-update-main? (or (not components-v2)
|
can-show-component? (and (not multi)
|
||||||
(and
|
(not main-instance?)
|
||||||
(not main-instance?)
|
(not is-dangling?))
|
||||||
(cph/component-touched? objects (:id shape))))
|
|
||||||
|
can-update-main? (and (not multi)
|
||||||
|
(not is-dangling?)
|
||||||
|
(or (not components-v2)
|
||||||
|
(and (not main-instance?)
|
||||||
|
(cph/component-touched? objects (:id shape)))))
|
||||||
|
|
||||||
|
|
||||||
do-detach-component
|
do-detach-component
|
||||||
#(st/emit! (dwl/detach-components (map :id copies)))
|
#(st/emit! (dwl/detach-components (map :id copies)))
|
||||||
|
|
||||||
do-reset-component
|
do-reset-component
|
||||||
#(st/emit! (dwl/reset-components (map :id touched-components)))
|
#(st/emit! (dwl/reset-components (map :id touched-not-dangling)))
|
||||||
|
|
||||||
do-restore-component
|
do-restore-component
|
||||||
#(let [;; Extract a map of component-id -> component-file in order to avoid duplicates
|
#(let [;; Extract a map of component-id -> component-file in order to avoid duplicates
|
||||||
|
@ -405,8 +410,8 @@
|
||||||
:action do-create-annotation})
|
:action do-create-annotation})
|
||||||
(when (seq copies)
|
(when (seq copies)
|
||||||
{:msg (if (> (count copies) 1)
|
{:msg (if (> (count copies) 1)
|
||||||
"workspace.shape.menu.detach-instances-in-bulk"
|
"workspace.shape.menu.detach-instances-in-bulk"
|
||||||
"workspace.shape.menu.detach-instance")
|
"workspace.shape.menu.detach-instance")
|
||||||
:action do-detach-component
|
:action do-detach-component
|
||||||
:shortcut :detach-component})
|
:shortcut :detach-component})
|
||||||
(when can-reset-overrides?
|
(when can-reset-overrides?
|
||||||
|
@ -415,10 +420,10 @@
|
||||||
(when (and (seq restorable-copies) components-v2)
|
(when (and (seq restorable-copies) components-v2)
|
||||||
{:msg "workspace.shape.menu.restore-main"
|
{:msg "workspace.shape.menu.restore-main"
|
||||||
:action do-restore-component})
|
:action do-restore-component})
|
||||||
(when (and (not multi) (not main-instance?) (not is-dangling?))
|
(when can-show-component?
|
||||||
{:msg "workspace.shape.menu.show-main"
|
{:msg "workspace.shape.menu.show-main"
|
||||||
:action do-show-component})
|
:action do-show-component})
|
||||||
(when (and (not multi) can-update-main? (not is-dangling?))
|
(when can-update-main?
|
||||||
{:msg "workspace.shape.menu.update-main"
|
{:msg "workspace.shape.menu.update-main"
|
||||||
:action do-update-component})]]
|
:action do-update-component})]]
|
||||||
(filter (complement nil?) menu-entries)))
|
(filter (complement nil?) menu-entries)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue