mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
✨ Fix a viewer can drop a .penpot file on dashboard
This commit is contained in:
parent
134c23c70c
commit
e1e13bcfb1
1 changed files with 26 additions and 22 deletions
|
@ -457,12 +457,14 @@
|
|||
on-drop
|
||||
(mf/use-fn
|
||||
(fn [e]
|
||||
(when (and (not (dnd/has-type? e "penpot/files"))
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file")))
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e))))))]
|
||||
(if can-edit
|
||||
(when (and (not (dnd/has-type? e "penpot/files"))
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file")))
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e))))
|
||||
(dom/prevent-default e))))]
|
||||
|
||||
[:div {:class (stl/css :dashboard-grid)
|
||||
:dragabble (dm/str can-edit)
|
||||
|
@ -576,24 +578,26 @@
|
|||
|
||||
on-drop
|
||||
(mf/use-fn
|
||||
(mf/deps files selected-files)
|
||||
(mf/deps files selected-files can-edit)
|
||||
(fn [e]
|
||||
(cond
|
||||
(dnd/has-type? e "penpot/files")
|
||||
(do
|
||||
(reset! dragging? false)
|
||||
(when (not= selected-project project-id)
|
||||
(let [data {:ids (into #{} (keys selected-files))
|
||||
:project-id project-id}
|
||||
mdata {:on-success on-drop-success}]
|
||||
(st/emit! (dd/move-files (with-meta data mdata))))))
|
||||
(if can-edit
|
||||
(cond
|
||||
(dnd/has-type? e "penpot/files")
|
||||
(do
|
||||
(reset! dragging? false)
|
||||
(when (not= selected-project project-id)
|
||||
(let [data {:ids (into #{} (keys selected-files))
|
||||
:project-id project-id}
|
||||
mdata {:on-success on-drop-success}]
|
||||
(st/emit! (dd/move-files (with-meta data mdata))))))
|
||||
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file"))
|
||||
(do
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e)))))))]
|
||||
(or (dnd/has-type? e "Files")
|
||||
(dnd/has-type? e "application/x-moz-file"))
|
||||
(do
|
||||
(dom/prevent-default e)
|
||||
(reset! dragging? false)
|
||||
(import-files (.-files (.-dataTransfer e)))))
|
||||
(dom/prevent-default e))))]
|
||||
|
||||
[:div {:class (stl/css :dashboard-grid)
|
||||
:dragabble (dm/str can-edit)
|
||||
|
|
Loading…
Add table
Reference in a new issue