0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Show better error messages on invalid images uploading

This commit is contained in:
Andrés Moya 2020-07-23 09:14:16 +02:00
parent d170ff8456
commit 840c4af4be
4 changed files with 604 additions and 546 deletions

File diff suppressed because it is too large Load diff

View file

@ -380,9 +380,19 @@
(on-uploaded %)) (on-uploaded %))
on-error #(do (st/emit! dm/hide) on-error #(do (st/emit! dm/hide)
(if (.-message %) (let [msg (cond
(rx/of (dm/error (.-message %))) (.-message %)
(rx/of (dm/error (tr "errors.unexpected-error"))))) (.-message %)
(= (:code %) :image-type-not-allowed)
(tr "errors.image-type-not-allowed")
(= (:code %) :image-type-mismatch)
(tr "errors.image-type-mismatch")
:else
(tr "errors.unexpected-error"))]
(rx/of (dm/error msg))))
prepare prepare
(fn [file] (fn [file]

View file

@ -180,9 +180,19 @@
on-success #(do (st/emit! dm/hide)) on-success #(do (st/emit! dm/hide))
on-error #(do (st/emit! dm/hide) on-error #(do (st/emit! dm/hide)
(if (.-message %) (let [msg (cond
(rx/of (dm/error (.-message %))) (.-message %)
(rx/of (dm/error (tr "errors.unexpected-error"))))) (.-message %)
(= (:code %) :image-type-not-allowed)
(tr "errors.image-type-not-allowed")
(= (:code %) :image-type-mismatch)
(tr "errors.image-type-mismatch")
:else
(tr "errors.unexpected-error"))]
(rx/of (dm/error msg))))
prepare prepare
(fn [file] (fn [file]

View file

@ -324,9 +324,19 @@
(on-added %)) (on-added %))
on-error #(do (st/emit! dm/hide) on-error #(do (st/emit! dm/hide)
(if (.-message %) (let [msg (cond
(rx/of (dm/error (.-message %))) (.-message %)
(rx/of (dm/error (tr "errors.unexpected-error"))))) (.-message %)
(= (:code %) :image-type-not-allowed)
(tr "errors.image-type-not-allowed")
(= (:code %) :image-type-mismatch)
(tr "errors.image-type-mismatch")
:else
(tr "errors.unexpected-error"))]
(rx/of (dm/error msg))))
prepare prepare
(fn [url] (fn [url]
@ -364,9 +374,19 @@
(on-uploaded %)) (on-uploaded %))
on-error #(do (st/emit! dm/hide) on-error #(do (st/emit! dm/hide)
(if (.-message %) (let [msg (cond
(rx/of (dm/error (.-message %))) (.-message %)
(rx/of (dm/error (tr "errors.unexpected-error"))))) (.-message %)
(= (:code %) :image-type-not-allowed)
(tr "errors.image-type-not-allowed")
(= (:code %) :image-type-mismatch)
(tr "errors.image-type-mismatch")
:else
(tr "errors.unexpected-error"))]
(rx/of (dm/error msg))))
prepare prepare
(fn [file] (fn [file]