From 9acab2a28a778bdf38744d5e68e7d09406d543e8 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 28 Nov 2023 19:30:57 +0100 Subject: [PATCH 1/4] :bug: Validation error on making a copy of a component that contains a group on a frame --- common/src/app/common/types/container.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 5e0bb1579..a7f060391 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -345,7 +345,9 @@ update-new-shape (fn [object _] object) force-id - keep-ids?) + keep-ids? + frame-id) + ;; Fix empty parent-id and remap all grid cells to the new ids. remap-ids From f261cf6e6329aa494dae3a87936d36766b0069ff Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 28 Nov 2023 20:08:27 +0100 Subject: [PATCH 2/4] :bug: Fix bad switch paths on files migrated to v2 --- .../ui/workspace/sidebar/options/menus/component.cljs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 01dcbc9a4..9d767c60a 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 @@ -201,6 +201,7 @@ workspace-libraries (mf/deref refs/workspace-libraries) objects (mf/deref refs/workspace-page-objects) libraries (assoc workspace-libraries current-file-id (assoc workspace-file :data workspace-data)) + single-comp (ctf/get-component libraries (:component-file shape) (:component-id shape)) every-same-file? (every? #(= (:component-file shape) (:component-file %)) shapes) current-comp-id (when (every? #(= (:component-id shape) (:component-id %)) shapes) (:component-id shape)) @@ -208,10 +209,10 @@ file-id (if every-same-file? (:component-file shape) current-file-id) - paths (->> shapes - (map :name) - (map cfh/split-path) - (map butlast)) + orig-components (map #(ctf/get-component libraries (:component-file %) (:component-id %)) shapes) + paths (->> orig-components + (map :path) + (map cfh/split-path)) find-common-path (fn common-path [path n] (let [current (nth (first paths) n nil)] @@ -221,7 +222,7 @@ (common-path (conj path current) (inc n))))) path (if single? - (cfh/butlast-path (:name shape)) + (:path single-comp) (cfh/join-path (if (not every-same-file?) "" (find-common-path [] 0)))) From d30dc6b34be7f1e534d6e9869bae4b38bdfc8b97 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 28 Nov 2023 14:10:55 +0100 Subject: [PATCH 3/4] :bug: Fix cut-paste main component outside another --- .../app/main/data/workspace/libraries_helpers.cljs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index ecb34649e..6aa83d582 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -227,12 +227,23 @@ ([changes library-data component-id it page delta old-id parent-id] (let [component (ctkl/get-deleted-component library-data component-id) + parent (get-in page [:objects parent-id]) + inside-component? (some? (ctn/get-instance-root (:objects page) parent)) shapes (cfh/get-children-with-self (:objects component) (:main-instance-id component)) shapes (map #(gsh/move % delta) shapes) first-shape (cond-> (first shapes) (not (nil? parent-id)) - (assoc :parent-id parent-id)) + (assoc :parent-id parent-id) + (and parent (= :frame (:type parent))) + (assoc :frame-id parent-id) + (and parent (not= :frame (:type parent))) + (assoc :frame-id (:frame-id parent)) + inside-component? + (dissoc :component-root) + (not inside-component?) + (assoc :component-root true)) + changes (-> (or changes (pcb/empty-changes it)) (pcb/with-page page) (pcb/with-objects (:objects page)) From ac6258043e42a410936cb1dba7dcfb32f11f9ca2 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 28 Nov 2023 22:06:29 +0100 Subject: [PATCH 4/4] :bug: Fix missing empty message on swap panel --- .../main/ui/workspace/sidebar/options/menus/component.cljs | 4 ++++ .../main/ui/workspace/sidebar/options/menus/component.scss | 5 +++++ frontend/translations/en.po | 5 ++++- frontend/translations/es.po | 5 ++++- 4 files changed, 17 insertions(+), 2 deletions(-) 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 9d767c60a..880ac18e8 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 @@ -360,6 +360,10 @@ [:span i/arrow-slide] [:span (:path filters)]]) + (when (empty? items) + [:div {:class (stl/css :component-list-empty)} + (tr "workspace.options.component.swap.empty")]) + (when (:listing-thumbs? filters) [:div {:class (stl/css :component-list)} (for [item groups] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss index 9ae617d32..c5557bc2f 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.scss @@ -216,6 +216,11 @@ height: $s-16; } + .component-list-empty { + @include titleTipography; + margin: 0 $s-4 0 $s-8; + } + .component-list { margin: 0 $s-4 0 $s-8; .component-item { diff --git a/frontend/translations/en.po b/frontend/translations/en.po index ee120abc4..b2fcc11b2 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -3641,9 +3641,12 @@ msgstr "Edit an annotation" msgid "workspace.options.component.main" msgstr "Main" - msgid "workspace.options.component.swap" msgstr "Swap component" + +msgid "workspace.options.component.swap.empty" +msgstr "There are no assets in this library yet" + #: src/app/main/ui/workspace/sidebar/options/menus/measures.cljs msgid "workspace.options.constraints" msgstr "Constraints" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 046bb34a3..6a1d1c5fa 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -3706,9 +3706,12 @@ msgstr "Editar una nota" msgid "workspace.options.component.main" msgstr "Principal" - msgid "workspace.options.component.swap" msgstr "Intercambiar componente" + +msgid "workspace.options.component.swap.empty" +msgstr "Aún no hay recursos en esta biblioteca" + #: src/app/main/ui/workspace/sidebar/options/menus/measures.cljs msgid "workspace.options.constraints" msgstr "Restricciones"