0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 15:09:10 -05:00

🐛 Fix features handling on viewer

This commit is contained in:
Andrey Antukh 2023-11-16 14:09:09 +01:00 committed by Andrés Moya
parent ef9c95a0a6
commit 2e927d5640
5 changed files with 24 additions and 12 deletions

View file

@ -119,7 +119,8 @@
app.config/config config
app.loggers.audit/submit! (constantly nil)
app.auth/derive-password identity
app.auth/verify-password (fn [a b] {:valid (= a b)})]
app.auth/verify-password (fn [a b] {:valid (= a b)})
app.common.features/get-enabled-features (fn [& _] app.common.features/supported-features)]
(let [templates [{:id "test"
:name "test"

View file

@ -33,7 +33,10 @@
}]
(binding [cond/*enabled* true]
(let [{:keys [error result]} (th/command! params)]
(let [{:keys [error result] :as out} (th/command! params)]
;; NOTE: Fails on print because fipps used for pretty print
;; tries to load pointers
;; (th/print-result! out)
(t/is (nil? error))
(t/is (map? result))
(t/is (contains? (meta result) :app.http/headers))

View file

@ -117,7 +117,7 @@
Team features are defined as: all features found on team plus all
no-migration features enabled globally."
[flags team]
(let [enabled-features (into #{} xf-flag-to-feature flags)
(let [enabled-features (get-enabled-features flags)
team-features (into #{} xf-remove-ephimeral (:features team))]
(-> enabled-features
(set/intersection no-migration-features)
@ -141,7 +141,7 @@
:hint (str/ffmt "client declares no support for '%' features"
(str/join "," not-supported)))))
(let [not-supported (set/difference client-features supported-features)]
(let [not-supported (set/difference client-features enabled-features)]
(when (seq not-supported)
(ex/raise :type :restriction
:code :feature-not-supported

View file

@ -8,6 +8,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.features :as cfeat]
[app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt]
[app.common.schema :as sm]
@ -106,9 +107,13 @@
(ptk/reify ::fetch-bundle
ptk/WatchEvent
(watch [_ state _]
(let [features (features/get-team-enabled-features state)
(watch [_ _ _]
(let [;; NOTE: in viewer we don't have access to the team when
;; user is not logged-in, so we can't know which features
;; are active from team, so in this case it is necesary
;; report the whole set of supported features instead of
;; the enabled ones.
features cfeat/supported-features
params' (cond-> {:file-id file-id :features features}
(uuid? share-id)
(assoc :share-id share-id))
@ -146,8 +151,9 @@
(rx/map (fn [data]
(update bundle :file assoc :data data))))))
(rx/mapcat
(fn [{:keys [fonts] :as bundle}]
(fn [{:keys [fonts team] :as bundle}]
(rx/of (df/fonts-fetched fonts)
(features/initialize (:features team))
(bundle-fetched (merge bundle params))))))))))
(declare go-to-frame)

View file

@ -27,14 +27,16 @@
(defn get-enabled-features
[state]
(-> (get state :features/runtime #{})
(set/intersection cfeat/no-migration-features)
(set/union global-enabled-features)))
(defn get-team-enabled-features
[state]
(let [runtime-features (set/intersection (:features/runtime state #{})
cfeat/no-migration-features)]
(-> global-enabled-features
(set/union (get state :features/runtime #{}))
(set/intersection cfeat/no-migration-features)
(set/union (get state :features/team #{}))))
(set/union runtime-features)
(set/union (:features/team state #{})))))
(def features-ref
(l/derived get-team-enabled-features st/state =))