mirror of
https://github.com/penpot/penpot.git
synced 2025-05-05 19:25:53 +02:00
Fix renaming token creating new token
This commit is contained in:
parent
4b39b6970a
commit
231baac31d
2 changed files with 10 additions and 10 deletions
|
@ -210,7 +210,7 @@
|
||||||
(wtu/update-workspace-tokens))))))
|
(wtu/update-workspace-tokens))))))
|
||||||
|
|
||||||
(defn update-create-token
|
(defn update-create-token
|
||||||
[token]
|
[{:keys [token prev-token-name]}]
|
||||||
(ptk/reify ::update-create-token
|
(ptk/reify ::update-create-token
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
(->> (ctob/make-token-set :name token-set-name :tokens {(:name token) token})
|
(->> (ctob/make-token-set :name token-set-name :tokens {(:name token) token})
|
||||||
(pcb/add-token-set (pcb/empty-changes)))
|
(pcb/add-token-set (pcb/empty-changes)))
|
||||||
;; Either update or add token to existing set
|
;; Either update or add token to existing set
|
||||||
(if-let [prev-token (ctob/get-token token-set (:name token))]
|
(if-let [prev-token (ctob/get-token token-set (or prev-token-name (:name token)))]
|
||||||
(pcb/update-token (pcb/empty-changes) (:name token-set) token prev-token)
|
(pcb/update-token (pcb/empty-changes) (:name token-set) token prev-token)
|
||||||
(pcb/add-token (pcb/empty-changes) (:name token-set) token)))]
|
(pcb/add-token (pcb/empty-changes) (:name token-set) token)))]
|
||||||
(rx/of
|
(rx/of
|
||||||
|
@ -251,7 +251,7 @@
|
||||||
(ctob/get-token token-name)
|
(ctob/get-token token-name)
|
||||||
(update :name #(str/concat % "-copy")))]
|
(update :name #(str/concat % "-copy")))]
|
||||||
(rx/of
|
(rx/of
|
||||||
(update-create-token token))))))
|
(update-create-token {:token token}))))))
|
||||||
|
|
||||||
(defn set-token-type-section-open
|
(defn set-token-type-section-open
|
||||||
[token-type open?]
|
[token-type open?]
|
||||||
|
|
|
@ -317,13 +317,13 @@ Token names should only contain letters and digits separated by . characters.")}
|
||||||
;; The result should be a vector of all resolved validations
|
;; The result should be a vector of all resolved validations
|
||||||
;; We do not handle the error case as it will be handled by the components validations
|
;; We do not handle the error case as it will be handled by the components validations
|
||||||
(when (and (seq result) (not err))
|
(when (and (seq result) (not err))
|
||||||
(let [new-token (ctob/make-token :name final-name
|
(st/emit! (dt/update-create-token {:token (ctob/make-token :name final-name
|
||||||
:type (or (:type token) token-type)
|
:type (or (:type token) token-type)
|
||||||
:value final-value
|
:value final-value
|
||||||
:description final-description)]
|
:description final-description)
|
||||||
(st/emit! (dt/update-create-token new-token))
|
:prev-token-name (:name token)}))
|
||||||
(st/emit! (wtu/update-workspace-tokens))
|
(st/emit! (wtu/update-workspace-tokens))
|
||||||
(modal/hide!)))))))))]
|
(modal/hide!))))))))]
|
||||||
[:form
|
[:form
|
||||||
{:class (stl/css :form-wrapper)
|
{:class (stl/css :form-wrapper)
|
||||||
:on-submit on-submit}
|
:on-submit on-submit}
|
||||||
|
|
Loading…
Add table
Reference in a new issue