mirror of
https://github.com/penpot/penpot.git
synced 2025-04-01 01:21:21 -05:00
🐛 Disable import to v1 from v2
This commit is contained in:
parent
28981e5d46
commit
19e40175be
5 changed files with 26 additions and 9 deletions
|
@ -508,7 +508,6 @@
|
||||||
grc/empty-rect)
|
grc/empty-rect)
|
||||||
name (:name data)
|
name (:name data)
|
||||||
path (:path data)
|
path (:path data)
|
||||||
component-id (:component-id data)
|
|
||||||
main-instance-id (:main-instance-id data)
|
main-instance-id (:main-instance-id data)
|
||||||
main-instance-page (:main-instance-page data)
|
main-instance-page (:main-instance-page data)
|
||||||
attrs (-> data
|
attrs (-> data
|
||||||
|
|
|
@ -80,12 +80,13 @@
|
||||||
(assoc :deleted? true))))))
|
(assoc :deleted? true))))))
|
||||||
|
|
||||||
(defn set-analyze-error
|
(defn set-analyze-error
|
||||||
[files uri]
|
[files uri error]
|
||||||
(->> files
|
(->> files
|
||||||
(mapv (fn [file]
|
(mapv (fn [file]
|
||||||
(cond-> file
|
(cond-> file
|
||||||
(= uri (:uri file))
|
(= uri (:uri file))
|
||||||
(assoc :status :analyze-error))))))
|
(-> (assoc :status :analyze-error)
|
||||||
|
(assoc :error error)))))))
|
||||||
|
|
||||||
(defn set-analyze-result [files uri type data]
|
(defn set-analyze-result [files uri type data]
|
||||||
(let [existing-files? (into #{} (->> files (map :file-id) (filter some?)))
|
(let [existing-files? (into #{} (->> files (map :file-id) (filter some?)))
|
||||||
|
@ -150,7 +151,6 @@
|
||||||
|
|
||||||
(mf/defc import-entry
|
(mf/defc import-entry
|
||||||
[{:keys [state file editing? can-be-deleted?]}]
|
[{:keys [state file editing? can-be-deleted?]}]
|
||||||
|
|
||||||
(let [loading? (or (= :analyzing (:status file))
|
(let [loading? (or (= :analyzing (:status file))
|
||||||
(= :importing (:status file)))
|
(= :importing (:status file)))
|
||||||
analyze-error? (= :analyze-error (:status file))
|
analyze-error? (= :analyze-error (:status file))
|
||||||
|
@ -226,7 +226,9 @@
|
||||||
(cond
|
(cond
|
||||||
analyze-error?
|
analyze-error?
|
||||||
[:div {:class (stl/css :error-message)}
|
[: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?
|
import-error?
|
||||||
[:div {:class (stl/css :error-message)}
|
[:div {:class (stl/css :error-message)}
|
||||||
|
@ -260,13 +262,14 @@
|
||||||
(fn [files]
|
(fn [files]
|
||||||
(->> (uw/ask-many!
|
(->> (uw/ask-many!
|
||||||
{:cmd :analyze-import
|
{:cmd :analyze-import
|
||||||
:files files})
|
:files files
|
||||||
|
:features @features/features-ref})
|
||||||
(rx/mapcat #(rx/delay emit-delay (rx/of %)))
|
(rx/mapcat #(rx/delay emit-delay (rx/of %)))
|
||||||
(rx/filter some?)
|
(rx/filter some?)
|
||||||
(rx/subs!
|
(rx/subs!
|
||||||
(fn [{:keys [uri data error type] :as msg}]
|
(fn [{:keys [uri data error type] :as msg}]
|
||||||
(if (some? error)
|
(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)))))))
|
(swap! state update :files set-analyze-result uri type data)))))))
|
||||||
|
|
||||||
import-files
|
import-files
|
||||||
|
|
|
@ -632,7 +632,7 @@
|
||||||
"other")))
|
"other")))
|
||||||
|
|
||||||
(defmethod impl/handler :analyze-import
|
(defmethod impl/handler :analyze-import
|
||||||
[{:keys [files]}]
|
[{:keys [files features]}]
|
||||||
|
|
||||||
(->> (rx/from files)
|
(->> (rx/from files)
|
||||||
(rx/merge-map
|
(rx/merge-map
|
||||||
|
@ -653,7 +653,16 @@
|
||||||
(rx/merge-map #(zip/loadAsync (:body %)))
|
(rx/merge-map #(zip/loadAsync (:body %)))
|
||||||
(rx/merge-map #(get-file {:zip %} :manifest))
|
(rx/merge-map #(get-file {:zip %} :manifest))
|
||||||
(rx/map (comp d/kebab-keys parser/string->uuid))
|
(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
|
(->> st
|
||||||
(rx/filter (fn [data] (= "application/octet-stream" (:type data))))
|
(rx/filter (fn [data] (= "application/octet-stream" (:type data))))
|
||||||
(rx/map (fn [_]
|
(rx/map (fn [_]
|
||||||
|
|
|
@ -534,6 +534,9 @@ msgstr "Import Penpot files"
|
||||||
msgid "dashboard.import.analyze-error"
|
msgid "dashboard.import.analyze-error"
|
||||||
msgstr "Oops! We couldn't import this file"
|
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"
|
msgid "dashboard.import.import-error"
|
||||||
msgstr "There was a problem importing the file. The file wasn't imported."
|
msgstr "There was a problem importing the file. The file wasn't imported."
|
||||||
|
|
||||||
|
|
|
@ -542,6 +542,9 @@ msgstr "Importar archivos Penpot"
|
||||||
msgid "dashboard.import.analyze-error"
|
msgid "dashboard.import.analyze-error"
|
||||||
msgstr "¡Vaya! No hemos podido importar el fichero"
|
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"
|
msgid "dashboard.import.import-error"
|
||||||
msgstr "Hubo un problema importando el fichero. No ha podido ser importado."
|
msgstr "Hubo un problema importando el fichero. No ha podido ser importado."
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue