mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05: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))))))
|
||||
|
||||
(defn update-create-token
|
||||
[token]
|
||||
[{:keys [token prev-token-name]}]
|
||||
(ptk/reify ::update-create-token
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -221,7 +221,7 @@
|
|||
(->> (ctob/make-token-set :name token-set-name :tokens {(:name token) token})
|
||||
(pcb/add-token-set (pcb/empty-changes)))
|
||||
;; 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/add-token (pcb/empty-changes) (:name token-set) token)))]
|
||||
(rx/of
|
||||
|
@ -251,7 +251,7 @@
|
|||
(ctob/get-token token-name)
|
||||
(update :name #(str/concat % "-copy")))]
|
||||
(rx/of
|
||||
(update-create-token token))))))
|
||||
(update-create-token {:token token}))))))
|
||||
|
||||
(defn set-token-type-section-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
|
||||
;; We do not handle the error case as it will be handled by the components validations
|
||||
(when (and (seq result) (not err))
|
||||
(let [new-token (ctob/make-token :name final-name
|
||||
:type (or (:type token) token-type)
|
||||
:value final-value
|
||||
:description final-description)]
|
||||
(st/emit! (dt/update-create-token new-token))
|
||||
(st/emit! (wtu/update-workspace-tokens))
|
||||
(modal/hide!)))))))))]
|
||||
(st/emit! (dt/update-create-token {:token (ctob/make-token :name final-name
|
||||
:type (or (:type token) token-type)
|
||||
:value final-value
|
||||
:description final-description)
|
||||
:prev-token-name (:name token)}))
|
||||
(st/emit! (wtu/update-workspace-tokens))
|
||||
(modal/hide!))))))))]
|
||||
[:form
|
||||
{:class (stl/css :form-wrapper)
|
||||
:on-submit on-submit}
|
||||
|
|
Loading…
Add table
Reference in a new issue