mirror of
https://github.com/penpot/penpot.git
synced 2025-05-01 08:26:19 +02:00
Fix set renaming not being updated in themes
This commit is contained in:
parent
7c4cbe5265
commit
1d50bacfbc
2 changed files with 25 additions and 7 deletions
|
@ -882,11 +882,14 @@
|
||||||
[data {:keys [name token-set]}]
|
[data {:keys [name token-set]}]
|
||||||
(-> data
|
(-> data
|
||||||
(update :tokens-lib
|
(update :tokens-lib
|
||||||
#(-> %
|
(fn [element]
|
||||||
(ctob/ensure-tokens-lib)
|
(let [path-changed? (not= name (:name token-set))
|
||||||
(ctob/update-set name (fn [prev-set]
|
lib (-> element
|
||||||
(merge prev-set
|
(ctob/ensure-tokens-lib)
|
||||||
(dissoc token-set :tokens))))))))
|
(ctob/update-set name (fn [prev-set]
|
||||||
|
(merge prev-set (dissoc token-set :tokens)))))]
|
||||||
|
(cond-> lib
|
||||||
|
path-changed? (ctob/update-set-name name (:name token-set))))))))
|
||||||
|
|
||||||
(defmethod process-change :del-token-set
|
(defmethod process-change :del-token-set
|
||||||
[data {:keys [name]}]
|
[data {:keys [name]}]
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.common.types.tokens-lib
|
(ns app.common.types.tokens-lib
|
||||||
(:require
|
(:require
|
||||||
|
#?(:clj [app.common.fressian :as fres])
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
|
@ -13,8 +14,8 @@
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[app.common.types.token :as cto]
|
[app.common.types.token :as cto]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[cuerdas.core :as str]
|
[clojure.walk :as walk]
|
||||||
#?(:clj [app.common.fressian :as fres])))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
;; === Groups handling
|
;; === Groups handling
|
||||||
|
|
||||||
|
@ -391,6 +392,7 @@
|
||||||
(toggle-set-in-theme [_ group-name theme-name set-name] "toggle a set used / not used in a theme")
|
(toggle-set-in-theme [_ group-name theme-name set-name] "toggle a set used / not used in a theme")
|
||||||
(get-active-themes-set-names [_] "set of set names that are active in the the active themes")
|
(get-active-themes-set-names [_] "set of set names that are active in the the active themes")
|
||||||
(get-active-themes-set-tokens [_] "set of set names that are active in the the active themes")
|
(get-active-themes-set-tokens [_] "set of set names that are active in the the active themes")
|
||||||
|
(update-set-name [_ old-set-name new-set-name] "updates set name in themes")
|
||||||
(validate [_]))
|
(validate [_]))
|
||||||
|
|
||||||
(deftype TokensLib [sets set-groups themes active-themes]
|
(deftype TokensLib [sets set-groups themes active-themes]
|
||||||
|
@ -614,6 +616,19 @@
|
||||||
acc))
|
acc))
|
||||||
(d/ordered-map) (tree-seq d/ordered-map? vals themes)))
|
(d/ordered-map) (tree-seq d/ordered-map? vals themes)))
|
||||||
|
|
||||||
|
(update-set-name [_ old-set-name new-set-name]
|
||||||
|
(TokensLib. sets
|
||||||
|
set-groups
|
||||||
|
(walk/postwalk
|
||||||
|
(fn [form]
|
||||||
|
(if (instance? TokenTheme form)
|
||||||
|
(-> form
|
||||||
|
(update :sets disj old-set-name)
|
||||||
|
(update :sets conj new-set-name))
|
||||||
|
form))
|
||||||
|
themes)
|
||||||
|
active-themes))
|
||||||
|
|
||||||
(validate [_]
|
(validate [_]
|
||||||
(and (valid-token-sets? sets) ;; TODO: validate set-groups
|
(and (valid-token-sets? sets) ;; TODO: validate set-groups
|
||||||
(valid-token-themes? themes)
|
(valid-token-themes? themes)
|
||||||
|
|
Loading…
Add table
Reference in a new issue