mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 20:41:37 +02:00
🐛 Prevent theme replacement on ranaming
This commit is contained in:
parent
9fb7456b38
commit
93bf198073
3 changed files with 22 additions and 19 deletions
|
@ -91,16 +91,21 @@
|
||||||
(ptk/reify ::update-token-theme
|
(ptk/reify ::update-token-theme
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [tokens-lib (get-tokens-lib state)
|
(let [data (dsh/lookup-file-data state)
|
||||||
data (dsh/lookup-file-data state)
|
tokens-lib (get data :tokens-lib)]
|
||||||
prev-token-theme (some-> tokens-lib (ctob/get-theme group name))
|
(if (and (or (not= group (:group token-theme))
|
||||||
changes (-> (pcb/empty-changes it)
|
(not= name (:name token-theme)))
|
||||||
(pcb/with-library-data data)
|
(ctob/get-theme tokens-lib
|
||||||
(pcb/set-token-theme (:group prev-token-theme)
|
(:group token-theme)
|
||||||
(:name prev-token-theme)
|
(:name token-theme)))
|
||||||
token-theme))]
|
(rx/of (ntf/show {:content (tr "errors.token-theme-already-exists")
|
||||||
(rx/of
|
:type :toast
|
||||||
(dch/commit-changes changes))))))
|
:level :error
|
||||||
|
:timeout 9000}))
|
||||||
|
(let [changes (-> (pcb/empty-changes it)
|
||||||
|
(pcb/with-library-data data)
|
||||||
|
(pcb/set-token-theme group name token-theme))]
|
||||||
|
(rx/of (dch/commit-changes changes))))))))
|
||||||
|
|
||||||
(defn toggle-token-theme-active? [group name]
|
(defn toggle-token-theme-active? [group name]
|
||||||
(ptk/reify ::toggle-token-theme-active?
|
(ptk/reify ::toggle-token-theme-active?
|
||||||
|
|
|
@ -253,7 +253,6 @@
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [team-id (:current-team-id state)
|
(let [team-id (:current-team-id state)
|
||||||
file-id (:id file)]
|
file-id (:id file)]
|
||||||
|
|
||||||
(rx/of (dwn/initialize team-id file-id)
|
(rx/of (dwn/initialize team-id file-id)
|
||||||
(dwsl/initialize-shape-layout)
|
(dwsl/initialize-shape-layout)
|
||||||
(fetch-libraries file-id))))))
|
(fetch-libraries file-id))))))
|
||||||
|
|
|
@ -308,7 +308,6 @@
|
||||||
|
|
||||||
;; Form / Modal handlers
|
;; Form / Modal handlers
|
||||||
on-back #(set-state (constantly {:type :themes-overview}))
|
on-back #(set-state (constantly {:type :themes-overview}))
|
||||||
on-submit #(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] %))
|
|
||||||
disabled? (-> (:name theme-state)
|
disabled? (-> (:name theme-state)
|
||||||
(str/trim)
|
(str/trim)
|
||||||
(str/empty?))
|
(str/empty?))
|
||||||
|
@ -320,16 +319,16 @@
|
||||||
|
|
||||||
on-save-form
|
on-save-form
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps theme-state on-submit)
|
(mf/deps theme theme-state)
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(let [theme (-> theme-state
|
(let [theme' (-> theme-state
|
||||||
(update :name str/trim)
|
(update :name str/trim)
|
||||||
(update :group str/trim)
|
(update :group str/trim)
|
||||||
(update :description str/trim))]
|
(update :description str/trim))]
|
||||||
(when-not (str/empty? (:name theme))
|
(when-not (str/empty? (:name theme))
|
||||||
(on-submit theme)))
|
(st/emit! (wdt/update-token-theme [(:group theme) (:name theme)] theme')))
|
||||||
(on-back)))
|
(on-back))))
|
||||||
|
|
||||||
close-modal
|
close-modal
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue