diff --git a/backend/test/backend_tests/helpers.clj b/backend/test/backend_tests/helpers.clj index e5ed4ac71..6523477db 100644 --- a/backend/test/backend_tests/helpers.clj +++ b/backend/test/backend_tests/helpers.clj @@ -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" diff --git a/backend/test/backend_tests/rpc_cond_middleware_test.clj b/backend/test/backend_tests/rpc_cond_middleware_test.clj index 4246257a5..c2ab68ad0 100644 --- a/backend/test/backend_tests/rpc_cond_middleware_test.clj +++ b/backend/test/backend_tests/rpc_cond_middleware_test.clj @@ -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)) diff --git a/common/src/app/common/features.cljc b/common/src/app/common/features.cljc index 0e3e652d0..9de649a93 100644 --- a/common/src/app/common/features.cljc +++ b/common/src/app/common/features.cljc @@ -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 diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index d70916376..07fe52cc0 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -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) diff --git a/frontend/src/app/main/features.cljs b/frontend/src/app/main/features.cljs index 890f32e15..9c6ff683e 100644 --- a/frontend/src/app/main/features.cljs +++ b/frontend/src/app/main/features.cljs @@ -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] - (-> global-enabled-features - (set/union (get state :features/runtime #{})) - (set/intersection cfeat/no-migration-features) - (set/union (get state :features/team #{})))) + (let [runtime-features (set/intersection (:features/runtime state #{}) + cfeat/no-migration-features)] + (-> global-enabled-features + (set/union runtime-features) + (set/union (:features/team state #{}))))) (def features-ref (l/derived get-team-enabled-features st/state =))