From af03f720b0eafcf40d280e38d86fd32364a0b8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Fri, 18 Nov 2022 16:13:52 +0100 Subject: [PATCH] :sparkles: Allow to reset changes from a deleted component --- .../main/data/workspace/libraries_helpers.cljs | 6 ++++++ .../src/app/main/ui/workspace/context_menu.cljs | 10 ++++------ .../sidebar/options/menus/component.cljs | 16 +++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 565cd1b93..681ec9c34 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -18,6 +18,7 @@ [app.common.types.color :as ctc] [app.common.types.component :as ctk] [app.common.types.container :as ctn] + [app.common.types.file :as ctf] [app.common.types.shape-tree :as ctst] [app.common.types.typography :as cty] [app.main.data.workspace.groups :as dwg] @@ -453,6 +454,11 @@ component (cph/get-component libraries (:component-file shape-inst) (:component-id shape-inst)) + component (or component + (and reset? + (ctf/get-deleted-component + (get-in libraries [(:component-file shape-inst) :data]) + (:component-id shape-inst)))) shape-main (when component (ctn/get-shape component (:shape-ref shape-inst))) diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index d6f6136b9..1fab9587a 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -484,9 +484,8 @@ [:& menu-entry {:title (tr "workspace.shape.menu.detach-instance") :shortcut (sc/get-tooltip :detach-component) :on-click do-detach-component}] - ;; This is commented due this functionality is not yet available - ;; [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") - ;; :on-click do-reset-component}] + [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") + :on-click do-reset-component}] (when components-v2 [:& menu-entry {:title (tr "workspace.shape.menu.restore-main") :on-click do-restore-component}])] @@ -505,9 +504,8 @@ [:& menu-entry {:title (tr "workspace.shape.menu.detach-instance") :shortcut (sc/get-tooltip :detach-component) :on-click do-detach-component}] - ;; This is commented due this functionality is not yet available - ;; [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") - ;; :on-click do-reset-component}] + [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") + :on-click do-reset-component}] (when components-v2 [:& menu-entry {:title (tr "workspace.shape.menu.restore-main") :on-click do-restore-component}])] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index db16601de..392b135ea 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -106,23 +106,21 @@ (if local-component? (if is-dangling? [[(tr "workspace.shape.menu.detach-instance") do-detach-component] - ;; [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] + [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] (when components-v2 [(tr "workspace.shape.menu.restore-main") do-restore-component])] [[(tr "workspace.shape.menu.detach-instance") do-detach-component] - ;; [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] + [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] [(tr "workspace.shape.menu.update-main") do-update-component] [(tr "workspace.shape.menu.show-main") do-show-component]]) - + (if is-dangling? [[(tr "workspace.shape.menu.detach-instance") do-detach-component] - ;; [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] + [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] (when components-v2 [(tr "workspace.shape.menu.restore-main") do-restore-component])] [[(tr "workspace.shape.menu.detach-instance") do-detach-component] - ;; [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] - ;; [(tr "workspace.shape.menu.update-main") _do-update-remote-component] - [(tr "workspace.shape.menu.go-main") do-navigate-component-file] - ])))}]]]]]))) - + [(tr "workspace.shape.menu.reset-overrides") _do-reset-component] + [(tr "workspace.shape.menu.update-main") _do-update-remote-component] + [(tr "workspace.shape.menu.go-main") do-navigate-component-file]])))}]]]]])))