From c2360916452354186f97740fba078419fa0f3d34 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 11 Dec 2023 13:41:56 +0100 Subject: [PATCH 1/4] :bug: Fix a copy inside a copy shouldn't be able to do an Update Main --- frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs index 53cd48ac65..43d329737a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/common.cljs @@ -13,6 +13,7 @@ [app.common.spec :as us] [app.common.thumbnails :as thc] [app.common.types.component :as ctk] + [app.common.types.container :as ctn] [app.common.types.file :as ctf] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] @@ -354,6 +355,7 @@ (not is-dangling?) (or (not components-v2) (and (not main-instance?) + (not (ctn/has-any-copy-parent? objects shape)) (cfh/component-touched? objects (:id shape))))) From b41f63c16e1f54e2d2c2edfdeae2ae20a09c53f7 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 11 Dec 2023 19:13:54 +0100 Subject: [PATCH 2/4] :bug: Fix component restoration is not notified to files using the library --- backend/src/app/rpc/commands/files_update.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app/rpc/commands/files_update.clj b/backend/src/app/rpc/commands/files_update.clj index 6026db5c16..d5bffab98c 100644 --- a/backend/src/app/rpc/commands/files_update.clj +++ b/backend/src/app/rpc/commands/files_update.clj @@ -74,7 +74,7 @@ (def ^:private library-change-types #{:add-color :mod-color :del-color :add-media :mod-media :del-media - :add-component :mod-component :del-component + :add-component :mod-component :del-component :restore-component :add-typography :mod-typography :del-typography}) (def ^:private file-change-types From f213992c0947ebf218cc0162f9c85f0a130c0b30 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 13 Dec 2023 13:01:42 +0100 Subject: [PATCH 3/4] :bug: Show component name in copies component panel for deleted ones --- .../app/main/ui/workspace/sidebar/options/menus/component.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 880ac18e83..c000ac90c8 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 @@ -428,7 +428,7 @@ shape (first shapes) id (:id shape) shape-name (:name shape) - component (ctf/resolve-component shape {:id current-file-id :data workspace-data} workspace-libraries) + component (ctf/resolve-component shape {:id current-file-id :data workspace-data} workspace-libraries {:include-deleted? true}) main-instance? (if components-v2 (ctk/main-instance? shape) true) toggle-content From f5904cee5983f7a7098e3a678528b9c2c453d4ba Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 13 Dec 2023 16:49:32 +0100 Subject: [PATCH 4/4] :bug: Validate and repair also orphan shapes --- common/src/app/common/files/validate.cljc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 23daff25d1..4864bbc418 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -474,7 +474,14 @@ [{:keys [data features] :as file} libraries] (when (contains? features "components/v2") (doseq [page (filter :id (ctpl/pages-seq data))] - (validate-shape! uuid/zero file page libraries)) + (let [orphans (->> page + :objects + vals + (filter #(not (contains? (:objects page) (:parent-id %)))) + (map :id))] + (validate-shape! uuid/zero file page libraries) + (doseq [shape-id orphans] + (validate-shape! shape-id file page libraries)))) (doseq [component (vals (:components data))] (validate-component! component file)))