mirror of
https://github.com/penpot/penpot.git
synced 2025-07-17 14:27:14 +02:00
✨ Add label and id support for debug snapshot helpers
This commit is contained in:
parent
2643dae0a7
commit
569674452a
3 changed files with 21 additions and 14 deletions
|
@ -12,6 +12,7 @@
|
|||
[app.common.files.validate :as cfv]
|
||||
[app.common.json :as json]
|
||||
[app.common.logging :as l]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.transit :as t]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.common.uri :as u]
|
||||
|
@ -482,7 +483,7 @@
|
|||
(rx/map http/conditional-decode-transit)
|
||||
(rx/mapcat rp/handle-response)
|
||||
(rx/subs! (fn [{:keys [id]}]
|
||||
(println "Snapshot saved:" (str id)))
|
||||
(println "Snapshot saved:" (str id) label))
|
||||
(fn [cause]
|
||||
(js/console.log "EE:" cause))))))
|
||||
|
||||
|
@ -490,13 +491,21 @@
|
|||
[label file-id]
|
||||
(when-let [file-id (or (d/parse-uuid file-id)
|
||||
(:current-file-id @st/state))]
|
||||
(->> (http/send! {:method :post
|
||||
:uri (u/join cf/public-uri "api/rpc/command/restore-file-snapshot")
|
||||
:body (http/transit-data {:file-id file-id :label label})})
|
||||
(rx/map http/conditional-decode-transit)
|
||||
(rx/mapcat rp/handle-response)
|
||||
(rx/subs! (fn [_]
|
||||
(println "Snapshot restored " label)
|
||||
(let [snapshot-id (sm/parse-uuid label)
|
||||
label (if snapshot-id nil label)
|
||||
params (cond-> {:file-id file-id}
|
||||
(uuid? snapshot-id)
|
||||
(assoc :id snapshot-id)
|
||||
|
||||
(string? label)
|
||||
(assoc :label label))]
|
||||
(->> (http/send! {:method :post
|
||||
:uri (u/join cf/public-uri "api/rpc/command/restore-file-snapshot")
|
||||
:body (http/transit-data params)})
|
||||
(rx/map http/conditional-decode-transit)
|
||||
(rx/mapcat rp/handle-response)
|
||||
(rx/subs! (fn [_]
|
||||
(println "Snapshot restored " (or snapshot-id label)))
|
||||
#_(.reload js/location))
|
||||
(fn [cause]
|
||||
(js/console.log "EE:" cause))))))
|
||||
(fn [cause]
|
||||
(js/console.log "EE:" cause))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue