From 1cc65c69b74ad23cba8b158c873ad3ad8a21281e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 29 Feb 2024 13:50:12 +0100 Subject: [PATCH] :sparkles: Add audit events for inspect tab usage On workspace and viewer --- frontend/src/app/main/data/viewer.cljs | 6 ++++++ frontend/src/app/main/data/workspace/layout.cljs | 11 ++++++++++- frontend/src/app/main/ui/viewer/header.cljs | 5 +++-- frontend/src/app/main/ui/workspace/sidebar.cljs | 10 ++++------ .../app/main/ui/workspace/sidebar/options.cljs | 16 ++++++---------- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index a698e567c..a45e75939 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -16,6 +16,7 @@ [app.common.types.shape-tree :as ctt] [app.common.types.shape.interactions :as ctsi] [app.main.data.comments :as dcm] + [app.main.data.events :as ev] [app.main.data.fonts :as df] [app.main.features :as features] [app.main.repo :as rp] @@ -546,6 +547,11 @@ (defn go-to-section [section] (ptk/reify ::go-to-section + ev/Event + (-data [_] + {::ev/origin "viewer" + :section (name section)}) + ptk/UpdateEvent (update [_ state] (assoc state :viewer-overlays [])) diff --git a/frontend/src/app/main/data/workspace/layout.cljs b/frontend/src/app/main/data/workspace/layout.cljs index 9c7ad57a0..0185c5884 100644 --- a/frontend/src/app/main/data/workspace/layout.cljs +++ b/frontend/src/app/main/data/workspace/layout.cljs @@ -8,6 +8,7 @@ "Workspace layout management events and helpers." (:require [app.common.data.macros :as dm] + [app.main.data.events :as ev] [app.util.storage :refer [storage]] [clojure.set :as set] [potok.v2.core :as ptk])) @@ -114,8 +115,16 @@ (defn set-options-mode [mode] - (dm/assert! (contains? valid-options-mode mode)) + (dm/assert! + "expected valid options mode" + (contains? valid-options-mode mode)) + (ptk/reify ::set-options-mode + ev/Event + (-data [_] + {::ev/origin "workspace:sidebar" + :mode (name mode)}) + ptk/UpdateEvent (update [_ state] (assoc-in state [:workspace-global :options-mode] mode)))) diff --git a/frontend/src/app/main/ui/viewer/header.cljs b/frontend/src/app/main/ui/viewer/header.cljs index 7cef2b214..e37f0e3b9 100644 --- a/frontend/src/app/main/ui/viewer/header.cljs +++ b/frontend/src/app/main/ui/viewer/header.cljs @@ -269,7 +269,8 @@ (mf/deps permissions) (fn [] (if (:is-logged permissions) - (st/emit! dv/close-thumbnails-panel (dv/go-to-section :inspect)) + (st/emit! dv/close-thumbnails-panel + (dv/go-to-section :inspect)) (open-login-dialog)))) navigate @@ -279,11 +280,11 @@ (let [section (-> (dom/get-current-target event) (dom/get-data "value") (keyword))] - (if (or (= section :interactions) (:is-logged permissions)) (st/emit! (dv/go-to-section section)) (open-login-dialog)))))] + [:header {:class (stl/css-case :viewer-header true :fullscreen (mf/deref fullscreen-ref))} [:div {:class (stl/css :nav-zone)} diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs index 9c27fff3a..2e2ab4a39 100644 --- a/frontend/src/app/main/ui/workspace/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar.cljs @@ -27,7 +27,6 @@ [app.main.ui.workspace.sidebar.sitemap :refer [sitemap]] [app.util.debug :as dbg] [app.util.i18n :refer [tr]] - [app.util.object :as obj] [rumext.v2 :as mf])) ;; --- Left Sidebar (Component) @@ -157,10 +156,9 @@ (set-size (if (> size 276) 276 768)))) props - (-> props - (obj/clone) - (obj/set! "on-change-section" handle-change-section) - (obj/set! "on-expand" handle-expand))] + (mf/spread props + :on-change-section handle-change-section + :on-expand handle-expand)] [:& (mf/provider muc/sidebar) {:value :right} [:aside {:class (stl/css-case :right-settings-bar true @@ -186,7 +184,7 @@ [:& comments-sidebar] (true? is-history?) - [:& history-toolbox] + [:> history-toolbox {}] :else [:> options-toolbox props])]]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 0a950b453..05be4666e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -37,7 +37,6 @@ [app.main.ui.workspace.sidebar.options.shapes.svg-raw :as svg-raw] [app.main.ui.workspace.sidebar.options.shapes.text :as text] [app.util.i18n :as i18n :refer [tr]] - [app.util.object :as obj] [rumext.v2 :as mf])) ;; --- Options @@ -75,7 +74,8 @@ (mf/defc options-content - {::mf/wrap [mf/memo]} + {::mf/memo true + ::mf/props :obj} [{:keys [selected section shapes shapes-with-children page-id file-id on-change-section on-expand]}] (let [drawing (mf/deref refs/workspace-drawing) objects (mf/deref refs/workspace-page-objects) @@ -172,14 +172,10 @@ ;; need on multiple selection in majority of cases (mf/defc options-toolbox - {::mf/wrap [mf/memo] - ::mf/wrap-props false} - [props] - (let [section (obj/get props "section") - selected (obj/get props "selected") - on-change-section (obj/get props "on-change-section") - on-expand (obj/get props "on-expand") - page-id (mf/use-ctx ctx/current-page-id) + {::mf/memo true + ::mf/props :obj} + [{:keys [section selected on-change-section on-expand]}] + (let [page-id (mf/use-ctx ctx/current-page-id) file-id (mf/use-ctx ctx/current-file-id) shapes (mf/deref refs/selected-objects) shapes-with-children (mf/deref refs/selected-shapes-with-children)]