0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 14:12:36 -05:00

🐛 Fix menu for create annotation appears on components that already have annotation

This commit is contained in:
Pablo Alba 2023-06-22 17:32:31 +02:00 committed by Andrés Moya
parent 9d06a34df4
commit 2648dc3d27
2 changed files with 8 additions and 7 deletions

View file

@ -447,7 +447,6 @@
first-shape (first shapes) first-shape (first shapes)
{:keys [id component-id component-file main-instance?]} first-shape {:keys [id component-id component-file main-instance?]} first-shape
lacks-annotation? (nil? (:annotation first-shape))
component-shapes (filter #(contains? % :component-id) shapes) component-shapes (filter #(contains? % :component-id) shapes)
@ -458,9 +457,11 @@
workspace-data (deref refs/workspace-data) workspace-data (deref refs/workspace-data)
workspace-libraries (deref refs/workspace-libraries) workspace-libraries (deref refs/workspace-libraries)
is-dangling? (nil? (if local-component? component (if local-component?
(ctkl/get-component workspace-data component-id) (ctkl/get-component workspace-data component-id)
(ctf/get-component workspace-libraries component-file component-id))) (ctf/get-component workspace-libraries component-file component-id))
is-dangling? (nil? component)
lacks-annotation? (nil? (:annotation component))
lib-exists? (and (not local-component?) lib-exists? (and (not local-component?)
(some? (get workspace-libraries component-file))) (some? (get workspace-libraries component-file)))
@ -535,7 +536,7 @@
[:* [:*
[:& menu-entry {:title (tr "workspace.shape.menu.show-in-assets") [:& menu-entry {:title (tr "workspace.shape.menu.show-in-assets")
:on-click do-show-in-assets}] :on-click do-show-in-assets}]
(when (and components-v2 lacks-annotation?) (when (and components-v2 local-component? lacks-annotation?)
[:& menu-entry {:title (tr "workspace.shape.menu.create-annotation") [:& menu-entry {:title (tr "workspace.shape.menu.create-annotation")
:on-click create-annotation}])] :on-click create-annotation}])]
(if local-component? (if local-component?

View file

@ -163,7 +163,6 @@
(:main-instance? values) (:main-instance? values)
true) true)
main-component? (:main-instance? values) main-component? (:main-instance? values)
lacks-annotation? (nil? (:annotation values))
local-component? (= library-id current-file-id) local-component? (= library-id current-file-id)
workspace-data (deref refs/workspace-data) workspace-data (deref refs/workspace-data)
workspace-libraries (deref refs/workspace-libraries) workspace-libraries (deref refs/workspace-libraries)
@ -171,6 +170,7 @@
(ctkl/get-component workspace-data component-id) (ctkl/get-component workspace-data component-id)
(ctf/get-component workspace-libraries library-id component-id)) (ctf/get-component workspace-libraries library-id component-id))
is-dangling? (nil? component) is-dangling? (nil? component)
lacks-annotation? (nil? (:annotation component))
lib-exists? (and (not local-component?) lib-exists? (and (not local-component?)
(some? (get workspace-libraries library-id))) (some? (get workspace-libraries library-id)))
@ -237,7 +237,7 @@
:options :options
(if main-component? (if main-component?
[[(tr "workspace.shape.menu.show-in-assets") do-show-in-assets] [[(tr "workspace.shape.menu.show-in-assets") do-show-in-assets]
(when (and components-v2 lacks-annotation?) (when (and components-v2 local-component? lacks-annotation?)
[(tr "workspace.shape.menu.create-annotation") do-create-annotation])] [(tr "workspace.shape.menu.create-annotation") do-create-annotation])]
(if local-component? (if local-component?
(if is-dangling? (if is-dangling?