mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 15:06:13 +02:00
🐛 Avoid creating component with shapes that belong to other one
This commit is contained in:
parent
a1a0444cc7
commit
dc89610d07
1 changed files with 8 additions and 5 deletions
|
@ -10,6 +10,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.components-list :as ctkl]
|
[app.common.types.components-list :as ctkl]
|
||||||
[app.common.types.file :as ctf]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.page :as ctp]
|
[app.common.types.page :as ctp]
|
||||||
|
@ -398,6 +399,7 @@
|
||||||
|
|
||||||
has-component? (some true? (map #(contains? % :component-id) shapes))
|
has-component? (some true? (map #(contains? % :component-id) shapes))
|
||||||
is-component? (and single? (-> shapes first :component-id some?))
|
is-component? (and single? (-> shapes first :component-id some?))
|
||||||
|
is-non-root? (and single? (ctk/in-component-instance-not-root? (first shapes)))
|
||||||
|
|
||||||
shape-id (-> shapes first :id)
|
shape-id (-> shapes first :id)
|
||||||
component-id (-> shapes first :component-id)
|
component-id (-> shapes first :component-id)
|
||||||
|
@ -452,10 +454,12 @@
|
||||||
:on-accept do-update-component-in-bulk}))]
|
:on-accept do-update-component-in-bulk}))]
|
||||||
[:*
|
[:*
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
(when (or (not is-non-root?) (and has-component? (not single?)))
|
||||||
|
[:& menu-separator])
|
||||||
|
(when-not is-non-root?
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
||||||
:shortcut (sc/get-tooltip :create-component)
|
:shortcut (sc/get-tooltip :create-component)
|
||||||
:on-click do-add-component}]
|
:on-click do-add-component}])
|
||||||
(when (and has-component? (not single?))
|
(when (and has-component? (not single?))
|
||||||
[:*
|
[:*
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instances-in-bulk")
|
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instances-in-bulk")
|
||||||
|
@ -468,7 +472,6 @@
|
||||||
;; WARNING: this menu is the same as the context menu at the sidebar.
|
;; WARNING: this menu is the same as the context menu at the sidebar.
|
||||||
;; If you change it, you must change equally the file
|
;; If you change it, you must change equally the file
|
||||||
;; app/main/ui/workspace/sidebar/options/menus/component.cljs
|
;; app/main/ui/workspace/sidebar/options/menus/component.cljs
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:& menu-separator]
|
[:& menu-separator]
|
||||||
(if main-component?
|
(if main-component?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue