mirror of
https://github.com/penpot/penpot.git
synced 2025-01-07 15:39:42 -05:00
🐛 Don't allow empty strings and whitespace-only strings on media name
This commit is contained in:
parent
b64a9f0cf4
commit
a868dcf8e6
2 changed files with 14 additions and 12 deletions
|
@ -31,6 +31,7 @@
|
|||
- Fix create and account only with spaces [Taiga #5518](https://tree.taiga.io/project/penpot/issue/5518)
|
||||
- Fix context menu outside screen [Taiga #5524](https://tree.taiga.io/project/penpot/issue/5524)
|
||||
- Fix graphic item rename on assets pannel [Taiga #5556](https://tree.taiga.io/project/penpot/issue/5556)
|
||||
- Fix component and media name validation on assets panel [Taiga #5555](https://tree.taiga.io/project/penpot/issue/5555)
|
||||
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
|
|
|
@ -185,21 +185,22 @@
|
|||
|
||||
(defn rename-media
|
||||
[id new-name]
|
||||
(dm/assert! (uuid? id))
|
||||
(dm/assert! (string? new-name))
|
||||
(dm/verify! (uuid? id))
|
||||
(dm/verify! (string? new-name))
|
||||
(ptk/reify ::rename-media
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(when (and (some? new-name) (not= "" new-name))
|
||||
(let [data (get state :workspace-data)
|
||||
[path name] (cph/parse-path-name new-name)
|
||||
object (get-in data [:media id])
|
||||
new-object (assoc object :path path :name name)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/update-media new-object))]
|
||||
(rx/of (dch/commit-changes changes)))))))
|
||||
|
||||
(let [new-name (str/trim new-name)]
|
||||
(if (str/empty? new-name)
|
||||
(rx/empty)
|
||||
(let [[path name] (cph/parse-path-name new-name)
|
||||
data (get state :workspace-data)
|
||||
object (get-in data [:media id])
|
||||
new-object (assoc object :path path :name name)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/update-media new-object))]
|
||||
(rx/of (dch/commit-changes changes))))))))
|
||||
|
||||
(defn delete-media
|
||||
[{:keys [id] :as params}]
|
||||
|
|
Loading…
Reference in a new issue