mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 02:46:09 +02:00
🐛 Forbid empty names for assets
This commit is contained in:
parent
fae76f6d4e
commit
2ad9c3cc72
3 changed files with 41 additions and 36 deletions
|
@ -49,6 +49,7 @@
|
||||||
- Fix problem with text out of borders when changing from auto-width to fixed [Taiga #4308](https://tree.taiga.io/project/penpot/issue/4308)
|
- Fix problem with text out of borders when changing from auto-width to fixed [Taiga #4308](https://tree.taiga.io/project/penpot/issue/4308)
|
||||||
- Fix header not showing when exiting fullscreen mode in viewer [Taiga #4244](https://tree.taiga.io/project/penpot/issue/4244)
|
- Fix header not showing when exiting fullscreen mode in viewer [Taiga #4244](https://tree.taiga.io/project/penpot/issue/4244)
|
||||||
- Fix visual problem in select options [Taiga #5028](https://tree.taiga.io/project/penpot/issue/5028)
|
- Fix visual problem in select options [Taiga #5028](https://tree.taiga.io/project/penpot/issue/5028)
|
||||||
|
- Forbid empty names for assets [Taiga #5056](https://tree.taiga.io/project/penpot/issue/5056)
|
||||||
|
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
- To @ondrejkonec: for contributing to the code with:
|
- To @ondrejkonec: for contributing to the code with:
|
||||||
|
|
|
@ -176,10 +176,11 @@
|
||||||
(ptk/reify ::rename-color
|
(ptk/reify ::rename-color
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (get state :workspace-data)
|
(when (and (some? new-name) (not= "" new-name))
|
||||||
object (get-in data [:colors id])
|
(let [data (get state :workspace-data)
|
||||||
new-object (assoc object :name new-name)]
|
object (get-in data [:colors id])
|
||||||
(do-update-color it state new-object file-id)))))
|
new-object (assoc object :name new-name)]
|
||||||
|
(do-update-color it state new-object file-id))))))
|
||||||
|
|
||||||
(defn delete-color
|
(defn delete-color
|
||||||
[{:keys [id] :as params}]
|
[{:keys [id] :as params}]
|
||||||
|
@ -211,14 +212,15 @@
|
||||||
(ptk/reify ::rename-media
|
(ptk/reify ::rename-media
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (get state :workspace-data)
|
(when (and (some? new-name) (not= "" new-name))
|
||||||
[path name] (cph/parse-path-name new-name)
|
(let [data (get state :workspace-data)
|
||||||
object (get-in data [:media id])
|
[path name] (cph/parse-path-name new-name)
|
||||||
new-object (assoc object :path path :name name)
|
object (get-in data [:media id])
|
||||||
changes (-> (pcb/empty-changes it)
|
new-object (assoc object :path path :name name)
|
||||||
(pcb/with-library-data data)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/update-media new-object))]
|
(pcb/with-library-data data)
|
||||||
(rx/of (dch/commit-changes changes))))))
|
(pcb/update-media new-object))]
|
||||||
|
(rx/of (dch/commit-changes changes)))))))
|
||||||
|
|
||||||
|
|
||||||
(defn delete-media
|
(defn delete-media
|
||||||
|
@ -281,11 +283,12 @@
|
||||||
(ptk/reify ::rename-typography
|
(ptk/reify ::rename-typography
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (get state :workspace-data)
|
(when (and (some? new-name) (not= "" new-name))
|
||||||
[path name] (cph/parse-path-name new-name)
|
(let [data (get state :workspace-data)
|
||||||
object (get-in data [:typographies id])
|
[path name] (cph/parse-path-name new-name)
|
||||||
new-object (assoc object :path path :name name)]
|
object (get-in data [:typographies id])
|
||||||
(do-update-tipography it state new-object file-id)))))
|
new-object (assoc object :path path :name name)]
|
||||||
|
(do-update-tipography it state new-object file-id))))))
|
||||||
|
|
||||||
(defn delete-typography
|
(defn delete-typography
|
||||||
[id]
|
[id]
|
||||||
|
@ -342,27 +345,28 @@
|
||||||
(ptk/reify ::rename-component
|
(ptk/reify ::rename-component
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (get state :workspace-data)
|
(when (and (some? new-name) (not= "" new-name))
|
||||||
[path name] (cph/parse-path-name new-name)
|
(let [data (get state :workspace-data)
|
||||||
|
[path name] (cph/parse-path-name new-name)
|
||||||
|
|
||||||
update-fn
|
update-fn
|
||||||
(fn [component]
|
(fn [component]
|
||||||
;; NOTE: we need to ensure the component exists,
|
;; NOTE: we need to ensure the component exists,
|
||||||
;; because there are small possibilities of race
|
;; because there are small possibilities of race
|
||||||
;; conditions with component deletion.
|
;; conditions with component deletion.
|
||||||
(when component
|
(when component
|
||||||
(-> component
|
(-> component
|
||||||
(assoc :path path)
|
(assoc :path path)
|
||||||
(assoc :name name)
|
(assoc :name name)
|
||||||
(update :objects
|
(update :objects
|
||||||
;; Give the same name to the root shape
|
;; Give the same name to the root shape
|
||||||
#(assoc-in % [id :name] name)))))
|
#(assoc-in % [id :name] name)))))
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/update-component id update-fn))]
|
(pcb/update-component id update-fn))]
|
||||||
|
|
||||||
(rx/of (dch/commit-changes changes))))))
|
(rx/of (dch/commit-changes changes)))))))
|
||||||
|
|
||||||
(defn duplicate-component
|
(defn duplicate-component
|
||||||
"Create a new component copied from the one with the given id."
|
"Create a new component copied from the one with the given id."
|
||||||
|
|
|
@ -1156,7 +1156,7 @@
|
||||||
|
|
||||||
rename-color
|
rename-color
|
||||||
(fn [name]
|
(fn [name]
|
||||||
(st/emit! (dwl/update-color (assoc color :name name) file-id)))
|
(st/emit! (dwl/rename-color file-id (:id color) name)))
|
||||||
|
|
||||||
edit-color
|
edit-color
|
||||||
(fn [new-color]
|
(fn [new-color]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue