mirror of
https://github.com/penpot/penpot.git
synced 2025-05-26 02:26:11 +02:00
✨ Restore a deleted variant
This commit is contained in:
parent
7eab6a2f1d
commit
219ddfabaf
7 changed files with 86 additions and 28 deletions
|
@ -8,6 +8,7 @@
|
|||
(ns app.main.ui.workspace.sidebar.assets.common
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.spec :as us]
|
||||
[app.common.thumbnails :as thc]
|
||||
|
@ -384,6 +385,24 @@
|
|||
|
||||
same-variant? (ctv/same-variant? shapes)
|
||||
|
||||
is-restorable-variant?
|
||||
;; A shape is a restorable variant if its component is deleted, is a variant,
|
||||
;; and the variant-container in which it will be restored still exists
|
||||
(fn [shape]
|
||||
(let [component (find-component shape true)
|
||||
main (ctk/get-component-root component)
|
||||
objects (dm/get-in libraries [(:component-file shape)
|
||||
:data
|
||||
:pages-index
|
||||
(:main-instance-page component)
|
||||
:objects])
|
||||
|
||||
parent (get objects (:parent-id main))]
|
||||
(and (:deleted component) (ctk/is-variant? component) parent)))
|
||||
|
||||
restorable-variants? (and variants?
|
||||
(every? is-restorable-variant? restorable-copies))
|
||||
|
||||
do-detach-component
|
||||
#(st/emit! (dwl/detach-components (map :id copies)))
|
||||
|
||||
|
@ -464,7 +483,10 @@
|
|||
{:title (tr "workspace.shape.menu.reset-overrides")
|
||||
:action do-reset-component})
|
||||
(when (seq restorable-copies)
|
||||
{:title (tr "workspace.shape.menu.restore-main")
|
||||
{:title
|
||||
(if restorable-variants?
|
||||
(tr "workspace.shape.menu.restore-variant")
|
||||
(tr "workspace.shape.menu.restore-main"))
|
||||
:action do-restore-component})
|
||||
(when can-show-component?
|
||||
{:title (tr "workspace.shape.menu.show-main")
|
||||
|
|
|
@ -756,7 +756,9 @@
|
|||
|
||||
(when (and can-swap? (not multi))
|
||||
[:div {:class (stl/css :component-parent-name)}
|
||||
(cfh/merge-path-item-with-dot path (:name component))])]]
|
||||
(if (:deleted component)
|
||||
(tr "workspace.options.component.unlinked")
|
||||
(cfh/merge-path-item-with-dot path (:name component)))])]]
|
||||
|
||||
(when show-menu?
|
||||
[:div {:class (stl/css :component-actions)}
|
||||
|
@ -776,7 +778,11 @@
|
|||
(when (and (not swap-opened?) (not multi))
|
||||
[:& component-annotation {:id id :shape shape :component component :rerender-fn rerender-fn}])
|
||||
|
||||
(when (and is-variant? (not main-instance?) (not swap-opened?) (not multi))
|
||||
(when (and is-variant?
|
||||
(not main-instance?)
|
||||
(not (:deleted component))
|
||||
(not swap-opened?)
|
||||
(not multi))
|
||||
[:> component-variant* {:component component
|
||||
:shape shape
|
||||
:data data}])
|
||||
|
|
|
@ -5177,6 +5177,9 @@ msgstr "Annotation"
|
|||
msgid "workspace.options.component.copy"
|
||||
msgstr "Copy"
|
||||
|
||||
msgid "workspace.options.component.unlinked"
|
||||
msgstr "Unlinked"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:180
|
||||
msgid "workspace.options.component.create-annotation"
|
||||
msgstr "Create an annotation"
|
||||
|
@ -6626,6 +6629,9 @@ msgstr "Reset overrides"
|
|||
msgid "workspace.shape.menu.restore-main"
|
||||
msgstr "Restore main component"
|
||||
|
||||
msgid "workspace.shape.menu.restore-variant"
|
||||
msgstr "Restore variant"
|
||||
|
||||
#: src/app/main/ui/workspace/context_menu.cljs:247
|
||||
msgid "workspace.shape.menu.select-layer"
|
||||
msgstr "Select layer"
|
||||
|
|
|
@ -5203,6 +5203,9 @@ msgstr "Nota"
|
|||
msgid "workspace.options.component.copy"
|
||||
msgstr "Copia"
|
||||
|
||||
msgid "workspace.options.component.unlinked"
|
||||
msgstr "Desvinculado"
|
||||
|
||||
#: src/app/main/ui/workspace/sidebar/options/menus/component.cljs:180
|
||||
msgid "workspace.options.component.create-annotation"
|
||||
msgstr "Crear una nota"
|
||||
|
@ -6656,6 +6659,9 @@ msgstr "Deshacer modificaciones"
|
|||
msgid "workspace.shape.menu.restore-main"
|
||||
msgstr "Restaurar componente principal"
|
||||
|
||||
msgid "workspace.shape.menu.restore-variant"
|
||||
msgstr "Restaurar variante"
|
||||
|
||||
#: src/app/main/ui/workspace/context_menu.cljs:247
|
||||
msgid "workspace.shape.menu.select-layer"
|
||||
msgstr "Seleccionar capa"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue