0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

🐛 Disable import to v1 from v2

This commit is contained in:
alonso.torres 2024-01-11 18:05:36 +01:00 committed by Andrey Antukh
parent 28981e5d46
commit 19e40175be
5 changed files with 26 additions and 9 deletions

View file

@ -508,7 +508,6 @@
grc/empty-rect)
name (:name data)
path (:path data)
component-id (:component-id data)
main-instance-id (:main-instance-id data)
main-instance-page (:main-instance-page data)
attrs (-> data

View file

@ -80,12 +80,13 @@
(assoc :deleted? true))))))
(defn set-analyze-error
[files uri]
[files uri error]
(->> files
(mapv (fn [file]
(cond-> file
(= uri (:uri file))
(assoc :status :analyze-error))))))
(-> (assoc :status :analyze-error)
(assoc :error error)))))))
(defn set-analyze-result [files uri type data]
(let [existing-files? (into #{} (->> files (map :file-id) (filter some?)))
@ -150,7 +151,6 @@
(mf/defc import-entry
[{:keys [state file editing? can-be-deleted?]}]
(let [loading? (or (= :analyzing (:status file))
(= :importing (:status file)))
analyze-error? (= :analyze-error (:status file))
@ -226,7 +226,9 @@
(cond
analyze-error?
[:div {:class (stl/css :error-message)}
(tr "dashboard.import.analyze-error")]
(if (some? (:error file))
(tr (:error file))
(tr "dashboard.import.analyze-error"))]
import-error?
[:div {:class (stl/css :error-message)}
@ -260,13 +262,14 @@
(fn [files]
(->> (uw/ask-many!
{:cmd :analyze-import
:files files})
:files files
:features @features/features-ref})
(rx/mapcat #(rx/delay emit-delay (rx/of %)))
(rx/filter some?)
(rx/subs!
(fn [{:keys [uri data error type] :as msg}]
(if (some? error)
(swap! state update :files set-analyze-error uri)
(swap! state update :files set-analyze-error uri error)
(swap! state update :files set-analyze-result uri type data)))))))
import-files

View file

@ -632,7 +632,7 @@
"other")))
(defmethod impl/handler :analyze-import
[{:keys [files]}]
[{:keys [files features]}]
(->> (rx/from files)
(rx/merge-map
@ -653,7 +653,16 @@
(rx/merge-map #(zip/loadAsync (:body %)))
(rx/merge-map #(get-file {:zip %} :manifest))
(rx/map (comp d/kebab-keys parser/string->uuid))
(rx/map #(hash-map :uri (:uri file) :data % :type "application/zip")))
(rx/map
(fn [data]
;; Checks if the file is exported with components v2 and the current team only
;; supports components v1
(let [has-file-v2?
(->> (:files data)
(d/seek (fn [[_ file]] (contains? (set (:features file)) "components/v2"))))]
(if (and has-file-v2? (not (contains? features "components/v2")))
{:uri (:uri file) :error "dashboard.import.analyze-error.components-v2"}
(hash-map :uri (:uri file) :data data :type "application/zip"))))))
(->> st
(rx/filter (fn [data] (= "application/octet-stream" (:type data))))
(rx/map (fn [_]

View file

@ -534,6 +534,9 @@ msgstr "Import Penpot files"
msgid "dashboard.import.analyze-error"
msgstr "Oops! We couldn't import this file"
msgid "dashboard.import.analyze-error.components-v2"
msgstr "File with components v2 activated but this team doesn't support it yet."
msgid "dashboard.import.import-error"
msgstr "There was a problem importing the file. The file wasn't imported."

View file

@ -542,6 +542,9 @@ msgstr "Importar archivos Penpot"
msgid "dashboard.import.analyze-error"
msgstr "¡Vaya! No hemos podido importar el fichero"
msgid "dashboard.import.analyze-error.components-v2"
msgstr "Fichero exportado con componentes-v2 pero el equipo actual no lo soporta aún."
msgid "dashboard.import.import-error"
msgstr "Hubo un problema importando el fichero. No ha podido ser importado."