From 942989824a2cb807376f593b4c435be23346059c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 29 Feb 2024 16:29:34 +0100 Subject: [PATCH] :sparkles: Improve audit events on inspect copy operations --- .../src/app/main/ui/viewer/inspect/code.cljs | 22 +++++++++++-------- .../main/ui/viewer/inspect/right_sidebar.cljs | 20 ++++++++--------- .../main/ui/workspace/sidebar/options.cljs | 4 +++- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/frontend/src/app/main/ui/viewer/inspect/code.cljs b/frontend/src/app/main/ui/viewer/inspect/code.cljs index 6c96e575e..d7db2dab2 100644 --- a/frontend/src/app/main/ui/viewer/inspect/code.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/code.cljs @@ -153,20 +153,24 @@ (cb/format-code markup-type)))) on-markup-copied - (mf/use-callback - (mf/deps markup-type) + (mf/use-fn + (mf/deps markup-type from) (fn [] - (st/emit! (ptk/event ::ev/event - {::ev/name "copy-inspect-code" - :type markup-type})))) + (let [origin (if (= :workspace from) "workspace" "viewer")] + (st/emit! (ptk/event ::ev/event + {::ev/name "copy-inspect-code" + ::ev/origin origin + :type markup-type}))))) on-style-copied - (mf/use-callback + (mf/use-fn (mf/deps style-type) (fn [] - (st/emit! (ptk/event ::ev/event - {::ev/name "copy-inspect-style" - :type style-type})))) + (let [origin (if (= :workspace from) "workspace" "viewer")] + (st/emit! (ptk/event ::ev/event + {::ev/name "copy-inspect-style" + ::ev/origin origin + :type style-type}))))) {on-markup-pointer-down :on-pointer-down on-markup-lost-pointer-capture :on-lost-pointer-capture diff --git a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs index e701734dc..1ab908b04 100644 --- a/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/right_sidebar.cljs @@ -40,16 +40,16 @@ (mf/defc right-sidebar [{:keys [frame page objects file selected shapes page-id file-id share-id from on-change-section on-expand] - :or {from :inspect}}] - (let [section (mf/use-state :info #_:code) - objects (or objects (:objects page)) - shapes (or shapes - (resolve-shapes objects selected)) - first-shape (first shapes) - page-id (or page-id (:id page)) - file-id (or file-id (:id file)) + :or {from :viewer}}] + (let [section (mf/use-state :info #_:code) + objects (or objects (:objects page)) + shapes (or shapes + (resolve-shapes objects selected)) + first-shape (first shapes) + page-id (or page-id (:id page)) + file-id (or file-id (:id file)) - libraries (get-libraries from) + libraries (get-libraries from) file (mf/deref refs/viewer-file) components-v2 (dm/get-in file [:data :options :components-v2]) @@ -83,7 +83,7 @@ (handle-change-tab :info)))) [:aside {:class (stl/css-case :settings-bar-right true - :viewer-code (= from :inspect))} + :viewer-code (= from :viewer))} (if (seq shapes) [:div {:class (stl/css :tool-windows)} [:div {:class (stl/css :shape-row)} diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 05be4666e..ea5414360 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -104,7 +104,9 @@ {:on-change-tab on-change-tab :selected section :collapsable false - :content-class (stl/css-case :content-class true :inspect (= section :inspect)) + :content-class (stl/css-case + :content-class true + :inspect (= section :inspect)) :header-class (stl/css :tab-spacing)} [:& tab-element {:id :design :title (tr "workspace.options.design")}