mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 23:48:42 +00:00
✨ Add several minor enhacements to features subsystem
Mainly fixes the team non-inheritable features handling and removes unnecesary/duplicate checks.
This commit is contained in:
parent
1d54fe2e24
commit
0346c48b03
@ -112,14 +112,15 @@
|
|||||||
;; FIXME: IMPORTANT: this code can have race conditions, because
|
;; FIXME: IMPORTANT: this code can have race conditions, because
|
||||||
;; we have no locks for updating team so, creating two files
|
;; we have no locks for updating team so, creating two files
|
||||||
;; concurrently can lead to lost team features updating
|
;; concurrently can lead to lost team features updating
|
||||||
|
|
||||||
(when-let [features (-> features
|
(when-let [features (-> features
|
||||||
(set/difference (:features team))
|
(set/difference (:features team))
|
||||||
(set/difference cfeat/no-team-inheritable-features)
|
(set/difference cfeat/no-team-inheritable-features)
|
||||||
(not-empty))]
|
(not-empty))]
|
||||||
(let [features (->> features
|
(let [features (-> features
|
||||||
(set/union (:features team))
|
(set/union (:features team))
|
||||||
(db/create-array conn "text"))]
|
(set/difference cfeat/no-team-inheritable-features)
|
||||||
|
(into-array))]
|
||||||
|
|
||||||
(db/update! conn :team
|
(db/update! conn :team
|
||||||
{:features features}
|
{:features features}
|
||||||
{:id (:id team)}
|
{:id (:id team)}
|
||||||
|
|||||||
@ -158,7 +158,6 @@
|
|||||||
|
|
||||||
tpoint (ct/tpoint)]
|
tpoint (ct/tpoint)]
|
||||||
|
|
||||||
|
|
||||||
(when (not= (:vern params)
|
(when (not= (:vern params)
|
||||||
(:vern file))
|
(:vern file))
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
@ -181,15 +180,15 @@
|
|||||||
(set/difference (:features team))
|
(set/difference (:features team))
|
||||||
(set/difference cfeat/no-team-inheritable-features)
|
(set/difference cfeat/no-team-inheritable-features)
|
||||||
(not-empty))]
|
(not-empty))]
|
||||||
(let [features (->> features
|
(let [features (-> features
|
||||||
(set/union (:features team))
|
(set/union (:features team))
|
||||||
(db/create-array conn "text"))]
|
(set/difference cfeat/no-team-inheritable-features)
|
||||||
|
(into-array))]
|
||||||
(db/update! conn :team
|
(db/update! conn :team
|
||||||
{:features features}
|
{:features features}
|
||||||
{:id (:id team)}
|
{:id (:id team)}
|
||||||
{::db/return-keys false})))
|
{::db/return-keys false})))
|
||||||
|
|
||||||
|
|
||||||
(mtx/run! metrics {:id :update-file-changes :inc (count changes)})
|
(mtx/run! metrics {:id :update-file-changes :inc (count changes)})
|
||||||
|
|
||||||
(binding [l/*context* (some-> (meta params)
|
(binding [l/*context* (some-> (meta params)
|
||||||
|
|||||||
@ -503,7 +503,7 @@
|
|||||||
|
|
||||||
(let [features (-> (cfeat/get-enabled-features cf/flags)
|
(let [features (-> (cfeat/get-enabled-features cf/flags)
|
||||||
(set/difference cfeat/frontend-only-features)
|
(set/difference cfeat/frontend-only-features)
|
||||||
(cfeat/check-client-features! (:features params)))
|
(set/difference cfeat/no-team-inheritable-features))
|
||||||
params (-> params
|
params (-> params
|
||||||
(assoc :profile-id profile-id)
|
(assoc :profile-id profile-id)
|
||||||
(assoc :features features))
|
(assoc :features features))
|
||||||
|
|||||||
@ -68,11 +68,6 @@
|
|||||||
"design-tokens/v1"
|
"design-tokens/v1"
|
||||||
"variants/v1"})
|
"variants/v1"})
|
||||||
|
|
||||||
;; A set of features that should not be propagated to team on creating
|
|
||||||
;; or modifying a file
|
|
||||||
(def no-team-inheritable-features
|
|
||||||
#{"fdata/path-data"})
|
|
||||||
|
|
||||||
;; A set of features which only affects on frontend and can be enabled
|
;; A set of features which only affects on frontend and can be enabled
|
||||||
;; and disabled freely by the user any time. This features does not
|
;; and disabled freely by the user any time. This features does not
|
||||||
;; persist on file features field but can be permanently enabled on
|
;; persist on file features field but can be permanently enabled on
|
||||||
@ -87,8 +82,14 @@
|
|||||||
;; Features that are mainly backend only or there are a proper
|
;; Features that are mainly backend only or there are a proper
|
||||||
;; fallback when frontend reports no support for it
|
;; fallback when frontend reports no support for it
|
||||||
(def backend-only-features
|
(def backend-only-features
|
||||||
#{"fdata/objects-map"
|
#{"fdata/pointer-map"
|
||||||
"fdata/pointer-map"})
|
"fdata/objects-map"})
|
||||||
|
|
||||||
|
;; A set of features that should not be propagated to team on creating
|
||||||
|
;; or modifying a file or creating or modifying a team
|
||||||
|
(def no-team-inheritable-features
|
||||||
|
#{"fdata/path-data"
|
||||||
|
"fdata/shape-data-type"})
|
||||||
|
|
||||||
;; This is a set of features that does not require an explicit
|
;; This is a set of features that does not require an explicit
|
||||||
;; migration like components/v2 or the migration is not mandatory to
|
;; migration like components/v2 or the migration is not mandatory to
|
||||||
@ -226,8 +227,6 @@
|
|||||||
:hint (str/ffmt "enabled feature '%' not present in file (missing migration)"
|
:hint (str/ffmt "enabled feature '%' not present in file (missing migration)"
|
||||||
not-supported)))
|
not-supported)))
|
||||||
|
|
||||||
(check-supported-features! file-features)
|
|
||||||
|
|
||||||
;; Components v1 is deprecated
|
;; Components v1 is deprecated
|
||||||
(when-not (contains? file-features "components/v2")
|
(when-not (contains? file-features "components/v2")
|
||||||
(ex/raise :type :restriction
|
(ex/raise :type :restriction
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user