0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

Merge pull request #5321 from penpot/niwinz-improvements-features

 Feature flags improvements
This commit is contained in:
Alejandro 2024-11-18 15:52:20 +01:00 committed by GitHub
commit 20ea188070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 29 deletions

View file

@ -134,6 +134,16 @@
(update :data feat.fdata/process-pointers deref)
(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
[cfg project-id]
(db/get cfg :project {:id project-id}))
@ -445,8 +455,11 @@
(fn [features]
(let [features (cfeat/check-supported-features! features)]
(-> (::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)
(fval/validate-file-schema! file))

View file

@ -508,15 +508,6 @@
(update :object-id #(str/replace-first % #"^(.*?)/" (str file-id "/")))))
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
[{:keys [::db/conn ::input ::project-id ::bfc/overwrite ::name] :as system}]
@ -527,7 +518,7 @@
file-id (:id file)
file-id' (bfc/lookup-index file-id)
file (clean-features file)
file (bfc/clean-file-features file)
thumbnails (:thumbnails file)]
(when (not= file-id expected-file-id)

View file

@ -12,6 +12,7 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.features :as cfeat]
[app.common.json :as json]
[app.common.logging :as l]
[app.common.schema :as sm]
@ -55,7 +56,8 @@
[:map
[:id ::sm/uuid]
[:name :string]
[:project-id ::sm/uuid]]]]
[:project-id ::sm/uuid]
[:features ::cfeat/features]]]]
[:relations {:optional true}
[:vector
@ -203,7 +205,10 @@
(dissoc :libraries))
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
[mtype]
@ -259,7 +264,8 @@
(vswap! bfc/*state* update :files assoc file-id
{:id file-id
:project-id (:project-id file)
:name (:name file)})
:name (:name file)
:features (:features file)})
(let [file (cond-> (dissoc file :data)
(:options data)

View file

@ -111,13 +111,15 @@
;; features, because some features can be enabled
;; globally, but the team is still not migrated properly.
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
;; client; that enables the ability to enable a runtime
;; feature on frontend and make it permanent on file
features (-> (:features params #{})
(set/intersection cfeat/no-migration-features)
(set/difference cfeat/frontend-only-features)
(set/union features))
params (-> params

View file

@ -139,7 +139,8 @@
features (-> (cfeat/get-team-enabled-features cf/flags team)
(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-with-metadata (mapcat :changes) vec)

View file

@ -30,7 +30,8 @@
[app.storage :as sto]
[app.util.services :as sv]
[app.util.time :as dt]
[app.worker :as wrk]))
[app.worker :as wrk]
[clojure.set :as set]))
;; --- Helpers & Specs
@ -416,6 +417,7 @@
::quotes/profile-id profile-id})
(let [features (-> (cfeat/get-enabled-features cf/flags)
(set/difference cfeat/frontend-only-features)
(cfeat/check-client-features! (:features params)))
params (-> params
(assoc :profile-id profile-id)

View file

@ -30,6 +30,7 @@
[app.util.i18n :as i18n]
[app.util.theme :as theme]
[beicon.v2.core :as rx]
[cuerdas.core :as str]
[debug]
[features]
[potok.v2.core :as ptk]
@ -38,11 +39,11 @@
(log/setup! {:app :info})
(when (= :browser cf/target)
(log/info :message "Welcome to penpot"
:version (:full cf/version)
(log/info :version (:full cf/version)
:asserts *assert*
: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)

View file

@ -33,10 +33,13 @@
(defn get-team-enabled-features
[state]
(-> global-enabled-features
(set/union (:features-runtime state #{}))
(set/intersection cfeat/no-migration-features)
(set/union (:features-team state #{}))))
(let [runtime-features (:features-runtime state #{})
team-features (->> (:features-team state #{})
(into #{} cfeat/xf-remove-ephimeral))]
(-> global-enabled-features
(set/union runtime-features)
(set/intersection cfeat/no-migration-features)
(set/union team-features))))
(def features-ref
(l/derived get-team-enabled-features st/state =))
@ -124,9 +127,9 @@
(let [features (get-team-enabled-features state)]
(if (contains? features "render-wasm/v1")
(render.wasm/initialize true)
(render.wasm/initialize false)))
(render.wasm/initialize false))
(log/trc :hint "initialized features"
:team (str/join "," (:features-team state))
:runtime (str/join "," (:features-runtime state)))))))
(log/inf :hint "initialized"
:enabled (str/join "," features)
:runtime (str/join "," (:features-runtime state))))))))