🐛 Avoid empty names in projects, files and pages

This commit is contained in:
Andrés Moya 2022-01-25 16:52:08 +01:00 committed by Alonso Torres
parent 918829ad0a
commit 9dfd5c0bcc
5 changed files with 19 additions and 10 deletions

View file

@ -74,6 +74,7 @@
- Fix auto hide header in viewer full screen [Taiga #2632](https://tree.taiga.io/project/penpot/issue/2632) - Fix auto hide header in viewer full screen [Taiga #2632](https://tree.taiga.io/project/penpot/issue/2632)
- Fix zoom in/out after fit or fill [Taiga #2630](https://tree.taiga.io/project/penpot/issue/2630) - Fix zoom in/out after fit or fill [Taiga #2630](https://tree.taiga.io/project/penpot/issue/2630)
- Normalize zoom levels in workspace and viewer [Taiga #2631](https://tree.taiga.io/project/penpot/issue/2631) - Normalize zoom levels in workspace and viewer [Taiga #2631](https://tree.taiga.io/project/penpot/issue/2631)
- Avoid empty names in projects, files and pages [Taiga #2594](https://tree.taiga.io/project/penpot/issue/2594)
### :arrow_up: Deps updates ### :arrow_up: Deps updates

View file

@ -16,6 +16,7 @@
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc header (mf/defc header
@ -63,9 +64,11 @@
(if (:edition @local) (if (:edition @local)
[:& inline-edition {:content (:name project) [:& inline-edition {:content (:name project)
:on-end (fn [name] :on-end (fn [name]
(st/emit! (-> (dd/rename-project (assoc project :name name)) (let [name (str/trim name)]
(with-meta {::ev/origin "project"}))) (when-not (str/empty? name)
(swap! local assoc :edition false))}] (st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "project"}))))
(swap! local assoc :edition false)))}]
[:div.dashboard-title [:div.dashboard-title
[:h1 {:on-double-click on-edit} [:h1 {:on-double-click on-edit}
(:name project)]])) (:name project)]]))

View file

@ -18,6 +18,7 @@
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt] [app.util.router :as rt]
[app.util.time :as dt] [app.util.time :as dt]
[cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
@ -73,9 +74,11 @@
(mf/use-callback (mf/use-callback
(mf/deps project) (mf/deps project)
(fn [name] (fn [name]
(st/emit! (-> (dd/rename-project (assoc project :name name)) (let [name (str/trim name)]
(with-meta {::ev/origin "dashboard"}))) (when-not (str/empty? name)
(swap! local assoc :edition? false))) (st/emit! (-> (dd/rename-project (assoc project :name name))
(with-meta {::ev/origin "dashboard"}))))
(swap! local assoc :edition? false))))
on-file-created on-file-created
(mf/use-callback (mf/use-callback

View file

@ -70,8 +70,8 @@
(on-stop-edit) (on-stop-edit)
(swap! local assoc :edition false) (swap! local assoc :edition false)
(st/emit! (dw/end-rename-shape) (st/emit! (dw/end-rename-shape)
(when-not (str/empty? name) (when-not (str/empty? (str/trim name))
(dw/update-shape (:id shape) {:name name}))))) (dw/update-shape (:id shape) {:name (str/trim name)})))))
cancel-edit (fn [] cancel-edit (fn []
(on-stop-edit) (on-stop-edit)

View file

@ -18,6 +18,7 @@
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
@ -66,8 +67,9 @@
(mf/use-callback (mf/use-callback
(fn [event] (fn [event]
(let [target (dom/event->target event) (let [target (dom/event->target event)
name (dom/get-value target)] name (str/trim (dom/get-value target))]
(st/emit! (dw/rename-page id name)) (when-not (str/empty? name)
(st/emit! (dw/rename-page id name)))
(swap! local assoc :edition false)))) (swap! local assoc :edition false))))
on-key-down on-key-down