mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 08:11:30 -05:00
✨ Add audit events for shape layout creation
This commit is contained in:
parent
467e4c76a6
commit
8eaf93f08a
3 changed files with 25 additions and 12 deletions
|
@ -19,6 +19,7 @@
|
||||||
[app.common.types.modifiers :as ctm]
|
[app.common.types.modifiers :as ctm]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.colors :as cl]
|
[app.main.data.workspace.colors :as cl]
|
||||||
[app.main.data.workspace.grid-layout.editor :as dwge]
|
[app.main.data.workspace.grid-layout.editor :as dwge]
|
||||||
|
@ -192,7 +193,7 @@
|
||||||
|
|
||||||
(defn remove-layout
|
(defn remove-layout
|
||||||
[ids]
|
[ids]
|
||||||
(ptk/reify ::remove-layout
|
(ptk/reify ::remove-shape-layout
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(let [undo-id (js/Symbol)]
|
(let [undo-id (js/Symbol)]
|
||||||
|
@ -204,7 +205,11 @@
|
||||||
|
|
||||||
(defn create-layout
|
(defn create-layout
|
||||||
[type]
|
[type]
|
||||||
(ptk/reify ::create-layout
|
(ptk/reify ::create-shape-layout
|
||||||
|
ev/Event
|
||||||
|
(-data [_]
|
||||||
|
{:layout (name type)})
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
|
@ -224,19 +229,21 @@
|
||||||
|
|
||||||
(defn toggle-layout
|
(defn toggle-layout
|
||||||
[type]
|
[type]
|
||||||
(ptk/reify ::toggle-layout-flex
|
(ptk/reify ::toggle-shape-layout
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [it state _]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
selected-shapes (map (d/getf objects) selected)
|
selected-shapes (map (d/getf objects) selected)
|
||||||
single? (= (count selected-shapes) 1)
|
single? (= (count selected-shapes) 1)
|
||||||
has-layout? (and single? (ctl/any-layout? objects (:id (first selected-shapes))))]
|
has-layout? (and single?
|
||||||
|
(ctl/any-layout? objects (:id (first selected-shapes))))]
|
||||||
|
|
||||||
(when (not= 0 (count selected))
|
(when (not= 0 (count selected))
|
||||||
(if has-layout?
|
(let [event (if has-layout?
|
||||||
(rx/of (remove-layout selected))
|
(remove-layout selected)
|
||||||
(rx/of (create-layout type))))))))
|
(create-layout type))]
|
||||||
|
(rx/of (with-meta event (meta it)))))))))
|
||||||
|
|
||||||
(defn update-layout
|
(defn update-layout
|
||||||
[ids changes]
|
[ids changes]
|
||||||
|
|
|
@ -222,13 +222,16 @@
|
||||||
:toggle-layout-flex {:tooltip (ds/shift "A")
|
:toggle-layout-flex {:tooltip (ds/shift "A")
|
||||||
:command "shift+a"
|
:command "shift+a"
|
||||||
:subsections [:modify-layers]
|
:subsections [:modify-layers]
|
||||||
:fn #(emit-when-no-readonly (dwsl/toggle-layout :flex))}
|
:fn #(emit-when-no-readonly
|
||||||
|
(with-meta (dwsl/toggle-layout :flex)
|
||||||
|
{::ev/origin "workspace:shortcuts"}))}
|
||||||
|
|
||||||
:toggle-layout-grid {:tooltip (ds/meta-shift "A")
|
:toggle-layout-grid {:tooltip (ds/meta-shift "A")
|
||||||
:command (ds/c-mod "shift+a")
|
:command (ds/c-mod "shift+a")
|
||||||
:subsections [:modify-layers]
|
:subsections [:modify-layers]
|
||||||
:fn #(emit-when-no-readonly (dwsl/toggle-layout :grid))}
|
:fn #(emit-when-no-readonly
|
||||||
|
(with-meta (dwsl/toggle-layout :grid)
|
||||||
|
{::ev/origin "workspace:shortcuts"}))}
|
||||||
;; TOOLS
|
;; TOOLS
|
||||||
|
|
||||||
:draw-frame {:tooltip "B"
|
:draw-frame {:tooltip "B"
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
[app.main.data.events :as-alias ev]
|
||||||
[app.main.data.workspace :as udw]
|
[app.main.data.workspace :as udw]
|
||||||
[app.main.data.workspace.grid-layout.editor :as dwge]
|
[app.main.data.workspace.grid-layout.editor :as dwge]
|
||||||
[app.main.data.workspace.shape-layout :as dwsl]
|
[app.main.data.workspace.shape-layout :as dwsl]
|
||||||
|
@ -855,7 +856,9 @@
|
||||||
(let [type (-> (dom/get-current-target event)
|
(let [type (-> (dom/get-current-target event)
|
||||||
(dom/get-data "type")
|
(dom/get-data "type")
|
||||||
(keyword))]
|
(keyword))]
|
||||||
(st/emit! (dwsl/create-layout type))
|
(st/emit! (with-meta (dwsl/create-layout type)
|
||||||
|
{::ev/origin "workspace:sidebar"}))
|
||||||
|
|
||||||
(reset! open* true))))
|
(reset! open* true))))
|
||||||
|
|
||||||
on-remove-layout
|
on-remove-layout
|
||||||
|
|
Loading…
Add table
Reference in a new issue