0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

Merge pull request #4215 from penpot/palba-bugfixing-005

🐛 Bugfixing
This commit is contained in:
Alejandro 2024-03-04 09:31:51 +01:00 committed by GitHub
commit acbc2a80dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 48 additions and 27 deletions

View file

@ -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]

View file

@ -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"))]

View file

@ -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

View file

@ -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)}]]))