mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
✨ Changed some events for versions
This commit is contained in:
parent
20ea188070
commit
f436d72f51
3 changed files with 30 additions and 7 deletions
|
@ -117,7 +117,7 @@
|
||||||
(rx/of (ptk/event ::ev/event {::ev/name "rename-version"}))))))
|
(rx/of (ptk/event ::ev/event {::ev/name "rename-version"}))))))
|
||||||
|
|
||||||
(defn restore-version
|
(defn restore-version
|
||||||
[project-id file-id id]
|
[project-id file-id id origin]
|
||||||
(dm/assert! (uuid? project-id))
|
(dm/assert! (uuid? project-id))
|
||||||
(dm/assert! (uuid? file-id))
|
(dm/assert! (uuid? file-id))
|
||||||
(dm/assert! (uuid? id))
|
(dm/assert! (uuid? id))
|
||||||
|
@ -132,7 +132,17 @@
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/mapcat #(rp/cmd! :restore-file-snapshot {:file-id file-id :id id}))
|
(rx/mapcat #(rp/cmd! :restore-file-snapshot {:file-id file-id :id id}))
|
||||||
(rx/map #(dw/initialize-file project-id file-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
|
(defn delete-version
|
||||||
[file-id id]
|
[file-id id]
|
||||||
|
|
|
@ -274,10 +274,11 @@
|
||||||
(fn [id label]
|
(fn [id label]
|
||||||
(st/emit! (dwv/rename-version file-id id label))))
|
(st/emit! (dwv/rename-version file-id id label))))
|
||||||
|
|
||||||
|
|
||||||
handle-restore-version
|
handle-restore-version
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps project-id file-id)
|
(mf/deps project-id file-id)
|
||||||
(fn [id]
|
(fn [origin id]
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(ntf/dialog
|
(ntf/dialog
|
||||||
:content (tr "workspace.versions.restore-warning")
|
:content (tr "workspace.versions.restore-warning")
|
||||||
|
@ -287,9 +288,21 @@
|
||||||
:callback #(st/emit! (ntf/hide))}
|
:callback #(st/emit! (ntf/hide))}
|
||||||
{:label (tr "labels.restore")
|
{:label (tr "labels.restore")
|
||||||
:type :primary
|
: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))))
|
: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
|
handle-delete-version
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps file-id)
|
(mf/deps file-id)
|
||||||
|
@ -362,7 +375,7 @@
|
||||||
:editing? (= (:id entry) editing)
|
:editing? (= (:id entry) editing)
|
||||||
:profile (get users (:profile-id entry))
|
:profile (get users (:profile-id entry))
|
||||||
:on-rename-version handle-rename-version
|
: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}]
|
:on-delete-version handle-delete-version}]
|
||||||
|
|
||||||
:snapshot
|
:snapshot
|
||||||
|
@ -371,7 +384,7 @@
|
||||||
:entry entry
|
:entry entry
|
||||||
:is-expanded (contains? @expanded idx-entry)
|
:is-expanded (contains? @expanded idx-entry)
|
||||||
:on-toggle-expand handle-toggle-expand
|
: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}]
|
:on-pin-snapshot handle-pin-version}]
|
||||||
|
|
||||||
nil))])])]))
|
nil))])])]))
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [project-id (:current-project-id @st/state)]
|
(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
|
(remove
|
||||||
[_]
|
[_]
|
||||||
|
|
Loading…
Add table
Reference in a new issue