0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Changed some events for versions

This commit is contained in:
alonso.torres 2024-11-18 16:38:38 +01:00
parent 20ea188070
commit f436d72f51
3 changed files with 30 additions and 7 deletions

View file

@ -117,7 +117,7 @@
(rx/of (ptk/event ::ev/event {::ev/name "rename-version"}))))))
(defn restore-version
[project-id file-id id]
[project-id file-id id origin]
(dm/assert! (uuid? project-id))
(dm/assert! (uuid? file-id))
(dm/assert! (uuid? id))
@ -132,7 +132,17 @@
(rx/take 1)
(rx/mapcat #(rp/cmd! :restore-file-snapshot {:file-id file-id :id id}))
(rx/map #(dw/initialize-file project-id file-id)))
(rx/of (ptk/event ::ev/event {::ev/name "restore-version"}))))))
(case origin
:version
(rx/of (ptk/event ::ev/event {::ev/name "restore-pin-version"}))
:snapshot
(rx/of (ptk/event ::ev/event {::ev/name "restore-autosave"}))
:plugin
(rx/of (ptk/event ::ev/event {::ev/name "restore-version-plugin"}))
(rx/empty))))))
(defn delete-version
[file-id id]

View file

@ -274,10 +274,11 @@
(fn [id label]
(st/emit! (dwv/rename-version file-id id label))))
handle-restore-version
(mf/use-fn
(mf/deps project-id file-id)
(fn [id]
(fn [origin id]
(st/emit!
(ntf/dialog
:content (tr "workspace.versions.restore-warning")
@ -287,9 +288,21 @@
:callback #(st/emit! (ntf/hide))}
{:label (tr "labels.restore")
:type :primary
:callback #(st/emit! (dwv/restore-version project-id file-id id))}]
:callback #(st/emit! (dwv/restore-version project-id file-id id origin))}]
:tag :restore-dialog))))
handle-restore-version-pinned
(mf/use-fn
(mf/deps handle-restore-version)
(fn [id]
(handle-restore-version :version id)))
handle-restore-version-snapshot
(mf/use-fn
(mf/deps handle-restore-version)
(fn [id]
(handle-restore-version :snapshot id)))
handle-delete-version
(mf/use-fn
(mf/deps file-id)
@ -362,7 +375,7 @@
:editing? (= (:id entry) editing)
:profile (get users (:profile-id entry))
:on-rename-version handle-rename-version
:on-restore-version handle-restore-version
:on-restore-version handle-restore-version-pinned
:on-delete-version handle-delete-version}]
:snapshot
@ -371,7 +384,7 @@
:entry entry
:is-expanded (contains? @expanded idx-entry)
:on-toggle-expand handle-toggle-expand
:on-restore-snapshot handle-restore-version
:on-restore-snapshot handle-restore-version-snapshot
:on-pin-snapshot handle-pin-version}]
nil))])])]))

View file

@ -40,7 +40,7 @@
:else
(let [project-id (:current-project-id @st/state)]
(st/emit! (dwv/restore-version project-id $file $version)))))
(st/emit! (dwv/restore-version project-id $file $version :plugin)))))
(remove
[_]