mirror of
https://github.com/penpot/penpot.git
synced 2026-06-09 08:52:05 +00:00
🐛 Fix add modal confirmation when clicking restore from saved version preview (#9804)
This commit is contained in:
parent
af81818b97
commit
d3148e1a10
@ -176,6 +176,25 @@
|
||||
;; RESTORE VERSION EVENTS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn exit-preview
|
||||
"Exit from preview mode and reload the live file data"
|
||||
[]
|
||||
(ptk/reify ::exit-preview
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [backup (dm/get-in state [:workspace-versions :backup])]
|
||||
(-> state
|
||||
(update :workspace-versions dissoc :backup)
|
||||
(update :workspace-global dissoc :read-only? :preview-id)
|
||||
(update :files assoc (:id backup) backup))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [file-id (:current-file-id state)
|
||||
page-id (:current-page-id state)]
|
||||
|
||||
(rx/of (dwpg/initialize-page file-id page-id))))))
|
||||
|
||||
(defn- restore-version
|
||||
[id]
|
||||
(assert (uuid? id) "expected valid uuid for `id`")
|
||||
@ -211,6 +230,7 @@
|
||||
:cancel {:label (tr "workspace.updates.dismiss")
|
||||
:callback #(do
|
||||
(rx/push! output-s (ntf/hide :tag :restore-dialog))
|
||||
(rx/push! output-s (exit-preview))
|
||||
(rx/end! output-s))}
|
||||
:accept {:label (tr "labels.restore")
|
||||
:callback #(do
|
||||
@ -232,25 +252,6 @@
|
||||
(update [_ state]
|
||||
(update state :files assoc id snapshot))))
|
||||
|
||||
(defn exit-preview
|
||||
"Exit from preview mode and reload the live file data"
|
||||
[]
|
||||
(ptk/reify ::exit-preview
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [backup (dm/get-in state [:workspace-versions :backup])]
|
||||
(-> state
|
||||
(update :workspace-versions dissoc :backup)
|
||||
(update :workspace-global dissoc :read-only? :preview-id)
|
||||
(update :files assoc (:id backup) backup))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [file-id (:current-file-id state)
|
||||
page-id (:current-page-id state)]
|
||||
|
||||
(rx/of (dwpg/initialize-page file-id page-id))))))
|
||||
|
||||
(defn enter-preview
|
||||
"Load a snapshot into the workspace for read-only preview without
|
||||
modifying any database state. Sets a read-only flag so no changes
|
||||
@ -291,7 +292,7 @@
|
||||
:accept {:label (tr "labels.restore")
|
||||
:callback #(do
|
||||
(rx/push! output-s (ntf/hide))
|
||||
(rx/push! output-s (restore-version id))
|
||||
(rx/push! output-s (enter-restore id))
|
||||
(rx/end! output-s))}
|
||||
:tag :preview-dialog))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user