From f4482eb5a7896a35a8ad7572b0ae6a38483cbfd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Fri, 29 Jul 2022 10:54:52 +0200 Subject: [PATCH] :sparkles: Allow to set features by config file --- frontend/src/app/config.cljs | 6 ++++++ frontend/src/app/main/features.cljs | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 1de776e7c..a9e99252b 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -63,6 +63,11 @@ flags (sequence (map keyword) (str/words 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 [global] (-> (obj/get global "penpotVersion") @@ -88,6 +93,7 @@ (def build-date (parse-build-date global)) (def flags (atom (parse-flags global))) +(def features (atom (parse-features global))) (def version (atom (parse-version global))) (def target (atom (parse-target global))) (def browser (atom (parse-browser))) diff --git a/frontend/src/app/main/features.cljs b/frontend/src/app/main/features.cljs index 236314cb8..5239bdd39 100644 --- a/frontend/src/app/main/features.cljs +++ b/frontend/src/app/main/features.cljs @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.logging :as log] + [app.config :as cfg] [app.main.store :as st] [okulary.core :as l] [potok.core :as ptk] @@ -27,7 +28,6 @@ :result (if (not (contains? (:features state) feature)) "enabled" "disabled")) - (-> state (update :features (fn [features] @@ -62,8 +62,14 @@ active-feature? (mf/deref active-feature-ref)] active-feature?)) -;; By default the features are active in local environments -(when *assert* - ;; Activate all features in local environment - (doseq [f features-list] - (toggle-feature! f))) +;; Read initial enabled features from config, if set +(if-let [enabled-features @cfg/features] + (doseq [f enabled-features] + (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))))) +