diff --git a/CHANGES.md b/CHANGES.md index 0e2571b6d..c6ff637ed 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,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/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/auth.cljs b/frontend/src/app/main/data/auth.cljs index 740946b24..93225c506 100644 --- a/frontend/src/app/main/data/auth.cljs +++ b/frontend/src/app/main/data/auth.cljs @@ -12,6 +12,7 @@ [app.common.exceptions :as ex] [app.common.schema :as sm] [app.common.uuid :as uuid] + [app.config :as cf] [app.main.data.common :as dcm] [app.main.data.event :as ev] [app.main.data.notifications :as ntf] @@ -74,6 +75,8 @@ ptk/WatchEvent (watch [_ _ stream] + (cf/initialize-external-context-info) + (->> (rx/merge (rx/of (dp/set-profile profile) (ws/initialize) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 3461de888..39b870cec 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -193,6 +193,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/main/ui/static.cljs b/frontend/src/app/main/ui/static.cljs index 5b77a7b24..01201f1ad 100644 --- a/frontend/src/app/main/ui/static.cljs +++ b/frontend/src/app/main/ui/static.cljs @@ -478,7 +478,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)))] diff --git a/frontend/src/app/plugins/library.cljs b/frontend/src/app/plugins/library.cljs index 5e41f4d5c..506fefdac 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 []