diff --git a/common/src/app/common/features.cljc b/common/src/app/common/features.cljc index ab2e66307..0a250b19f 100644 --- a/common/src/app/common/features.cljc +++ b/common/src/app/common/features.cljc @@ -260,3 +260,46 @@ :feature (first not-supported) :hint (str/ffmt "the source team does not have support '%' features" (str/join "," not-supported)))))) + + +(defn check-paste-features! + "Function used for check feature compability between currently enabled + features set on the application with the provided featured set by + the paste data (frontend clipboard)." + [enabled-features paste-features] + (let [not-supported (-> enabled-features + (set/difference paste-features) + ;; NOTE: we don't want to raise a feature-mismatch + ;; exception for features which don't require an + ;; explicit file migration process or has no real + ;; effect on file data structure + (set/difference no-migration-features))] + + (when (seq not-supported) + (ex/raise :type :restriction + :code :missing-features-in-paste-content + :feature (first not-supported) + :hint (str/ffmt "expected features '%' not present in pasted content" + (str/join "," not-supported))))) + + (let [not-supported (set/difference enabled-features supported-features)] + (when (seq not-supported) + (ex/raise :type :restriction + :code :paste-feature-not-supported + :feature (first not-supported) + :hint (str/ffmt "features '%' not supported in the application" + (str/join "," not-supported))))) + + (let [not-supported (-> paste-features + (set/difference enabled-features) + (set/difference backend-only-features) + (set/difference frontend-only-features))] + + (when (seq not-supported) + (ex/raise :type :restriction + :code :paste-feature-not-enabled + :feature (first not-supported) + :hint (str/ffmt "paste features '%' not enabled on the application" + (str/join "," not-supported)))))) + + diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index aa84170ed..16d848a27 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -80,7 +80,6 @@ [app.util.webapi :as wapi] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [cuerdas.core :as str] [potok.core :as ptk])) @@ -1736,47 +1735,8 @@ (= (:width (:selrect (first (vals paste-obj)))) (:width (:selrect frame-obj))))) -(defn- check-paste-features! - "Function used for check feature compability between currently - enabled features set on the application with the provided featured - set by the paste data." - [enabled-features paste-features] - (let [not-supported (-> enabled-features - (set/difference paste-features) - ;; NOTE: we don't want to raise a feature-mismatch - ;; exception for features which don't require an - ;; explicit file migration process or has no real - ;; effect on file data structure - (set/difference cfeat/no-migration-features))] - - (when (seq not-supported) - (ex/raise :type :restriction - :code :missing-features-in-paste-content - :feature (first not-supported) - :hint (str/ffmt "expected features '%' not present in pasted content" - (str/join "," not-supported))))) - - (let [not-supported (set/difference enabled-features cfeat/supported-features)] - (when (seq not-supported) - (ex/raise :type :restriction - :code :paste-feature-not-supported - :feature (first not-supported) - :hint (str/ffmt "features '%' not supported in the application" - (str/join "," not-supported))))) - - (let [not-supported (-> paste-features - (set/difference enabled-features) - (set/difference cfeat/backend-only-features) - (set/difference cfeat/frontend-only-features))] - - (when (seq not-supported) - (ex/raise :type :restriction - :code :paste-feature-not-enabled - :feature (first not-supported) - :hint (str/ffmt "paste features '%' not enabled on the application" - (str/join "," not-supported)))))) - -(def ^:private schema:paste-data +(def ^:private + schema:paste-data (sm/define [:map {:title "paste-data"} [:type [:= :copied-shapes]] @@ -1816,7 +1776,7 @@ {:hint "invalid paste data" :code :invalid-paste-data}) - (check-paste-features! features (:features pdata)) + (cfeat/check-paste-features! features (:features pdata)) (if (= file-id (:file-id pdata)) (let [pdata (assoc pdata :images [])] (rx/of (paste-shapes pdata))) diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 4166e7ac6..1df309459 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -881,7 +881,7 @@ msgstr "The email «%s» has been reported as spam or permanently bounce." msgid "errors.feature-mismatch" msgstr "" "Looks like you are opening a file that has the feature '%s' enabled but " -"your penpot frontend does not supports it or has it disabled." +"the current penpot version does not supports it or has it disabled." #: src/app/main/errors.cljs msgid "errors.file-feature-mismatch"