Allow to set features by config file

This commit is contained in:
Andrés Moya 2022-07-29 10:54:52 +02:00
parent 0667089833
commit f4482eb5a7
2 changed files with 18 additions and 6 deletions

View file

@ -63,6 +63,11 @@
flags (sequence (map keyword) (str/words flags))] flags (sequence (map keyword) (str/words flags))]
(flags/parse flags/default default-flags flags))) (flags/parse flags/default default-flags flags)))
(defn- parse-features
[global]
(when-let [features-str (obj/get global "penpotFeatures")]
(map keyword (str/words features-str))))
(defn- parse-version (defn- parse-version
[global] [global]
(-> (obj/get global "penpotVersion") (-> (obj/get global "penpotVersion")
@ -88,6 +93,7 @@
(def build-date (parse-build-date global)) (def build-date (parse-build-date global))
(def flags (atom (parse-flags global))) (def flags (atom (parse-flags global)))
(def features (atom (parse-features global)))
(def version (atom (parse-version global))) (def version (atom (parse-version global)))
(def target (atom (parse-target global))) (def target (atom (parse-target global)))
(def browser (atom (parse-browser))) (def browser (atom (parse-browser)))

View file

@ -8,6 +8,7 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.logging :as log] [app.common.logging :as log]
[app.config :as cfg]
[app.main.store :as st] [app.main.store :as st]
[okulary.core :as l] [okulary.core :as l]
[potok.core :as ptk] [potok.core :as ptk]
@ -27,7 +28,6 @@
:result (if (not (contains? (:features state) feature)) :result (if (not (contains? (:features state) feature))
"enabled" "enabled"
"disabled")) "disabled"))
(-> state (-> state
(update :features (update :features
(fn [features] (fn [features]
@ -62,8 +62,14 @@
active-feature? (mf/deref active-feature-ref)] active-feature? (mf/deref active-feature-ref)]
active-feature?)) active-feature?))
;; By default the features are active in local environments ;; Read initial enabled features from config, if set
(when *assert* (if-let [enabled-features @cfg/features]
;; Activate all features in local environment (doseq [f enabled-features]
(doseq [f features-list] (toggle-feature! f))
(toggle-feature! f))) (when *assert*
;; By default, all features disabled, except in development
;; environment, that are enabled except components-v2
(doseq [f features-list]
(when (not= f :components-v2)
(toggle-feature! f)))))