From b30cb0e0848de8266d95cd5c914a19dfcd59a3ef Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 10:28:00 +0200 Subject: [PATCH] :sparkles: Allow pass variant related attrs on add-component change --- common/src/app/common/files/changes.cljc | 8 ++++++-- common/src/app/common/types/components_list.cljc | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 73f48f5661..62810a0e02 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -320,14 +320,18 @@ [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:path {:optional true} :string] [:main-instance-id ::sm/uuid] - [:main-instance-page ::sm/uuid]]] + [:main-instance-page ::sm/uuid] + ;; Only used by external processes (like Penpot SDK) + [:variant-id {:optional true} ::sm/uuid] + [:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]] [:mod-component [:map {:title "ModCompoenentChange"} [:type [:= :mod-component]] [:id ::sm/uuid] - [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:name {:optional true} :string] + [:path {:optional true} :string] + [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:variant-id {:optional true} ::sm/uuid] [:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]] diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index fd75341681..68d8e72ef0 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -35,7 +35,7 @@ (defn add-component [fdata {:keys [id name path main-instance-id main-instance-page annotation variant-id variant-properties]}] - (let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))] + (let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))] (cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page) annotation (update-in [:components id] assoc :annotation annotation) variant-id (update-in [:components id] assoc :variant-id variant-id) @@ -83,9 +83,11 @@ (nil? variant-properties) (dissoc :variant-properties)) + + ;; The set of properties that doesn't mark a component as touched diff (set/difference (ctk/diff-components component new-comp) - #{:annotation :modified-at :variant-id :variant-properties})] ;; The set of properties that doesn't mark a component as touched + #{:annotation :modified-at :variant-id :variant-properties})] (if (empty? diff) new-comp