From c8683ea0bac3cce3867fcbb3905b91f8ef081b92 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 8 Nov 2016 20:41:25 +0100 Subject: [PATCH] Show properly conflict errors on colors page. --- src/uxbox/main/locales/en.cljs | 5 ++++- src/uxbox/main/ui.cljs | 6 +++++- src/uxbox/main/ui/dashboard/colors.cljs | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/uxbox/main/locales/en.cljs b/src/uxbox/main/locales/en.cljs index 9cfec171f6..b4c5e5ba93 100644 --- a/src/uxbox/main/locales/en.cljs +++ b/src/uxbox/main/locales/en.cljs @@ -70,8 +70,11 @@ "errors.form.max-len" "Should be less than %s" "errors.form.color" "Should be a valid color string" "errors.form.password-not-match" "Password does not match" - "errors.generic" "Something work has happened." "errors.auth.unauthorized" "Username or passwords seems to be wrong." "errors.auth.invalid-recovery-token" "The recovery token is invalid." "errors.profile.update-password" "Error updating password, probably your old password is wrong." + + "errors.generic" "Something work has happened." + "errors.conflict" "Conflict on saving data, please refresh and try again." + }) diff --git a/src/uxbox/main/ui.cljs b/src/uxbox/main/ui.cljs index d11aebc6ed..cd3888f031 100644 --- a/src/uxbox/main/ui.cljs +++ b/src/uxbox/main/ui.cljs @@ -50,7 +50,7 @@ (defn- on-error "A default error handler." - [error] + [{:keys [status] :as error}] (cond ;; Unauthorized or Auth timeout (and (:status error) @@ -59,6 +59,10 @@ (= (:status error) 419))) (rs/emit! (dauth/logout)) + ;; Conflict + (= status 412) + (dmsg/error! (tr "errors.conflict")) + ;; Network error (= (:status error) 0) (do diff --git a/src/uxbox/main/ui/dashboard/colors.cljs b/src/uxbox/main/ui/dashboard/colors.cljs index 153f7b6ad8..8ee43db01b 100644 --- a/src/uxbox/main/ui/dashboard/colors.cljs +++ b/src/uxbox/main/ui/dashboard/colors.cljs @@ -12,6 +12,7 @@ [uxbox.main.data.dashboard :as dd] [uxbox.main.data.lightbox :as udl] [uxbox.main.state :as st] + [uxbox.main.ui.messages :as uum] [uxbox.main.ui.colorpicker :refer (colorpicker)] [uxbox.main.ui.dashboard.header :refer (header)] [uxbox.main.ui.forms :as form] @@ -330,6 +331,7 @@ colls (mx/react collections-ref) coll (get colls (:id state))] [:main.dashboard-main + (uum/messages) (header) [:section.dashboard-content (nav state colls)