mirror of
https://github.com/penpot/penpot.git
synced 2026-09-15 00:19:01 +00:00
✨ Show warning when selecting a copy of conflicted variant (#6743)
This commit is contained in:
parent
ec021d944d
commit
70f3988046
@ -387,7 +387,7 @@
|
|||||||
(str duplicated-msg " " "Adjust the values so they can be retrieved.")]]))]))
|
(str duplicated-msg " " "Adjust the values so they can be retrieved.")]]))]))
|
||||||
|
|
||||||
|
|
||||||
(mf/defc component-variant*
|
(mf/defc component-variant-copy*
|
||||||
[{:keys [component shape data]}]
|
[{:keys [component shape data]}]
|
||||||
(let [component-id (:id component)
|
(let [component-id (:id component)
|
||||||
properties (:variant-properties component)
|
properties (:variant-properties component)
|
||||||
@ -397,6 +397,10 @@
|
|||||||
|
|
||||||
variant-components (cfv/find-variant-components data objects variant-id)
|
variant-components (cfv/find-variant-components data objects variant-id)
|
||||||
|
|
||||||
|
duplicated-ids (->> (cfv/find-variant-components data objects variant-id)
|
||||||
|
get-component-ids-with-duplicated-variant-props-and-values)
|
||||||
|
duplicated? (d/not-empty? duplicated-ids)
|
||||||
|
|
||||||
prop-vals (mf/with-memo [data objects variant-id]
|
prop-vals (mf/with-memo [data objects variant-id]
|
||||||
(cfv/extract-properties-values data objects variant-id))
|
(cfv/extract-properties-values data objects variant-id))
|
||||||
|
|
||||||
@ -406,6 +410,11 @@
|
|||||||
(fn [prop-name]
|
(fn [prop-name]
|
||||||
(get-variant-options prop-name prop-vals)))
|
(get-variant-options prop-name prop-vals)))
|
||||||
|
|
||||||
|
select-shapes-with-duplicated
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps duplicated-ids)
|
||||||
|
#(st/emit! (dw/select-shapes (into (d/ordered-set) duplicated-ids))))
|
||||||
|
|
||||||
switch-component
|
switch-component
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps shape)
|
(mf/deps shape)
|
||||||
@ -421,16 +430,27 @@
|
|||||||
(when nearest-comp
|
(when nearest-comp
|
||||||
(st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]
|
(st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]
|
||||||
|
|
||||||
[:div {:class (stl/css :variant-property-list)}
|
[:*
|
||||||
(for [[pos prop] (map vector (range) properties)]
|
[:div {:class (stl/css :variant-property-list)}
|
||||||
[:div {:key (str (:id shape) pos) :class (stl/css :variant-property-container)}
|
(for [[pos prop] (map vector (range) properties)]
|
||||||
[:*
|
[:div {:key (str (:id shape) pos) :class (stl/css :variant-property-container)}
|
||||||
[:span {:class (stl/css :variant-property-name)}
|
[:*
|
||||||
(:name prop)]
|
[:span {:class (stl/css :variant-property-name)}
|
||||||
[:> select* {:default-selected (:value prop)
|
(:name prop)]
|
||||||
:options (clj->js (get-options (:name prop)))
|
[:> select* {:default-selected (:value prop)
|
||||||
:empty-to-end true
|
:options (clj->js (get-options (:name prop)))
|
||||||
:on-change (partial switch-component pos)}]]])]))
|
:empty-to-end true
|
||||||
|
:on-change (partial switch-component pos)}]]])]
|
||||||
|
|
||||||
|
(when duplicated?
|
||||||
|
[:div {:class (stl/css :variant-warning-wrapper)}
|
||||||
|
[:> icon* {:icon-id "msg-neutral"
|
||||||
|
:class (stl/css :variant-warning-darken)}]
|
||||||
|
[:div {:class (stl/css :variant-warning-highlight)}
|
||||||
|
(tr "workspace.options.component.variant.duplicated.copy.title")]
|
||||||
|
[:button {:class (stl/css :variant-warning-button)
|
||||||
|
:on-click select-shapes-with-duplicated}
|
||||||
|
(tr "workspace.options.component.variant.duplicated.copy.locate")]])]))
|
||||||
|
|
||||||
|
|
||||||
(mf/defc component-swap-item
|
(mf/defc component-swap-item
|
||||||
@ -879,9 +899,9 @@
|
|||||||
(not (:deleted component))
|
(not (:deleted component))
|
||||||
(not swap-opened?)
|
(not swap-opened?)
|
||||||
(not multi))
|
(not multi))
|
||||||
[:> component-variant* {:component component
|
[:> component-variant-copy* {:component component
|
||||||
:shape shape
|
:shape shape
|
||||||
:data data}])
|
:data data}])
|
||||||
|
|
||||||
(when (and is-variant? main-instance? same-variant? (not swap-opened?))
|
(when (and is-variant? main-instance? same-variant? (not swap-opened?))
|
||||||
[:> component-variant-main-instance* {:components components
|
[:> component-variant-main-instance* {:components components
|
||||||
|
|||||||
@ -5487,6 +5487,14 @@ msgstr "Variant"
|
|||||||
msgid "workspace.options.component.variant.duplicated.group.locate"
|
msgid "workspace.options.component.variant.duplicated.group.locate"
|
||||||
msgstr "Locate duplicated variants"
|
msgstr "Locate duplicated variants"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:440
|
||||||
|
msgid "workspace.options.component.variant.duplicated.copy.title"
|
||||||
|
msgstr "This component has conflicting variants. Make sure each variation has a unique set of property values."
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:443
|
||||||
|
msgid "workspace.options.component.variant.duplicated.copy.locate"
|
||||||
|
msgstr "Go to main component"
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:954
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:954
|
||||||
msgid "workspace.options.component.variant.duplicated.group.title"
|
msgid "workspace.options.component.variant.duplicated.group.title"
|
||||||
msgstr "Some variants have identical properties and values"
|
msgstr "Some variants have identical properties and values"
|
||||||
|
|||||||
@ -5507,6 +5507,14 @@ msgstr "Desvinculado"
|
|||||||
msgid "workspace.options.component.variant"
|
msgid "workspace.options.component.variant"
|
||||||
msgstr "Variante"
|
msgstr "Variante"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:440
|
||||||
|
msgid "workspace.options.component.variant.duplicated.copy.title"
|
||||||
|
msgstr "Este componente tiene variantes en conflicto. Comprueba que cada variante tenga un conjunto único de propiedades y valores."
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:443
|
||||||
|
msgid "workspace.options.component.variant.duplicated.copy.locate"
|
||||||
|
msgstr "Ir al componente principal"
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:957
|
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:957
|
||||||
msgid "workspace.options.component.variant.duplicated.group.locate"
|
msgid "workspace.options.component.variant.duplicated.group.locate"
|
||||||
msgstr "Localizar variantes duplicadas"
|
msgstr "Localizar variantes duplicadas"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user