mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
Merge pull request #3081 from penpot/hiru-cancel-remove-graphics
✨ Allow to cancel and resume later remove graphics
This commit is contained in:
commit
e481f1cc99
2 changed files with 19 additions and 8 deletions
|
@ -1895,7 +1895,7 @@
|
||||||
[file-id file-name]
|
[file-id file-name]
|
||||||
(ptk/reify ::remove-graphics
|
(ptk/reify ::remove-graphics
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state stream]
|
||||||
(let [file-data (wsh/get-file state file-id)
|
(let [file-data (wsh/get-file state file-id)
|
||||||
|
|
||||||
grid-gap 50
|
grid-gap 50
|
||||||
|
@ -1915,7 +1915,9 @@
|
||||||
media)
|
media)
|
||||||
|
|
||||||
shape-grid
|
shape-grid
|
||||||
(ctst/generate-shape-grid media-points start-pos grid-gap)]
|
(ctst/generate-shape-grid media-points start-pos grid-gap)
|
||||||
|
|
||||||
|
stoper (rx/filter (ptk/type? ::finalize-file) stream)]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (modal/show {:type :remove-graphics-dialog :file-name file-name})
|
(rx/of (modal/show {:type :remove-graphics-dialog :file-name file-name})
|
||||||
|
@ -1924,8 +1926,9 @@
|
||||||
(rx/of (dch/commit-changes (-> (pcb/empty-changes it)
|
(rx/of (dch/commit-changes (-> (pcb/empty-changes it)
|
||||||
(pcb/set-save-undo? false)
|
(pcb/set-save-undo? false)
|
||||||
(pcb/add-page (:id page) page)))))
|
(pcb/add-page (:id page) page)))))
|
||||||
(rx/mapcat (partial remove-graphic it file-data' page)
|
(->> (rx/mapcat (partial remove-graphic it file-data' page)
|
||||||
(rx/from (d/enumerate (d/zip media shape-grid))))
|
(rx/from (d/enumerate (d/zip media shape-grid))))
|
||||||
|
(rx/take-until stoper))
|
||||||
(rx/of (complete-remove-graphics)))))))
|
(rx/of (complete-remove-graphics)))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
[app.util.globals :as globals]
|
[app.util.globals :as globals]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
[app.util.router :as rt]
|
||||||
[debug :refer [debug?]]
|
[debug :refer [debug?]]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
|
@ -199,8 +200,12 @@
|
||||||
::mf/register-as :remove-graphics-dialog}
|
::mf/register-as :remove-graphics-dialog}
|
||||||
[{:keys [] :as ctx}]
|
[{:keys [] :as ctx}]
|
||||||
(let [remove-state (mf/deref refs/remove-graphics)
|
(let [remove-state (mf/deref refs/remove-graphics)
|
||||||
close #(modal/hide!)
|
project (mf/deref refs/workspace-project)
|
||||||
reload-file #(dom/reload-current-window)]
|
close #(modal/hide!)
|
||||||
|
reload-file #(dom/reload-current-window)
|
||||||
|
nav-out #(st/emit! (rt/navigate :dashboard-files
|
||||||
|
{:team-id (:team-id project)
|
||||||
|
:project-id (:id project)}))]
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
#(st/emit! (dw/clear-remove-graphics))))
|
#(st/emit! (dw/clear-remove-graphics))))
|
||||||
|
@ -209,9 +214,12 @@
|
||||||
[:div.modal-header
|
[:div.modal-header
|
||||||
[:div.modal-header-title
|
[:div.modal-header-title
|
||||||
[:h2 (tr "workspace.remove-graphics.title" (:file-name ctx))]]
|
[:h2 (tr "workspace.remove-graphics.title" (:file-name ctx))]]
|
||||||
(when (and (:completed remove-state) (:error remove-state))
|
(if (and (:completed remove-state) (:error remove-state))
|
||||||
[:div.modal-close-button
|
[:div.modal-close-button
|
||||||
{:on-click close} i/close])]
|
{:on-click close} i/close]
|
||||||
|
[:div.modal-close-button
|
||||||
|
{:on-click nav-out}
|
||||||
|
i/close])]
|
||||||
(if-not (and (:completed remove-state) (:error remove-state))
|
(if-not (and (:completed remove-state) (:error remove-state))
|
||||||
[:div.modal-content
|
[:div.modal-content
|
||||||
[:p (tr "workspace.remove-graphics.text1")]
|
[:p (tr "workspace.remove-graphics.text1")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue