mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Fix features handling on viewer
This commit is contained in:
committed by
Andrés Moya
parent
ef9c95a0a6
commit
2e927d5640
@@ -119,7 +119,8 @@
|
|||||||
app.config/config config
|
app.config/config config
|
||||||
app.loggers.audit/submit! (constantly nil)
|
app.loggers.audit/submit! (constantly nil)
|
||||||
app.auth/derive-password identity
|
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"
|
(let [templates [{:id "test"
|
||||||
:name "test"
|
:name "test"
|
||||||
|
|||||||
@@ -33,7 +33,10 @@
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
(binding [cond/*enabled* true]
|
(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 (nil? error))
|
||||||
(t/is (map? result))
|
(t/is (map? result))
|
||||||
(t/is (contains? (meta result) :app.http/headers))
|
(t/is (contains? (meta result) :app.http/headers))
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
Team features are defined as: all features found on team plus all
|
Team features are defined as: all features found on team plus all
|
||||||
no-migration features enabled globally."
|
no-migration features enabled globally."
|
||||||
[flags team]
|
[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))]
|
team-features (into #{} xf-remove-ephimeral (:features team))]
|
||||||
(-> enabled-features
|
(-> enabled-features
|
||||||
(set/intersection no-migration-features)
|
(set/intersection no-migration-features)
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
:hint (str/ffmt "client declares no support for '%' features"
|
:hint (str/ffmt "client declares no support for '%' features"
|
||||||
(str/join "," not-supported)))))
|
(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)
|
(when (seq not-supported)
|
||||||
(ex/raise :type :restriction
|
(ex/raise :type :restriction
|
||||||
:code :feature-not-supported
|
:code :feature-not-supported
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.features :as cfeat]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
@@ -106,9 +107,13 @@
|
|||||||
|
|
||||||
(ptk/reify ::fetch-bundle
|
(ptk/reify ::fetch-bundle
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ _ _]
|
||||||
(let [features (features/get-team-enabled-features state)
|
(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}
|
params' (cond-> {:file-id file-id :features features}
|
||||||
(uuid? share-id)
|
(uuid? share-id)
|
||||||
(assoc :share-id share-id))
|
(assoc :share-id share-id))
|
||||||
@@ -146,8 +151,9 @@
|
|||||||
(rx/map (fn [data]
|
(rx/map (fn [data]
|
||||||
(update bundle :file assoc :data data))))))
|
(update bundle :file assoc :data data))))))
|
||||||
(rx/mapcat
|
(rx/mapcat
|
||||||
(fn [{:keys [fonts] :as bundle}]
|
(fn [{:keys [fonts team] :as bundle}]
|
||||||
(rx/of (df/fonts-fetched fonts)
|
(rx/of (df/fonts-fetched fonts)
|
||||||
|
(features/initialize (:features team))
|
||||||
(bundle-fetched (merge bundle params))))))))))
|
(bundle-fetched (merge bundle params))))))))))
|
||||||
|
|
||||||
(declare go-to-frame)
|
(declare go-to-frame)
|
||||||
|
|||||||
@@ -27,14 +27,16 @@
|
|||||||
(defn get-enabled-features
|
(defn get-enabled-features
|
||||||
[state]
|
[state]
|
||||||
(-> (get state :features/runtime #{})
|
(-> (get state :features/runtime #{})
|
||||||
|
(set/intersection cfeat/no-migration-features)
|
||||||
(set/union global-enabled-features)))
|
(set/union global-enabled-features)))
|
||||||
|
|
||||||
(defn get-team-enabled-features
|
(defn get-team-enabled-features
|
||||||
[state]
|
[state]
|
||||||
|
(let [runtime-features (set/intersection (:features/runtime state #{})
|
||||||
|
cfeat/no-migration-features)]
|
||||||
(-> global-enabled-features
|
(-> global-enabled-features
|
||||||
(set/union (get state :features/runtime #{}))
|
(set/union runtime-features)
|
||||||
(set/intersection cfeat/no-migration-features)
|
(set/union (:features/team state #{})))))
|
||||||
(set/union (get state :features/team #{}))))
|
|
||||||
|
|
||||||
(def features-ref
|
(def features-ref
|
||||||
(l/derived get-team-enabled-features st/state =))
|
(l/derived get-team-enabled-features st/state =))
|
||||||
|
|||||||
Reference in New Issue
Block a user