From 1f0e470419331cecb37ce6b76bc9e3f2f67b3e56 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 20 Jan 2025 11:06:25 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Revert=20":tada:=20Add=20A/B=20test=20of=20?= =?UTF-8?q?use=20of=20boards=20if=20we=20just=20change=20the=20icon=20for?= =?UTF-8?q?=20=E2=80=9Cstandard=E2=80=9D=20one"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0c586551c4810085aeb466a53c873755d2e8b5ad. --- frontend/resources/images/icons/board-2.svg | 3 --- frontend/src/app/main/ui/components/shape_icon.cljs | 5 ++--- frontend/src/app/main/ui/icons.cljs | 1 - frontend/src/app/main/ui/workspace/sidebar/history.cljs | 3 +-- frontend/src/app/main/ui/workspace/sidebar/layers.cljs | 3 +-- frontend/src/app/main/ui/workspace/top_toolbar.cljs | 3 +-- 6 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 frontend/resources/images/icons/board-2.svg diff --git a/frontend/resources/images/icons/board-2.svg b/frontend/resources/images/icons/board-2.svg deleted file mode 100644 index 70a44ea15..000000000 --- a/frontend/resources/images/icons/board-2.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/frontend/src/app/main/ui/components/shape_icon.cljs b/frontend/src/app/main/ui/components/shape_icon.cljs index 86ce8f3bf..060213681 100644 --- a/frontend/src/app/main/ui/components/shape_icon.cljs +++ b/frontend/src/app/main/ui/components/shape_icon.cljs @@ -9,7 +9,6 @@ [app.common.types.component :as ctk] [app.common.types.shape :as cts] [app.common.types.shape.layout :as ctl] - [app.config :as cf] [app.main.ui.icons :as i] [rumext.v2 :as mf])) @@ -32,7 +31,7 @@ i/flex-grid :else - (if (cf/external-feature-flag "boards-01" "test") i/board-2 i/board)) + i/board) ;; TODO -> THUMBNAIL ICON :image i/img :line (if (cts/has-images? shape) i/img i/path) @@ -57,7 +56,7 @@ (if main-instance? i/component (case type - :frame (if (cf/external-feature-flag "boards-01" "test") i/board-2 i/board) + :frame i/board :image i/img :shape i/path :text i/text diff --git a/frontend/src/app/main/ui/icons.cljs b/frontend/src/app/main/ui/icons.cljs index 29b057557..c73c7d1bd 100644 --- a/frontend/src/app/main/ui/icons.cljs +++ b/frontend/src/app/main/ui/icons.cljs @@ -63,7 +63,6 @@ (def ^:icon arrow (icon-xref :arrow)) (def ^:icon asc-sort (icon-xref :asc-sort)) (def ^:icon board (icon-xref :board)) -(def ^:icon board-2 (icon-xref :board-2)) (def ^:icon boards-thumbnail (icon-xref :boards-thumbnail)) (def ^:icon boolean-difference (icon-xref :boolean-difference)) (def ^:icon boolean-exclude (icon-xref :boolean-exclude)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/history.cljs b/frontend/src/app/main/ui/workspace/sidebar/history.cljs index 753c99c3c..618e397b0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/history.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/history.cljs @@ -9,7 +9,6 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] - [app.config :as cf] [app.main.data.workspace.undo :as dwu] [app.main.refs :as refs] [app.main.store :as st] @@ -155,7 +154,7 @@ :circle i/elipse :text i/text :path i/path - :frame (if (cf/external-feature-flag "boards-01" "test") i/board-2 i/board) + :frame i/board :group i/group :color i/drop-icon :typography i/text-palette diff --git a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs index 9dd8d234a..88f3c4601 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs @@ -12,7 +12,6 @@ [app.common.files.helpers :as cfh] [app.common.types.shape :as cts] [app.common.uuid :as uuid] - [app.config :as cf] [app.main.data.workspace :as dw] [app.main.refs :as refs] [app.main.store :as st] @@ -336,7 +335,7 @@ :on-click add-filter} [:div {:class (stl/css :filter-menu-item-name-wrapper)} [:span {:class (stl/css :filter-menu-item-icon)} - (if (cf/external-feature-flag "boards-01" "test") i/board-2 i/board)] + i/board] [:span {:class (stl/css :filter-menu-item-name)} (tr "workspace.sidebar.layers.frames")]] diff --git a/frontend/src/app/main/ui/workspace/top_toolbar.cljs b/frontend/src/app/main/ui/workspace/top_toolbar.cljs index eb19fc6f7..fb9f3473c 100644 --- a/frontend/src/app/main/ui/workspace/top_toolbar.cljs +++ b/frontend/src/app/main/ui/workspace/top_toolbar.cljs @@ -10,7 +10,6 @@ [app.common.data.macros :as dm] [app.common.geom.point :as gpt] [app.common.media :as cm] - [app.config :as cf] [app.main.data.events :as ev] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] @@ -147,7 +146,7 @@ :on-click select-drawtool :data-tool "frame" :data-testid "artboard-btn"} - (if (cf/external-feature-flag "boards-01" "test") i/board-2 i/board)]] + i/board]] [:li [:button {:title (tr "workspace.toolbar.rect" (sc/get-tooltip :draw-rect)) From e2900d9012cae335ef0534db55c886c2adf5616e Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 20 Jan 2025 11:07:13 +0100 Subject: [PATCH 2/3] :tada: Change of boards icon --- frontend/resources/images/icons/board.svg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/resources/images/icons/board.svg b/frontend/resources/images/icons/board.svg index d4e8525c2..70a44ea15 100644 --- a/frontend/resources/images/icons/board.svg +++ b/frontend/resources/images/icons/board.svg @@ -1,3 +1,3 @@ - - \ No newline at end of file + + From f553fa10d841757fc040d48e68a8e96d679cbb6b Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 17 Jan 2025 15:34:21 +0100 Subject: [PATCH 3/3] :bug: Fix problem in plugins with `replaceColor` method --- CHANGES.md | 1 + frontend/src/app/plugins/api.cljs | 8 ++++--- frontend/src/app/plugins/format.cljs | 23 ++++++++++---------- frontend/src/app/plugins/library.cljs | 1 + frontend/src/app/plugins/parser.cljs | 30 +++++++++++++++++---------- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a138453cc..e8020a4ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### :bug: Bugs fixed - Fix detach when top copy is dangling and nested copy is not [Taiga #9699](https://tree.taiga.io/project/penpot/issue/9699) +- Fix problem in plugins with `replaceColor` method [#174](https://github.com/penpot/penpot-plugins/issues/174) ## 2.4.1 diff --git a/frontend/src/app/plugins/api.cljs b/frontend/src/app/plugins/api.cljs index 7bc0fd1fc..8516ca3c6 100644 --- a/frontend/src/app/plugins/api.cljs +++ b/frontend/src/app/plugins/api.cljs @@ -166,8 +166,8 @@ :replaceColor (fn [shapes old-color new-color] - (let [old-color (parser/parse-color old-color) - new-color (parser/parse-color new-color)] + (let [old-color (parser/parse-color-data old-color) + new-color (parser/parse-color-data new-color)] (cond (or (not (array? shapes)) (not (every? shape/shape-proxy? shapes))) (u/display-not-valid :replaceColor-shapes shapes) @@ -190,7 +190,9 @@ shapes-by-color (->> (ctc/extract-all-colors shapes file-id shared-libs) (group-by :attrs))] - (st/emit! (dwc/change-color-in-selected new-color (get shapes-by-color old-color) old-color)))))) + + (when-let [operations (get shapes-by-color old-color)] + (st/emit! (dwc/change-color-in-selected operations new-color old-color))))))) :getRoot (fn [] diff --git a/frontend/src/app/plugins/format.cljs b/frontend/src/app/plugins/format.cljs index b39f422bc..829476da0 100644 --- a/frontend/src/app/plugins/format.cljs +++ b/frontend/src/app/plugins/format.cljs @@ -128,18 +128,19 @@ ;; image?: ImageData; ;; } (defn format-color - [{:keys [id name path color opacity ref-id ref-file gradient image] :as color-data}] + [{:keys [id file-id name path color opacity ref-id ref-file gradient image] :as color-data}] (when (some? color-data) - (obj/without-empty - #js {:id (format-id id) - :name name - :path path - :color color - :opacity opacity - :refId (format-id ref-id) - :refFile (format-id ref-file) - :gradient (format-gradient gradient) - :image (format-image image)}))) + (let [id (or (format-id id) (format-id ref-id)) + file-id (or (format-id file-id) (format-id ref-file))] + (obj/without-empty + #js {:id (or (format-id id) (format-id ref-id)) + :fileId (or (format-id file-id) (format-id ref-file)) + :name name + :path path + :color color + :opacity opacity + :gradient (format-gradient gradient) + :image (format-image image)})))) ;; Color & ColorShapeInfo (defn format-color-result diff --git a/frontend/src/app/plugins/library.cljs b/frontend/src/app/plugins/library.cljs index 31241a4bf..d1dc2096f 100644 --- a/frontend/src/app/plugins/library.cljs +++ b/frontend/src/app/plugins/library.cljs @@ -48,6 +48,7 @@ :$file {:enumerable false :get (constantly file-id)} :id {:get (fn [] (dm/str id))} + :fileId {:get #(dm/str file-id)} :name {:this true diff --git a/frontend/src/app/plugins/parser.cljs b/frontend/src/app/plugins/parser.cljs index 4731528ab..8d884350d 100644 --- a/frontend/src/app/plugins/parser.cljs +++ b/frontend/src/app/plugins/parser.cljs @@ -111,28 +111,36 @@ ;; export interface Color { ;; id?: string; +;; fileId?: string; +;; refId?: string; // deprecated +;; refFile?: string; // deprecated ;; name?: string; ;; path?: string; ;; color?: string; ;; opacity?: number; -;; refId?: string; -;; refFile?: string; ;; gradient?: Gradient; ;; image?: ImageData; ;; } +(defn parse-color-data + [^js color] + (when (some? color) + (let [id (or (obj/get color "id") (obj/get color "refId")) + file-id (or (obj/get color "fileId") (obj/get color "refFile"))] + (d/without-nils + {:id (parse-id id) + :file-id (parse-id file-id) + :color (-> (obj/get color "color") parse-hex) + :opacity (obj/get color "opacity") + :gradient (-> (obj/get color "gradient") parse-gradient) + :image (-> (obj/get color "image") parse-image-data)})))) + (defn parse-color [^js color] (when (some? color) (d/without-nils - {:id (-> (obj/get color "id") parse-id) - :name (obj/get color "name") - :path (obj/get color "path") - :color (-> (obj/get color "color") parse-hex) - :opacity (obj/get color "opacity") - :ref-id (-> (obj/get color "refId") parse-id) - :ref-file (-> (obj/get color "refFile") parse-id) - :gradient (-> (obj/get color "gradient") parse-gradient) - :image (-> (obj/get color "image") parse-image-data)}))) + (-> (parse-color-data color) + (assoc :name (obj/get color "name") + :path (obj/get color "path")))))) ;; export interface Shadow { ;; id?: string;