0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

🐛 Disallow restore component when the library has been detached

This commit is contained in:
Andrés Moya 2023-06-21 16:39:17 +02:00
parent bb8a523208
commit 749d60be48
2 changed files with 7 additions and 2 deletions

View file

@ -461,6 +461,8 @@
is-dangling? (nil? (if local-component?
(ctkl/get-component workspace-data component-id)
(ctf/get-component workspace-libraries component-file component-id)))
lib-exists? (and (not local-component?)
(some? (get workspace-libraries component-file)))
do-add-component #(st/emit! (dwl/add-component))
do-add-multiple-components #(st/emit! (dwl/add-multiple-components))
@ -568,7 +570,7 @@
(when can-update-main?
[:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides")
:on-click do-reset-component}])
(when components-v2
(when (and components-v2 lib-exists?)
[:& menu-entry {:title (tr "workspace.shape.menu.restore-main")
:on-click do-restore-component}])]
[:*

View file

@ -167,6 +167,9 @@
(ctkl/get-component workspace-data component-id)
(ctf/get-component workspace-libraries library-id component-id))
is-dangling? (nil? component)
lib-exists? (and (not local-component?)
(some? (get workspace-libraries library-id)))
on-menu-click
(mf/use-callback
@ -251,7 +254,7 @@
[[(tr "workspace.shape.menu.detach-instance") do-detach-component]
(when can-update-main?
[(tr "workspace.shape.menu.reset-overrides") do-reset-component])
(when components-v2
(when (and components-v2 lib-exists?)
[(tr "workspace.shape.menu.restore-main") do-restore-component])]
[[(tr "workspace.shape.menu.detach-instance") do-detach-component]
(when can-update-main?