mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
🐛 Remove the usage of namespaced keywords on toplevel global state
Because debuging the global state value becomes dificult when exist a name clash on namespaced keywords and not namespaced keywords.
This commit is contained in:
parent
51c6abb261
commit
b3fcbd91e4
1 changed files with 12 additions and 12 deletions
|
@ -26,16 +26,16 @@
|
||||||
|
|
||||||
(defn get-enabled-features
|
(defn get-enabled-features
|
||||||
[state]
|
[state]
|
||||||
(-> (get state :features/runtime #{})
|
(-> (get state :features-runtime #{})
|
||||||
(set/intersection cfeat/no-migration-features)
|
(set/intersection cfeat/no-migration-features)
|
||||||
(set/union global-enabled-features)))
|
(set/union global-enabled-features)))
|
||||||
|
|
||||||
(defn get-team-enabled-features
|
(defn get-team-enabled-features
|
||||||
[state]
|
[state]
|
||||||
(-> global-enabled-features
|
(-> global-enabled-features
|
||||||
(set/union (:features/runtime state #{}))
|
(set/union (:features-runtime state #{}))
|
||||||
(set/intersection cfeat/no-migration-features)
|
(set/intersection cfeat/no-migration-features)
|
||||||
(set/union (:features/team state #{}))))
|
(set/union (:features-team state #{}))))
|
||||||
|
|
||||||
(def features-ref
|
(def features-ref
|
||||||
(l/derived get-team-enabled-features st/state =))
|
(l/derived get-team-enabled-features st/state =))
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
"Given a state and feature, check if feature is enabled"
|
"Given a state and feature, check if feature is enabled"
|
||||||
[state feature]
|
[state feature]
|
||||||
(assert (contains? cfeat/supported-features feature) "not supported feature")
|
(assert (contains? cfeat/supported-features feature) "not supported feature")
|
||||||
(or (contains? (get state :features/runtime) feature)
|
(or (contains? (get state :features-runtime) feature)
|
||||||
(if (contains? cfeat/no-migration-features feature)
|
(if (contains? cfeat/no-migration-features feature)
|
||||||
(or (contains? global-enabled-features feature)
|
(or (contains? global-enabled-features feature)
|
||||||
(contains? (get state :features/team) feature))
|
(contains? (get state :features-team) feature))
|
||||||
(contains? (get state :features/team state) feature))))
|
(contains? (get state :features-team state) feature))))
|
||||||
|
|
||||||
(defn use-feature
|
(defn use-feature
|
||||||
"A react hook that checks if feature is currently enabled"
|
"A react hook that checks if feature is currently enabled"
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(assert (contains? cfeat/supported-features feature) "not supported feature")
|
(assert (contains? cfeat/supported-features feature) "not supported feature")
|
||||||
(update state :features/runtime (fn [features]
|
(update state :features-runtime (fn [features]
|
||||||
(if (contains? features feature)
|
(if (contains? features feature)
|
||||||
(do
|
(do
|
||||||
(log/trc :hint "feature disabled" :feature feature)
|
(log/trc :hint "feature disabled" :feature feature)
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
state
|
state
|
||||||
(do
|
(do
|
||||||
(log/trc :hint "feature enabled" :feature feature)
|
(log/trc :hint "feature enabled" :feature feature)
|
||||||
(update state :features/runtime (fnil conj #{}) feature))))))
|
(update state :features-runtime (fnil conj #{}) feature))))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
([] (initialize #{}))
|
([] (initialize #{}))
|
||||||
|
@ -102,8 +102,8 @@
|
||||||
cfeat/xf-supported-features
|
cfeat/xf-supported-features
|
||||||
team-features)]
|
team-features)]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc :features/runtime runtime-features)
|
(assoc :features-runtime runtime-features)
|
||||||
(assoc :features/team team-features))))
|
(assoc :features-team team-features))))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
|
@ -117,6 +117,6 @@
|
||||||
ptk/EffectEvent
|
ptk/EffectEvent
|
||||||
(effect [_ state _]
|
(effect [_ state _]
|
||||||
(log/trc :hint "initialized features"
|
(log/trc :hint "initialized features"
|
||||||
:team (str/join "," (:features/team state))
|
:team (str/join "," (:features-team state))
|
||||||
:runtime (str/join "," (:features/runtime state)))))))
|
:runtime (str/join "," (:features-runtime state)))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue