From 58dd23f9c72c10cc1dc6a4c0aa9c5d0388807aad Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 10 Jan 2025 12:15:14 +0100 Subject: [PATCH 1/3] :bug: Fix problem when changing color libraries --- CHANGES.md | 1 + .../app/main/data/workspace/libraries.cljs | 19 +++++++++++++++++++ frontend/src/app/plugins/library.cljs | 8 ++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b2811d57c..520c2af07 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### :bug: Bugs fixed - Fix error when importing files with touched components [Taiga #9625](https://tree.taiga.io/project/penpot/issue/9625) +- Fix problem when changing color libraries [Plugins #184](https://github.com/penpot/penpot-plugins/issues/184) ## 2.4.0 diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index fa16fb9a8..25893d81b 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -191,6 +191,25 @@ (watch [it state _] (update-color* it state color file-id))))) +(defn update-color-data + "Update color data without affecting the path location" + [color file-id] + (let [color (d/without-nils color)] + + (dm/assert! + "expected valid color data structure" + (ctc/check-color! color)) + + (dm/assert! + "expected file-id" + (uuid? file-id)) + + (ptk/reify ::update-color-data + ptk/WatchEvent + (watch [it state _] + (let [color (assoc color :name (dm/str (:path color) "/" (:name color)))] + (update-color* it state color file-id)))))) + (defn rename-color [file-id id new-name] (dm/assert! diff --git a/frontend/src/app/plugins/library.cljs b/frontend/src/app/plugins/library.cljs index 29b8b15b0..31241a4bf 100644 --- a/frontend/src/app/plugins/library.cljs +++ b/frontend/src/app/plugins/library.cljs @@ -98,7 +98,7 @@ :else (let [color (-> (u/proxy->library-color self) (assoc :color value))] - (st/emit! (dwl/update-color color file-id)))))} + (st/emit! (dwl/update-color-data color file-id)))))} :opacity {:this true @@ -115,7 +115,7 @@ :else (let [color (-> (u/proxy->library-color self) (assoc :opacity value))] - (st/emit! (dwl/update-color color file-id)))))} + (st/emit! (dwl/update-color-data color file-id)))))} :gradient {:this true @@ -133,7 +133,7 @@ :else (let [color (-> (u/proxy->library-color self) (assoc :gradient value))] - (st/emit! (dwl/update-color color file-id))))))} + (st/emit! (dwl/update-color-data color file-id))))))} :image {:this true @@ -151,7 +151,7 @@ :else (let [color (-> (u/proxy->library-color self) (assoc :image value))] - (st/emit! (dwl/update-color color file-id))))))} + (st/emit! (dwl/update-color-data color file-id))))))} :remove (fn [] From e380289e34a056481b47e04569ba58d6078273a6 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Fri, 10 Jan 2025 21:25:55 +0100 Subject: [PATCH 2/3] :bug: Fix feature flags not setting on login --- frontend/src/app/config.cljs | 5 +++++ frontend/src/app/main/data/users.cljs | 1 + 2 files changed, 6 insertions(+) diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index b809f7e2e..13d3e8d88 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -148,6 +148,11 @@ (let [f (obj/get global "externalContextInfo")] (when (fn? f) (f)))) +(defn initialize-external-context-info + [] + (let [f (obj/get global "initializeExternalConfigInfo")] + (when (fn? f) (f)))) + ;; --- Helper Functions (defn ^boolean check-browser? [candidate] diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 237cdde46..a8562e06c 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -207,6 +207,7 @@ ptk/WatchEvent (watch [_ _ _] (when (is-authenticated? profile) + (cf/initialize-external-context-info) (->> (rx/concat (rx/of (profile-fetched profile) (fetch-teams) From accc662e1c01b884f65733f7a521bcd65e801364 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 13 Jan 2025 19:13:36 +0100 Subject: [PATCH 3/3] :bug: Fix login is not shown on 404 --- frontend/src/app/main/ui/static.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/static.cljs b/frontend/src/app/main/ui/static.cljs index 50a3141e8..d892d0fde 100644 --- a/frontend/src/app/main/ui/static.cljs +++ b/frontend/src/app/main/ui/static.cljs @@ -476,7 +476,7 @@ request-access? (and - (= (:type data) :not-found) + (or (= (:type data) :not-found) (= (:type data) :authentication)) (or workspace? dashboard? view?) (or (:file-id info) (:team-id info)))]