mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
✨ Improve audit log for create files
This commit is contained in:
parent
1eede8442d
commit
bfe54fe5e1
5 changed files with 19 additions and 14 deletions
|
@ -713,18 +713,21 @@
|
|||
[{:keys [project-id] :as params}]
|
||||
(us/assert ::us/uuid project-id)
|
||||
(ptk/reify ::create-file
|
||||
|
||||
IDeref
|
||||
(-deref [_] {:project-id project-id})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(watch [it _ _]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error rx/throw}} (meta params)
|
||||
|
||||
name (name (gensym (str (tr "dashboard.new-file-prefix") " ")))
|
||||
params (assoc params :name name)]
|
||||
|
||||
(->> (rp/mutation! :create-file params)
|
||||
(rx/tap on-success)
|
||||
(rx/map file-created)
|
||||
(rx/map #(with-meta (file-created %) (meta it)))
|
||||
(rx/catch on-error))))))
|
||||
|
||||
;; --- EVENT: duplicate-file
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
(derive :app.main.data.comments/update-comment-thread-status ::generic-action)
|
||||
(derive :app.main.data.dashboard/delete-team-member ::generic-action)
|
||||
(derive :app.main.data.dashboard/duplicate-project ::generic-action)
|
||||
(derive :app.main.data.dashboard/create-file ::generic-action)
|
||||
(derive :app.main.data.dashboard/file-created ::generic-action)
|
||||
(derive :app.main.data.dashboard/invite-team-members ::generic-action)
|
||||
(derive :app.main.data.dashboard/leave-team ::generic-action)
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
:on-import on-import}]
|
||||
|
||||
[:div.dashboard-header-actions
|
||||
[:a.btn-secondary.btn-small {:on-click (partial on-create-clicked project) :data-test "new-file"}
|
||||
[:a.btn-secondary.btn-small {:on-click (partial on-create-clicked project "dashboard:header") :data-test "new-file"}
|
||||
(tr "dashboard.new-file")]
|
||||
|
||||
(when-not (:is-default project)
|
||||
|
@ -100,9 +100,10 @@
|
|||
|
||||
on-create-clicked
|
||||
(mf/use-callback
|
||||
(fn [project event]
|
||||
(fn [project origin event]
|
||||
(dom/prevent-default event)
|
||||
(st/emit! (dd/create-file {:project-id (:id project)}))))]
|
||||
(st/emit! (with-meta (dd/create-file {:project-id (:id project)})
|
||||
{::ev/origin origin}))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps project)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
:else
|
||||
[:div.grid-empty-placeholder
|
||||
[:button.create-new {:on-click (partial on-create-clicked project)}
|
||||
[:button.create-new {:on-click (partial on-create-clicked project "dashboard:empty-folder-placeholder")}
|
||||
(tr "dashboard.new-file")]]))
|
||||
|
||||
(mf/defc loading-placeholder
|
||||
|
|
|
@ -93,10 +93,11 @@
|
|||
create-file
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn []
|
||||
(fn [origin]
|
||||
(let [mdata {:on-success on-file-created}
|
||||
params {:project-id (:id project)}]
|
||||
(st/emit! (dd/create-file (with-meta params mdata))))))
|
||||
(st/emit! (with-meta (dd/create-file (with-meta params mdata))
|
||||
{::ev/origin origin})))))
|
||||
|
||||
on-import
|
||||
(mf/use-callback
|
||||
|
@ -140,7 +141,7 @@
|
|||
i/pin)])
|
||||
|
||||
[:a.btn-secondary.btn-small.tooltip.tooltip-bottom
|
||||
{:on-click create-file :alt (tr "dashboard.new-file") :data-test "project-new-file"}
|
||||
{:on-click (partial create-file "dashboard:folder") :alt (tr "dashboard.new-file") :data-test "project-new-file"}
|
||||
i/close]
|
||||
|
||||
[:a.btn-secondary.btn-small.tooltip.tooltip-bottom
|
||||
|
@ -152,8 +153,7 @@
|
|||
:team team
|
||||
:on-load-more on-nav
|
||||
:files files
|
||||
:on-create-clicked create-file}]]))
|
||||
|
||||
:on-create-clicked (partial create-file "dashboard:empty-folder-placeholder")}]]))
|
||||
|
||||
(def recent-files-ref
|
||||
(l/derived :dashboard-recent-files st/state))
|
||||
|
|
Loading…
Reference in a new issue