mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 11:38:24 -05:00
commit
acbc2a80dd
4 changed files with 48 additions and 27 deletions
|
@ -100,26 +100,27 @@
|
||||||
:initial initial)
|
:initial initial)
|
||||||
|
|
||||||
on-error
|
on-error
|
||||||
(fn [cause]
|
(fn [err]
|
||||||
(cond
|
(let [cause (ex-data err)]
|
||||||
(and (= :restriction (:type cause))
|
(cond
|
||||||
(= :profile-blocked (:code cause)))
|
(and (= :restriction (:type cause))
|
||||||
(reset! error (tr "errors.profile-blocked"))
|
(= :profile-blocked (:code cause)))
|
||||||
|
(reset! error (tr "errors.profile-blocked"))
|
||||||
|
|
||||||
(and (= :restriction (:type cause))
|
(and (= :restriction (:type cause))
|
||||||
(= :admin-only-profile (:code cause)))
|
(= :admin-only-profile (:code cause)))
|
||||||
(reset! error (tr "errors.profile-blocked"))
|
(reset! error (tr "errors.profile-blocked"))
|
||||||
|
|
||||||
(and (= :validation (:type cause))
|
(and (= :validation (:type cause))
|
||||||
(= :wrong-credentials (:code cause)))
|
(= :wrong-credentials (:code cause)))
|
||||||
(reset! error (tr "errors.wrong-credentials"))
|
(reset! error (tr "errors.wrong-credentials"))
|
||||||
|
|
||||||
(and (= :validation (:type cause))
|
(and (= :validation (:type cause))
|
||||||
(= :account-without-password (:code cause)))
|
(= :account-without-password (:code cause)))
|
||||||
(reset! error (tr "errors.wrong-credentials"))
|
(reset! error (tr "errors.wrong-credentials"))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(reset! error (tr "errors.generic"))))
|
(reset! error (tr "errors.generic")))))
|
||||||
|
|
||||||
on-success-default
|
on-success-default
|
||||||
(fn [data]
|
(fn [data]
|
||||||
|
|
|
@ -58,9 +58,16 @@
|
||||||
(let [fonts* (mf/use-state {})
|
(let [fonts* (mf/use-state {})
|
||||||
fonts (deref fonts*)
|
fonts (deref fonts*)
|
||||||
input-ref (mf/use-ref)
|
input-ref (mf/use-ref)
|
||||||
|
|
||||||
uploading (mf/use-state #{})
|
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
|
handle-click
|
||||||
(mf/use-fn #(dom/click (mf/ref-val input-ref)))
|
(mf/use-fn #(dom/click (mf/ref-val input-ref)))
|
||||||
|
|
||||||
|
@ -95,7 +102,13 @@
|
||||||
on-blur-name
|
on-blur-name
|
||||||
(fn [id event]
|
(fn [id event]
|
||||||
(let [name (dom/get-target-val 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
|
on-delete
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -145,9 +158,11 @@
|
||||||
[:div {:class (stl/css :font-item :table-row)}
|
[:div {:class (stl/css :font-item :table-row)}
|
||||||
[:span (tr "dashboard.fonts.fonts-added" (i18n/c (count (vals fonts))))]
|
[:span (tr "dashboard.fonts.fonts-added" (i18n/c (count (vals fonts))))]
|
||||||
[:div {:class (stl/css :table-field :options)}
|
[: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
|
:on-click handle-upload-all
|
||||||
:data-test "upload-all"}
|
:data-test "upload-all"
|
||||||
|
:disabled disable-upload-all?}
|
||||||
[:span (tr "dashboard.fonts.upload-all")]]
|
[:span (tr "dashboard.fonts.upload-all")]]
|
||||||
[:button {:class (stl/css :btn-secondary)
|
[:button {:class (stl/css :btn-secondary)
|
||||||
:on-click handle-dismiss-all
|
:on-click handle-dismiss-all
|
||||||
|
@ -155,12 +170,15 @@
|
||||||
[:span (tr "dashboard.fonts.dismiss-all")]]]])
|
[:span (tr "dashboard.fonts.dismiss-all")]]]])
|
||||||
|
|
||||||
(for [item (sort-by :font-family (vals fonts))]
|
(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)
|
[:div {:class (stl/css :font-item :table-row)
|
||||||
:key (:id item)}
|
:key (:id item)}
|
||||||
[:div {:class (stl/css :table-field :family)}
|
[:div {:class (stl/css :table-field :family)}
|
||||||
[:input {:type "text"
|
[:input {:type "text"
|
||||||
:on-blur #(on-blur-name (:id item) %)
|
:on-blur #(on-blur-name (:id item) %)
|
||||||
|
:on-change #(on-change-name (:id item) %)
|
||||||
:default-value (:font-family item)}]]
|
:default-value (:font-family item)}]]
|
||||||
[:div {:class (stl/css :table-field :variants)}
|
[:div {:class (stl/css :table-field :variants)}
|
||||||
[:span {:class (stl/css :label)}
|
[:span {:class (stl/css :label)}
|
||||||
|
@ -177,8 +195,8 @@
|
||||||
[:button {:on-click #(on-upload item)
|
[:button {:on-click #(on-upload item)
|
||||||
:class (stl/css-case :btn-primary true
|
:class (stl/css-case :btn-primary true
|
||||||
:upload-button true
|
:upload-button true
|
||||||
:disabled uploading?)
|
:disabled disable-upload?)
|
||||||
:disabled uploading?}
|
:disabled disable-upload?}
|
||||||
(if uploading?
|
(if uploading?
|
||||||
(tr "labels.uploading")
|
(tr "labels.uploading")
|
||||||
(tr "labels.upload"))]
|
(tr "labels.upload"))]
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
[app.util.timers :as ts]
|
[app.util.timers :as ts]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[goog.functions :as f]
|
[goog.functions :as f]
|
||||||
[potok.v2.core :as ptk]
|
[potok.v2.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
@ -91,8 +92,9 @@
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps item)
|
(mf/deps item)
|
||||||
(fn [name]
|
(fn [name]
|
||||||
(st/emit! (-> (dd/rename-project (assoc item :name name))
|
(when-not (str/blank? name)
|
||||||
(with-meta {::ev/origin "dashboard:sidebar"})))
|
(st/emit! (-> (dd/rename-project (assoc item :name name))
|
||||||
|
(with-meta {::ev/origin "dashboard:sidebar"}))))
|
||||||
(swap! local* assoc :edition? false)))
|
(swap! local* assoc :edition? false)))
|
||||||
|
|
||||||
on-drag-enter
|
on-drag-enter
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
(defn- on-error
|
(defn- on-error
|
||||||
[form error]
|
[form error]
|
||||||
(case (:code error)
|
(case (:code (ex-data error))
|
||||||
:old-password-not-match
|
:old-password-not-match
|
||||||
(swap! form assoc-in [:errors :password-old]
|
(swap! form assoc-in [:errors :password-old]
|
||||||
{:message (tr "errors.wrong-old-password")})
|
{:message (tr "errors.wrong-old-password")})
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
:label (t locale "labels.confirm-password")}]]
|
:label (t locale "labels.confirm-password")}]]
|
||||||
|
|
||||||
[:> fm/submit-button*
|
[:> fm/submit-button*
|
||||||
{:label (t locale "dashboard.update-settings")
|
{:label (t locale "dashboard.password-change")
|
||||||
:data-test "submit-password"
|
:data-test "submit-password"
|
||||||
:class (stl/css :update-btn)}]]))
|
:class (stl/css :update-btn)}]]))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue