mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
Merge pull request #5321 from penpot/niwinz-improvements-features
✨ Feature flags improvements
This commit is contained in:
commit
20ea188070
8 changed files with 48 additions and 29 deletions
|
@ -134,6 +134,16 @@
|
||||||
(update :data feat.fdata/process-pointers deref)
|
(update :data feat.fdata/process-pointers deref)
|
||||||
(update :data feat.fdata/process-objects (partial into {}))))))))
|
(update :data feat.fdata/process-objects (partial into {}))))))))
|
||||||
|
|
||||||
|
(defn clean-file-features
|
||||||
|
[file]
|
||||||
|
(update file :features (fn [features]
|
||||||
|
(if (set? features)
|
||||||
|
(-> features
|
||||||
|
(cfeat/migrate-legacy-features)
|
||||||
|
(set/difference cfeat/frontend-only-features)
|
||||||
|
(set/difference cfeat/backend-only-features))
|
||||||
|
#{}))))
|
||||||
|
|
||||||
(defn get-project
|
(defn get-project
|
||||||
[cfg project-id]
|
[cfg project-id]
|
||||||
(db/get cfg :project {:id project-id}))
|
(db/get cfg :project {:id project-id}))
|
||||||
|
@ -445,8 +455,11 @@
|
||||||
(fn [features]
|
(fn [features]
|
||||||
(let [features (cfeat/check-supported-features! features)]
|
(let [features (cfeat/check-supported-features! features)]
|
||||||
(-> (::features cfg #{})
|
(-> (::features cfg #{})
|
||||||
(set/difference cfeat/frontend-only-features)
|
(set/union features)
|
||||||
(set/union features))))))
|
;; We never want to store
|
||||||
|
;; frontend-only features on file
|
||||||
|
(set/difference cfeat/frontend-only-features))))))
|
||||||
|
|
||||||
|
|
||||||
_ (when (contains? cf/flags :file-schema-validation)
|
_ (when (contains? cf/flags :file-schema-validation)
|
||||||
(fval/validate-file-schema! file))
|
(fval/validate-file-schema! file))
|
||||||
|
|
|
@ -508,15 +508,6 @@
|
||||||
(update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/")))))
|
(update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/")))))
|
||||||
thumbnails))
|
thumbnails))
|
||||||
|
|
||||||
(defn- clean-features
|
|
||||||
[file]
|
|
||||||
(update file :features (fn [features]
|
|
||||||
(if (set? features)
|
|
||||||
(-> features
|
|
||||||
(cfeat/migrate-legacy-features)
|
|
||||||
(set/difference cfeat/backend-only-features))
|
|
||||||
#{}))))
|
|
||||||
|
|
||||||
(defmethod read-section :v1/files
|
(defmethod read-section :v1/files
|
||||||
[{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}]
|
[{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}]
|
||||||
|
|
||||||
|
@ -527,7 +518,7 @@
|
||||||
file-id (:id file)
|
file-id (:id file)
|
||||||
file-id' (bfc/lookup-index file-id)
|
file-id' (bfc/lookup-index file-id)
|
||||||
|
|
||||||
file (clean-features file)
|
file (bfc/clean-file-features file)
|
||||||
thumbnails (:thumbnails file)]
|
thumbnails (:thumbnails file)]
|
||||||
|
|
||||||
(when (not= file-id expected-file-id)
|
(when (not= file-id expected-file-id)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
|
[app.common.features :as cfeat]
|
||||||
[app.common.json :as json]
|
[app.common.json :as json]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
|
@ -55,7 +56,8 @@
|
||||||
[:map
|
[:map
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
[:name :string]
|
[:name :string]
|
||||||
[:project-id ::sm/uuid]]]]
|
[:project-id ::sm/uuid]
|
||||||
|
[:features ::cfeat/features]]]]
|
||||||
|
|
||||||
[:relations {:optional true}
|
[:relations {:optional true}
|
||||||
[:vector
|
[:vector
|
||||||
|
@ -203,7 +205,10 @@
|
||||||
(dissoc :libraries))
|
(dissoc :libraries))
|
||||||
|
|
||||||
embed-assets
|
embed-assets
|
||||||
(update :data #(bfc/embed-assets cfg % file-id)))))
|
(update :data #(bfc/embed-assets cfg % file-id))
|
||||||
|
|
||||||
|
:always
|
||||||
|
(bfc/clean-file-features))))
|
||||||
|
|
||||||
(defn- resolve-extension
|
(defn- resolve-extension
|
||||||
[mtype]
|
[mtype]
|
||||||
|
@ -259,7 +264,8 @@
|
||||||
(vswap! bfc/*state* update :files assoc file-id
|
(vswap! bfc/*state* update :files assoc file-id
|
||||||
{:id file-id
|
{:id file-id
|
||||||
:project-id (:project-id file)
|
:project-id (:project-id file)
|
||||||
:name (:name file)})
|
:name (:name file)
|
||||||
|
:features (:features file)})
|
||||||
|
|
||||||
(let [file (cond-> (dissoc file :data)
|
(let [file (cond-> (dissoc file :data)
|
||||||
(:options data)
|
(:options data)
|
||||||
|
|
|
@ -111,13 +111,15 @@
|
||||||
;; features, because some features can be enabled
|
;; features, because some features can be enabled
|
||||||
;; globally, but the team is still not migrated properly.
|
;; globally, but the team is still not migrated properly.
|
||||||
features (-> (cfeat/get-team-enabled-features cf/flags team)
|
features (-> (cfeat/get-team-enabled-features cf/flags team)
|
||||||
(cfeat/check-client-features! (:features params)))
|
(cfeat/check-client-features! (:features params))
|
||||||
|
(set/difference cfeat/frontend-only-features))
|
||||||
|
|
||||||
;; We also include all no migration features declared by
|
;; We also include all no migration features declared by
|
||||||
;; client; that enables the ability to enable a runtime
|
;; client; that enables the ability to enable a runtime
|
||||||
;; feature on frontend and make it permanent on file
|
;; feature on frontend and make it permanent on file
|
||||||
features (-> (:features params #{})
|
features (-> (:features params #{})
|
||||||
(set/intersection cfeat/no-migration-features)
|
(set/intersection cfeat/no-migration-features)
|
||||||
|
(set/difference cfeat/frontend-only-features)
|
||||||
(set/union features))
|
(set/union features))
|
||||||
|
|
||||||
params (-> params
|
params (-> params
|
||||||
|
|
|
@ -139,7 +139,8 @@
|
||||||
|
|
||||||
features (-> (cfeat/get-team-enabled-features cf/flags team)
|
features (-> (cfeat/get-team-enabled-features cf/flags team)
|
||||||
(cfeat/check-client-features! (:features params))
|
(cfeat/check-client-features! (:features params))
|
||||||
(cfeat/check-file-features! (:features file) (:features params)))
|
(cfeat/check-file-features! (:features file) (:features params))
|
||||||
|
(set/difference cfeat/frontend-only-features))
|
||||||
|
|
||||||
changes (if changes-with-metadata
|
changes (if changes-with-metadata
|
||||||
(->> changes-with-metadata (mapcat :changes) vec)
|
(->> changes-with-metadata (mapcat :changes) vec)
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
[app.storage :as sto]
|
[app.storage :as sto]
|
||||||
[app.util.services :as sv]
|
[app.util.services :as sv]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.worker :as wrk]))
|
[app.worker :as wrk]
|
||||||
|
[clojure.set :as set]))
|
||||||
|
|
||||||
;; --- Helpers & Specs
|
;; --- Helpers & Specs
|
||||||
|
|
||||||
|
@ -416,6 +417,7 @@
|
||||||
::quotes/profile-id profile-id})
|
::quotes/profile-id profile-id})
|
||||||
|
|
||||||
(let [features (-> (cfeat/get-enabled-features cf/flags)
|
(let [features (-> (cfeat/get-enabled-features cf/flags)
|
||||||
|
(set/difference cfeat/frontend-only-features)
|
||||||
(cfeat/check-client-features! (:features params)))
|
(cfeat/check-client-features! (:features params)))
|
||||||
params (-> params
|
params (-> params
|
||||||
(assoc :profile-id profile-id)
|
(assoc :profile-id profile-id)
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
[app.util.i18n :as i18n]
|
[app.util.i18n :as i18n]
|
||||||
[app.util.theme :as theme]
|
[app.util.theme :as theme]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[debug]
|
[debug]
|
||||||
[features]
|
[features]
|
||||||
[potok.v2.core :as ptk]
|
[potok.v2.core :as ptk]
|
||||||
|
@ -38,11 +39,11 @@
|
||||||
(log/setup! {:app :info})
|
(log/setup! {:app :info})
|
||||||
|
|
||||||
(when (= :browser cf/target)
|
(when (= :browser cf/target)
|
||||||
(log/info :message "Welcome to penpot"
|
(log/info :version (:full cf/version)
|
||||||
:version (:full cf/version)
|
|
||||||
:asserts *assert*
|
:asserts *assert*
|
||||||
:build-date cf/build-date
|
:build-date cf/build-date
|
||||||
:public-uri (dm/str cf/public-uri)))
|
:public-uri (dm/str cf/public-uri))
|
||||||
|
(log/info :flags (str/join "," (map name cf/flags))))
|
||||||
|
|
||||||
(declare reinit)
|
(declare reinit)
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,13 @@
|
||||||
|
|
||||||
(defn get-team-enabled-features
|
(defn get-team-enabled-features
|
||||||
[state]
|
[state]
|
||||||
(-> global-enabled-features
|
(let [runtime-features (:features-runtime state #{})
|
||||||
(set/union (:features-runtime state #{}))
|
team-features (->> (:features-team state #{})
|
||||||
(set/intersection cfeat/no-migration-features)
|
(into #{} cfeat/xf-remove-ephimeral))]
|
||||||
(set/union (:features-team state #{}))))
|
(-> global-enabled-features
|
||||||
|
(set/union runtime-features)
|
||||||
|
(set/intersection cfeat/no-migration-features)
|
||||||
|
(set/union team-features))))
|
||||||
|
|
||||||
(def features-ref
|
(def features-ref
|
||||||
(l/derived get-team-enabled-features st/state =))
|
(l/derived get-team-enabled-features st/state =))
|
||||||
|
@ -124,9 +127,9 @@
|
||||||
(let [features (get-team-enabled-features state)]
|
(let [features (get-team-enabled-features state)]
|
||||||
(if (contains? features "render-wasm/v1")
|
(if (contains? features "render-wasm/v1")
|
||||||
(render.wasm/initialize true)
|
(render.wasm/initialize true)
|
||||||
(render.wasm/initialize false)))
|
(render.wasm/initialize false))
|
||||||
|
|
||||||
(log/trc :hint "initialized features"
|
(log/inf :hint "initialized"
|
||||||
:team (str/join "," (:features-team state))
|
:enabled (str/join "," features)
|
||||||
:runtime (str/join "," (:features-runtime state)))))))
|
:runtime (str/join "," (:features-runtime state))))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue