diff --git a/frontend/src/app/main/ui/auth/login.cljs b/frontend/src/app/main/ui/auth/login.cljs index b48b9fd9c..b4d02fb11 100644 --- a/frontend/src/app/main/ui/auth/login.cljs +++ b/frontend/src/app/main/ui/auth/login.cljs @@ -100,26 +100,27 @@ :initial initial) on-error - (fn [cause] - (cond - (and (= :restriction (:type cause)) - (= :profile-blocked (:code cause))) - (reset! error (tr "errors.profile-blocked")) + (fn [err] + (let [cause (ex-data err)] + (cond + (and (= :restriction (:type cause)) + (= :profile-blocked (:code cause))) + (reset! error (tr "errors.profile-blocked")) - (and (= :restriction (:type cause)) - (= :admin-only-profile (:code cause))) - (reset! error (tr "errors.profile-blocked")) + (and (= :restriction (:type cause)) + (= :admin-only-profile (:code cause))) + (reset! error (tr "errors.profile-blocked")) - (and (= :validation (:type cause)) - (= :wrong-credentials (:code cause))) - (reset! error (tr "errors.wrong-credentials")) + (and (= :validation (:type cause)) + (= :wrong-credentials (:code cause))) + (reset! error (tr "errors.wrong-credentials")) - (and (= :validation (:type cause)) - (= :account-without-password (:code cause))) - (reset! error (tr "errors.wrong-credentials")) + (and (= :validation (:type cause)) + (= :account-without-password (:code cause))) + (reset! error (tr "errors.wrong-credentials")) - :else - (reset! error (tr "errors.generic")))) + :else + (reset! error (tr "errors.generic"))))) on-success-default (fn [data] diff --git a/frontend/src/app/main/ui/dashboard/fonts.cljs b/frontend/src/app/main/ui/dashboard/fonts.cljs index da1ca7dc9..bdd8e5ede 100644 --- a/frontend/src/app/main/ui/dashboard/fonts.cljs +++ b/frontend/src/app/main/ui/dashboard/fonts.cljs @@ -58,9 +58,16 @@ (let [fonts* (mf/use-state {}) fonts (deref fonts*) input-ref (mf/use-ref) - uploading (mf/use-state #{}) + bad-font-family-tmp? + (mf/use-fn + (fn [font] + (and (contains? font :font-family-tmp) + (str/blank? (:font-family-tmp font))))) + + disable-upload-all? (some bad-font-family-tmp? (vals fonts)) + handle-click (mf/use-fn #(dom/click (mf/ref-val input-ref))) @@ -95,7 +102,13 @@ on-blur-name (fn [id event] (let [name (dom/get-target-val event)] - (swap! fonts* df/rename-and-regroup id name installed-fonts))) + (when-not (str/blank? name) + (swap! fonts* df/rename-and-regroup id name installed-fonts)))) + + on-change-name + (fn [id event] + (let [name (dom/get-target-val event)] + (swap! fonts* update-in [id] #(assoc % :font-family-tmp name)))) on-delete (mf/use-fn @@ -145,9 +158,11 @@ [:div {:class (stl/css :font-item :table-row)} [:span (tr "dashboard.fonts.fonts-added" (i18n/c (count (vals fonts))))] [:div {:class (stl/css :table-field :options)} - [:button {:class (stl/css :btn-primary) + [:button {:class (stl/css-case :btn-primary true + :disabled disable-upload-all?) :on-click handle-upload-all - :data-test "upload-all"} + :data-test "upload-all" + :disabled disable-upload-all?} [:span (tr "dashboard.fonts.upload-all")]] [:button {:class (stl/css :btn-secondary) :on-click handle-dismiss-all @@ -155,12 +170,15 @@ [:span (tr "dashboard.fonts.dismiss-all")]]]]) (for [item (sort-by :font-family (vals fonts))] - (let [uploading? (contains? @uploading (:id item))] + (let [uploading? (contains? @uploading (:id item)) + disable-upload? (or uploading? + (bad-font-family-tmp? item))] [:div {:class (stl/css :font-item :table-row) :key (:id item)} [:div {:class (stl/css :table-field :family)} [:input {:type "text" :on-blur #(on-blur-name (:id item) %) + :on-change #(on-change-name (:id item) %) :default-value (:font-family item)}]] [:div {:class (stl/css :table-field :variants)} [:span {:class (stl/css :label)} @@ -177,8 +195,8 @@ [:button {:on-click #(on-upload item) :class (stl/css-case :btn-primary true :upload-button true - :disabled uploading?) - :disabled uploading?} + :disabled disable-upload?) + :disabled disable-upload?} (if uploading? (tr "labels.uploading") (tr "labels.upload"))] diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 9b7a67b38..dffd26c78 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -34,6 +34,7 @@ [app.util.timers :as ts] [beicon.v2.core :as rx] [cljs.spec.alpha :as s] + [cuerdas.core :as str] [goog.functions :as f] [potok.v2.core :as ptk] [rumext.v2 :as mf])) @@ -91,8 +92,9 @@ (mf/use-callback (mf/deps item) (fn [name] - (st/emit! (-> (dd/rename-project (assoc item :name name)) - (with-meta {::ev/origin "dashboard:sidebar"}))) + (when-not (str/blank? name) + (st/emit! (-> (dd/rename-project (assoc item :name name)) + (with-meta {::ev/origin "dashboard:sidebar"})))) (swap! local* assoc :edition? false))) on-drag-enter diff --git a/frontend/src/app/main/ui/settings/password.cljs b/frontend/src/app/main/ui/settings/password.cljs index 9039dfa76..db12f1b3c 100644 --- a/frontend/src/app/main/ui/settings/password.cljs +++ b/frontend/src/app/main/ui/settings/password.cljs @@ -19,7 +19,7 @@ (defn- on-error [form error] - (case (:code error) + (case (:code (ex-data error)) :old-password-not-match (swap! form assoc-in [:errors :password-old] {:message (tr "errors.wrong-old-password")}) @@ -103,7 +103,7 @@ :label (t locale "labels.confirm-password")}]] [:> fm/submit-button* - {:label (t locale "dashboard.update-settings") + {:label (t locale "dashboard.password-change") :data-test "submit-password" :class (stl/css :update-btn)}]]))