mirror of
https://github.com/penpot/penpot.git
synced 2025-05-06 12:55:54 +02:00
🎉 Add export event for telemetry
This commit is contained in:
parent
bf60bf1848
commit
2a13c2ec00
6 changed files with 65 additions and 39 deletions
|
@ -49,8 +49,7 @@
|
||||||
|
|
||||||
|
|
||||||
(defn show-workspace-export-dialog
|
(defn show-workspace-export-dialog
|
||||||
([] (show-workspace-export-dialog nil))
|
[{:keys [selected origin]}]
|
||||||
([{:keys [selected]}]
|
|
||||||
(ptk/reify ::show-workspace-export-dialog
|
(ptk/reify ::show-workspace-export-dialog
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -73,7 +72,7 @@
|
||||||
(assoc :name (:name shape))))]
|
(assoc :name (:name shape))))]
|
||||||
|
|
||||||
(rx/of (modal/show :export-shapes
|
(rx/of (modal/show :export-shapes
|
||||||
{:exports (vec exports)})))))))
|
{:exports (vec exports) :origin origin}))))))
|
||||||
|
|
||||||
(defn show-viewer-export-dialog
|
(defn show-viewer-export-dialog
|
||||||
[{:keys [shapes page-id file-id share-id exports]}]
|
[{:keys [shapes page-id file-id share-id exports]}]
|
||||||
|
@ -90,7 +89,7 @@
|
||||||
(assoc :shape (dissoc shape :exports))
|
(assoc :shape (dissoc shape :exports))
|
||||||
(assoc :name (:name shape))
|
(assoc :name (:name shape))
|
||||||
(cond-> share-id (assoc :share-id share-id))))]
|
(cond-> share-id (assoc :share-id share-id))))]
|
||||||
(rx/of (modal/show :export-shapes {:exports (vec exports)})))))) #_TODO
|
(rx/of (modal/show :export-shapes {:exports (vec exports) :origin "viewer"})))))) #_TODO
|
||||||
|
|
||||||
(defn show-workspace-export-frames-dialog
|
(defn show-workspace-export-frames-dialog
|
||||||
[frames]
|
[frames]
|
||||||
|
@ -108,7 +107,7 @@
|
||||||
:name (:name frame)})]
|
:name (:name frame)})]
|
||||||
|
|
||||||
(rx/of (modal/show :export-frames
|
(rx/of (modal/show :export-frames
|
||||||
{:exports (vec exports)}))))))
|
{:exports (vec exports) :origin "workspace:menu"}))))))
|
||||||
|
|
||||||
(defn- initialize-export-status
|
(defn- initialize-export-status
|
||||||
[exports cmd resource]
|
[exports cmd resource]
|
||||||
|
|
|
@ -396,7 +396,7 @@
|
||||||
:command (ds/c-mod "shift+e")
|
:command (ds/c-mod "shift+e")
|
||||||
:subsections [:basics :main-menu]
|
:subsections [:basics :main-menu]
|
||||||
:fn #(st/emit!
|
:fn #(st/emit!
|
||||||
(de/show-workspace-export-dialog))}
|
(de/show-workspace-export-dialog {:origin "workspace:shortcuts"}))}
|
||||||
|
|
||||||
:toggle-snap-ruler-guide {:tooltip (ds/meta-shift "G")
|
:toggle-snap-ruler-guide {:tooltip (ds/meta-shift "G")
|
||||||
:command (ds/c-mod "shift+g")
|
:command (ds/c-mod "shift+g")
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
[app.common.colors :as clr]
|
[app.common.colors :as clr]
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.exports :as de]
|
[app.main.data.exports :as de]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
[app.util.strings :as ust]
|
[app.util.strings :as ust]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
|
[potok.v2.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def ^:private neutral-icon
|
(def ^:private neutral-icon
|
||||||
|
@ -35,10 +37,9 @@
|
||||||
(i/icon-xref :close (stl/css :close-icon)))
|
(i/icon-xref :close (stl/css :close-icon)))
|
||||||
|
|
||||||
(mf/defc export-multiple-dialog
|
(mf/defc export-multiple-dialog
|
||||||
[{:keys [exports title cmd no-selection]}]
|
[{:keys [exports title cmd no-selection origin]}]
|
||||||
(let [lstate (mf/deref refs/export)
|
(let [lstate (mf/deref refs/export)
|
||||||
in-progress? (:in-progress lstate)
|
in-progress? (:in-progress lstate)
|
||||||
|
|
||||||
exports (mf/use-state exports)
|
exports (mf/use-state exports)
|
||||||
|
|
||||||
all-exports (deref exports)
|
all-exports (deref exports)
|
||||||
|
@ -61,7 +62,11 @@
|
||||||
(st/emit! (modal/hide)
|
(st/emit! (modal/hide)
|
||||||
(de/request-multiple-export
|
(de/request-multiple-export
|
||||||
{:exports enabled-exports
|
{:exports enabled-exports
|
||||||
:cmd cmd})))
|
:cmd cmd})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes"
|
||||||
|
::ev/origin origin
|
||||||
|
:num-shapes (count enabled-exports)})))
|
||||||
|
|
||||||
on-toggle-enabled
|
on-toggle-enabled
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -186,23 +191,25 @@
|
||||||
(mf/defc export-shapes-dialog
|
(mf/defc export-shapes-dialog
|
||||||
{::mf/register modal/components
|
{::mf/register modal/components
|
||||||
::mf/register-as :export-shapes}
|
::mf/register-as :export-shapes}
|
||||||
[{:keys [exports]}]
|
[{:keys [exports origin]}]
|
||||||
(let [title (tr "dashboard.export-shapes.title")]
|
(let [title (tr "dashboard.export-shapes.title")]
|
||||||
[:& export-multiple-dialog
|
[:& export-multiple-dialog
|
||||||
{:exports exports
|
{:exports exports
|
||||||
:title title
|
:title title
|
||||||
:cmd :export-shapes
|
:cmd :export-shapes
|
||||||
:no-selection shapes-no-selection}]))
|
:no-selection shapes-no-selection
|
||||||
|
:origin origin}]))
|
||||||
|
|
||||||
(mf/defc export-frames
|
(mf/defc export-frames
|
||||||
{::mf/register modal/components
|
{::mf/register modal/components
|
||||||
::mf/register-as :export-frames}
|
::mf/register-as :export-frames}
|
||||||
[{:keys [exports]}]
|
[{:keys [exports origin]}]
|
||||||
(let [title (tr "dashboard.export-frames.title")]
|
(let [title (tr "dashboard.export-frames.title")]
|
||||||
[:& export-multiple-dialog
|
[:& export-multiple-dialog
|
||||||
{:exports exports
|
{:exports exports
|
||||||
:title title
|
:title title
|
||||||
:cmd :export-frames}]))
|
:cmd :export-frames
|
||||||
|
:origin origin}]))
|
||||||
|
|
||||||
(mf/defc export-progress-widget
|
(mf/defc export-progress-widget
|
||||||
{::mf/wrap [mf/memo]}
|
{::mf/wrap [mf/memo]}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.exports :as de]
|
[app.main.data.exports :as de]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :refer [tr c]]
|
[app.util.i18n :refer [tr c]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
|
[potok.v2.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(mf/defc exports
|
(mf/defc exports
|
||||||
|
@ -62,8 +64,14 @@
|
||||||
(cond-> share-id (assoc :share-id share-id)))
|
(cond-> share-id (assoc :share-id share-id)))
|
||||||
exports (mapv #(merge % defaults) @exports)]
|
exports (mapv #(merge % defaults) @exports)]
|
||||||
(if (= 1 (count exports))
|
(if (= 1 (count exports))
|
||||||
(st/emit! (de/request-simple-export {:export (first exports)}))
|
(st/emit!
|
||||||
(st/emit! (de/request-multiple-export {:exports exports :filename filename}))))))
|
(de/request-simple-export {:export (first exports)})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes" ::ev/origin "viewer" :num-shapes 1}))
|
||||||
|
(st/emit!
|
||||||
|
(de/request-multiple-export {:exports exports})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes" ::ev/origin "viewer" :num-shapes (count exports)}))))))
|
||||||
|
|
||||||
add-export
|
add-export
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
|
|
@ -508,7 +508,7 @@
|
||||||
(on-add-shared event))))
|
(on-add-shared event))))
|
||||||
|
|
||||||
on-export-shapes
|
on-export-shapes
|
||||||
(mf/use-fn #(st/emit! (de/show-workspace-export-dialog)))
|
(mf/use-fn #(st/emit! (de/show-workspace-export-dialog {:origin "workspace:menu"})))
|
||||||
|
|
||||||
on-export-shapes-key-down
|
on-export-shapes-key-down
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.exports :as de]
|
[app.main.data.exports :as de]
|
||||||
[app.main.data.workspace.shapes :as dwsh]
|
[app.main.data.workspace.shapes :as dwsh]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :refer [tr c]]
|
[app.util.i18n :refer [tr c]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
|
[potok.v2.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def exports-attrs
|
(def exports-attrs
|
||||||
|
@ -75,8 +77,12 @@
|
||||||
(cond-> sname
|
(cond-> sname
|
||||||
(some? suffix)
|
(some? suffix)
|
||||||
(str suffix))
|
(str suffix))
|
||||||
(st/emit! (de/request-simple-export {:export (merge export defaults)})))
|
(st/emit!
|
||||||
(st/emit! (de/show-workspace-export-dialog {:selected (reverse ids)})))
|
(de/request-simple-export {:export (merge export defaults)})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes" ::ev/origin "workspace:sidebar" :num-shapes 1})))
|
||||||
|
(st/emit!
|
||||||
|
(de/show-workspace-export-dialog {:selected (reverse ids) :origin "workspace:sidebar"})))
|
||||||
|
|
||||||
;; In other all cases we only allowed to have a single
|
;; In other all cases we only allowed to have a single
|
||||||
;; shape-id because multiple shape-ids are handled
|
;; shape-id because multiple shape-ids are handled
|
||||||
|
@ -88,8 +94,14 @@
|
||||||
exports (mapv #(merge % defaults) exports)]
|
exports (mapv #(merge % defaults) exports)]
|
||||||
(if (= 1 (count exports))
|
(if (= 1 (count exports))
|
||||||
(let [export (first exports)]
|
(let [export (first exports)]
|
||||||
(st/emit! (de/request-simple-export {:export export})))
|
(st/emit!
|
||||||
(st/emit! (de/request-multiple-export {:exports exports})))))))
|
(de/request-simple-export {:export export})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes" ::ev/origin "workspace:sidebar" :num-shapes 1})))
|
||||||
|
(st/emit!
|
||||||
|
(de/request-multiple-export {:exports exports})
|
||||||
|
(ptk/event
|
||||||
|
::ev/event {::ev/name "export-shapes" ::ev/origin "workspace:sidebar" :num-shapes (count exports)})))))))
|
||||||
|
|
||||||
;; TODO: maybe move to specific events for avoid to have this logic here?
|
;; TODO: maybe move to specific events for avoid to have this logic here?
|
||||||
add-export
|
add-export
|
||||||
|
|
Loading…
Add table
Reference in a new issue