mirror of
https://github.com/penpot/penpot.git
synced 2026-03-26 21:31:24 +01:00
✨ Move paste feature checking function to common/features
This commit is contained in:
committed by
Andrés Moya
parent
ea156198c6
commit
12907771b0
@@ -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))))))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user