mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
✨ Improve event registry.
This commit is contained in:
parent
b5b97f7626
commit
926fa483b9
25 changed files with 245 additions and 93 deletions
|
@ -72,7 +72,7 @@
|
|||
(update :workspace-drawing dissoc :comment)
|
||||
(update-in [:comments id] assoc (:id comment) comment)))]
|
||||
|
||||
(ptk/reify ::create-thread
|
||||
(ptk/reify ::create-comment-thread
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(->> (rp/mutation :create-comment-thread params)
|
||||
|
@ -94,6 +94,8 @@
|
|||
[{:keys [id is-resolved] :as thread}]
|
||||
(us/assert ::comment-thread thread)
|
||||
(ptk/reify ::update-comment-thread
|
||||
IDeref
|
||||
(-deref [_] {:is-resolved is-resolved})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -122,7 +124,7 @@
|
|||
(defn update-comment
|
||||
[{:keys [id content thread-id] :as comment}]
|
||||
(us/assert ::comment comment)
|
||||
(ptk/reify :update-comment
|
||||
(ptk/reify ::update-comment
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(d/update-in-when state [:comments thread-id id] assoc :content content))
|
||||
|
@ -135,7 +137,7 @@
|
|||
(defn delete-comment-thread
|
||||
[{:keys [id] :as thread}]
|
||||
(us/assert ::comment-thread thread)
|
||||
(ptk/reify :delete-comment-thread
|
||||
(ptk/reify ::delete-comment-thread
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
@ -150,7 +152,7 @@
|
|||
(defn delete-comment
|
||||
[{:keys [id thread-id] :as comment}]
|
||||
(us/assert ::comment comment)
|
||||
(ptk/reify :delete-comment
|
||||
(ptk/reify ::delete-comment
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(d/update-in-when state [:comments thread-id] dissoc id))
|
||||
|
@ -212,7 +214,7 @@
|
|||
(defn open-thread
|
||||
[{:keys [id] :as thread}]
|
||||
(us/assert ::comment-thread thread)
|
||||
(ptk/reify ::open-thread
|
||||
(ptk/reify ::open-comment-thread
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
@ -221,7 +223,7 @@
|
|||
|
||||
(defn close-thread
|
||||
[]
|
||||
(ptk/reify ::close-thread
|
||||
(ptk/reify ::close-comment-thread
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.fonts :as df]
|
||||
[app.main.data.media :as di]
|
||||
[app.main.data.users :as du]
|
||||
|
@ -386,6 +387,9 @@
|
|||
(us/assert ::us/email email)
|
||||
(us/assert ::us/keyword role)
|
||||
(ptk/reify ::invite-team-member
|
||||
IDeref
|
||||
(-deref [_] {:role role})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [{:keys [on-success on-error]
|
||||
|
@ -475,6 +479,10 @@
|
|||
(us/assert ::us/uuid id)
|
||||
(us/assert ::us/uuid team-id)
|
||||
(ptk/reify ::move-project
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{:id id :team-id team-id})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [{:keys [on-success on-error]
|
||||
|
@ -566,6 +574,10 @@
|
|||
[{:keys [id name] :as params}]
|
||||
(us/assert ::file params)
|
||||
(ptk/reify ::rename-file
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{::ev/origin "dashboard" :id id :name name})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
@ -585,6 +597,10 @@
|
|||
[{:keys [id is-shared] :as params}]
|
||||
(us/assert ::file params)
|
||||
(ptk/reify ::set-file-shared
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{::ev/origin "dashboard" :id id :shared is-shared})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
@ -663,12 +679,16 @@
|
|||
(us/assert ::set-of-uuid ids)
|
||||
(us/assert ::us/uuid project-id)
|
||||
(ptk/reify ::move-files
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{:num-files (count ids)
|
||||
:project-id project-id})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error rx/throw}} (meta params)]
|
||||
|
||||
(->> (rp/mutation! :move-files {:ids ids :project-id project-id})
|
||||
(rx/tap on-success)
|
||||
(rx/catch on-error))))))
|
||||
|
|
|
@ -71,18 +71,84 @@
|
|||
|
||||
;; --- EVENT TRANSLATION
|
||||
|
||||
(defmulti ^:private process-event ptk/type)
|
||||
(derive :app.main.data.comments/create-comment ::generic-action)
|
||||
(derive :app.main.data.comments/create-comment-thread ::generic-action)
|
||||
(derive :app.main.data.comments/delete-comment ::generic-action)
|
||||
(derive :app.main.data.comments/delete-comment-thread ::generic-action)
|
||||
(derive :app.main.data.comments/open-comment-thread ::generic-action)
|
||||
(derive :app.main.data.comments/update-comment ::generic-action)
|
||||
(derive :app.main.data.comments/update-comment-thread ::generic-action)
|
||||
(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/file-created ::generic-action)
|
||||
(derive :app.main.data.dashboard/invite-team-member ::generic-action)
|
||||
(derive :app.main.data.dashboard/leave-team ::generic-action)
|
||||
(derive :app.main.data.dashboard/move-files ::generic-action)
|
||||
(derive :app.main.data.dashboard/move-project ::generic-action)
|
||||
(derive :app.main.data.dashboard/project-created ::generic-action)
|
||||
(derive :app.main.data.dashboard/rename-file ::generic-action)
|
||||
(derive :app.main.data.dashboard/set-file-shared ::generic-action)
|
||||
(derive :app.main.data.dashboard/update-team-member-role ::generic-action)
|
||||
(derive :app.main.data.dashboard/update-team-photo ::generic-action)
|
||||
(derive :app.main.data.fonts/add-font ::generic-action)
|
||||
(derive :app.main.data.fonts/delete-font ::generic-action)
|
||||
(derive :app.main.data.fonts/delete-font-variant ::generic-action)
|
||||
(derive :app.main.data.users/logout ::generic-action)
|
||||
(derive :app.main.data.users/request-email-change ::generic-action)
|
||||
(derive :app.main.data.users/update-password ::generic-action)
|
||||
(derive :app.main.data.users/update-photo ::generic-action)
|
||||
(derive :app.main.data.workspace.comments/open-comment-thread ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/add-color ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/add-media ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/add-typography ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/delete-color ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/delete-media ::generic-action)
|
||||
(derive :app.main.data.workspace.libraries/delete-typography ::generic-action)
|
||||
(derive :app.main.data.workspace.persistence/attach-library ::generic-action)
|
||||
(derive :app.main.data.workspace.persistence/detach-library ::generic-action)
|
||||
(derive :app.main.data.workspace.persistence/set-file-shard ::generic-action)
|
||||
(derive :app.main.data.workspace/create-page ::generic-action)
|
||||
(derive :app.main.data.workspace/set-workspace-layout ::generic-action)
|
||||
|
||||
|
||||
(defmulti process-event ptk/type)
|
||||
(defmethod process-event :default [_] nil)
|
||||
|
||||
(defmethod process-event ::event
|
||||
[event]
|
||||
(let [data (deref event)]
|
||||
(let [data (deref event)
|
||||
origin (::origin data)]
|
||||
(when (::name data)
|
||||
(d/without-nils
|
||||
{:type (::type data "action")
|
||||
:name (::name data)
|
||||
:context (::context data)
|
||||
:props (dissoc data ::name ::type ::context)}))))
|
||||
:props (-> data
|
||||
(dissoc ::name)
|
||||
(dissoc ::type)
|
||||
(dissoc ::origin)
|
||||
(dissoc ::context)
|
||||
(cond-> origin (assoc :origin origin)))}))))
|
||||
|
||||
(defmethod process-event ::generic-action
|
||||
[event]
|
||||
(let [type (ptk/type event)
|
||||
mdata (meta event)
|
||||
data (if (satisfies? IDeref event)
|
||||
(deref event)
|
||||
{})
|
||||
|
||||
name (or (::name mdata)
|
||||
(name type))]
|
||||
|
||||
{:type "action"
|
||||
:name (name type)
|
||||
:props (merge data (d/without-nils (::props mdata)))
|
||||
:context (d/without-nils
|
||||
{:event-origin (::origin mdata)
|
||||
:event-namespace (namespace type)
|
||||
:event-symbol (name type)})}))
|
||||
|
||||
(defmethod process-event :app.util.router/navigated
|
||||
[event]
|
||||
|
@ -113,42 +179,6 @@
|
|||
:profile-id (:id data)
|
||||
:props (d/without-nils props)}))
|
||||
|
||||
(defmethod process-event :app.main.data.dashboard/project-created
|
||||
[event]
|
||||
(let [data (deref event)]
|
||||
{:type "action"
|
||||
:name "create-project"
|
||||
:props {:id (:id data)
|
||||
:team-id (:team-id data)}}))
|
||||
|
||||
(defmethod process-event :app.main.data.dashboard/file-created
|
||||
[event]
|
||||
(let [data (deref event)]
|
||||
{:type "action"
|
||||
:name "create-file"
|
||||
:props {:id (:id data)
|
||||
:project-id (:project-id data)}}))
|
||||
|
||||
(defmethod process-event :app.main.data.workspace/create-page
|
||||
[event]
|
||||
(let [data (deref event)]
|
||||
{:type "action"
|
||||
:name "create-page"
|
||||
:props {:id (:id data)
|
||||
:file-id (:file-id data)
|
||||
:project-id (:project-id data)}}))
|
||||
|
||||
(defn- event->generic-action
|
||||
[_ name]
|
||||
{:type "action"
|
||||
:name name
|
||||
:props {}})
|
||||
|
||||
(defmethod process-event :app.main.data.users/logout
|
||||
[event]
|
||||
(event->generic-action event "signout"))
|
||||
|
||||
|
||||
;; --- MAIN LOOP
|
||||
|
||||
(defn- append-to-buffer
|
||||
|
@ -203,8 +233,7 @@
|
|||
|
||||
ptk/EffectEvent
|
||||
(effect [_ _ stream]
|
||||
(let [events (methods process-event)
|
||||
session (atom nil)
|
||||
(let [session (atom nil)
|
||||
|
||||
profile (->> (rx/from-atom storage {:emit-current-value? true})
|
||||
(rx/map :profile)
|
||||
|
@ -215,12 +244,9 @@
|
|||
(rx/with-latest-from profile)
|
||||
(rx/map (fn [result]
|
||||
(let [event (aget result 0)
|
||||
profile-id (aget result 1)
|
||||
type (ptk/type event)
|
||||
impl-fn (get events type)]
|
||||
(when (fn? impl-fn)
|
||||
(some-> (impl-fn event)
|
||||
(update :profile-id #(or % profile-id)))))))
|
||||
profile-id (aget result 1)]
|
||||
(some-> (process-event event)
|
||||
(update :profile-id #(or % profile-id))))))
|
||||
(rx/filter :profile-id)
|
||||
(rx/map (fn [event]
|
||||
(let [session* (or @session (dt/now))
|
||||
|
|
|
@ -187,6 +187,9 @@
|
|||
(defn add-font
|
||||
[font]
|
||||
(ptk/reify ::add-font
|
||||
IDeref
|
||||
(-deref [_] (select-keys font [:font-family :font-style :font-weight]))
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update state :dashboard-fonts assoc (:id font) font))))
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
[app.common.transit :as t]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
|
@ -373,6 +374,10 @@
|
|||
[id name]
|
||||
{:pre [(uuid? id) (string? name)]}
|
||||
(ptk/reify ::rename-file
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{:ev/origin "workspace" :id id :name name})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-file :name] name))
|
||||
|
@ -1247,7 +1252,10 @@
|
|||
(defn go-to-layout
|
||||
[layout]
|
||||
(us/verify ::layout-flag layout)
|
||||
(ptk/reify ::go-to-layout
|
||||
(ptk/reify ::set-workspace-layout
|
||||
IDeref
|
||||
(-deref [_] {:layout layout})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [project-id (get-in state [:workspace-project :id])
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.math :as mth]
|
||||
[app.common.spec :as us]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
[app.main.streams :as ms]
|
||||
|
@ -89,7 +90,7 @@
|
|||
(defn navigate
|
||||
[thread]
|
||||
(us/assert ::dcm/comment-thread thread)
|
||||
(ptk/reify ::navigate
|
||||
(ptk/reify ::open-comment-thread
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(let [pparams {:project-id (:project-id thread)
|
||||
|
|
|
@ -83,12 +83,15 @@
|
|||
|
||||
(defn add-color
|
||||
[color]
|
||||
(let [id (uuid/next)
|
||||
color (assoc color
|
||||
:id id
|
||||
:name (default-color-name color))]
|
||||
(let [id (uuid/next)
|
||||
color (-> color
|
||||
(assoc :id id)
|
||||
(assoc :name (default-color-name color)))]
|
||||
(us/assert ::cp/color color)
|
||||
(ptk/reify ::add-color
|
||||
IDeref
|
||||
(-deref [_] color)
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [it _ _]
|
||||
(let [rchg {:type :add-color
|
||||
|
@ -211,6 +214,9 @@
|
|||
(let [typography (update typography :id #(or % (uuid/next)))]
|
||||
(us/assert ::cp/typography typography)
|
||||
(ptk/reify ::add-typography
|
||||
IDeref
|
||||
(-deref [_] typography)
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [it _ _]
|
||||
(let [rchg {:type :add-typography
|
||||
|
@ -258,17 +264,20 @@
|
|||
:undo-changes [uchg]
|
||||
:origin it}))))))
|
||||
|
||||
(def add-component
|
||||
"Add a new component to current file library, from the currently selected shapes."
|
||||
(ptk/reify ::add-component
|
||||
|
||||
(defn- add-component2
|
||||
"This is the second step of the component creation."
|
||||
[selected]
|
||||
(ptk/reify ::add-component2
|
||||
IDeref
|
||||
(-deref [_] {:num-shapes (count selected)})
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [file-id (:current-file-id state)
|
||||
page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
selected (cp/clean-loops objects selected)
|
||||
shapes (dwg/shapes-for-grouping objects selected)]
|
||||
shapes (dwg/shapes-for-grouping objects selected)]
|
||||
(when-not (empty? shapes)
|
||||
(let [[group rchanges uchanges]
|
||||
(dwlh/generate-add-component shapes objects page-id file-id)]
|
||||
|
@ -278,6 +287,20 @@
|
|||
:origin it})
|
||||
(dwc/select-shapes (d/ordered-set (:id group)))))))))))
|
||||
|
||||
(defn add-component
|
||||
"Add a new component to current file library, from the currently selected shapes.
|
||||
This operation is made in two steps, first one for calculate the
|
||||
shapes that will be part of the component and the second one with
|
||||
the component creation."
|
||||
[]
|
||||
(ptk/reify ::add-component
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cp/clean-loops objects))]
|
||||
(rx/of (add-component2 selected))))))
|
||||
|
||||
(defn rename-component
|
||||
"Rename the component with the given id, in the current file library."
|
||||
[id new-name]
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.fonts :as df]
|
||||
[app.main.data.media :as di]
|
||||
[app.main.data.messages :as dm]
|
||||
|
@ -275,6 +276,10 @@
|
|||
[id is-shared]
|
||||
{:pre [(uuid? id) (boolean? is-shared)]}
|
||||
(ptk/reify ::set-file-shared
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{::ev/origin "workspace" :id id :shared is-shared})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-file :is-shared] is-shared))
|
||||
|
@ -313,7 +318,7 @@
|
|||
|
||||
(defn link-file-to-library
|
||||
[file-id library-id]
|
||||
(ptk/reify ::link-file-to-library
|
||||
(ptk/reify ::attach-library
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [fetched #(assoc-in %2 [:workspace-libraries (:id %1)] %1)
|
||||
|
@ -325,7 +330,7 @@
|
|||
|
||||
(defn unlink-file-from-library
|
||||
[file-id library-id]
|
||||
(ptk/reify ::unlink-file-from-library
|
||||
(ptk/reify ::detach-library
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(d/dissoc-in state [:workspace-libraries library-id]))
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
|
||||
:create-component {:tooltip (ds/meta "K")
|
||||
:command (ds/c-mod "k")
|
||||
:fn #(st/emit! dwl/add-component)}
|
||||
:fn #(st/emit! (dwl/add-component))}
|
||||
|
||||
:detach-component {:tooltip (ds/meta-shift "K")
|
||||
:command (ds/c-mod "shift+k")
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
[beicon.core :as rx]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc copy-button [{:keys [data]}]
|
||||
(mf/defc copy-button [{:keys [data on-copied]}]
|
||||
(let [just-copied (mf/use-state false)]
|
||||
(mf/use-effect
|
||||
(mf/deps @just-copied)
|
||||
(fn []
|
||||
(when @just-copied
|
||||
(when (fn? on-copied)
|
||||
(on-copied))
|
||||
(let [sub (timers/schedule 1000 #(reset! just-copied false))]
|
||||
;; On unmount we dispose the timer
|
||||
#(rx/-dispose sub)))))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.dashboard.comments
|
||||
(:require
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.workspace.comments :as dwcm]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
|
@ -15,13 +16,18 @@
|
|||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc comments-section
|
||||
[{:keys [profile team]}]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps team)
|
||||
(st/emitf (dcm/retrieve-unread-comment-threads (:id team))))
|
||||
(fn []
|
||||
(st/emit! (dcm/retrieve-unread-comment-threads (:id team))
|
||||
(ptk/event ::ev/event {::ev/name "open-comment-notifications"
|
||||
::ev/origin "dashboard"}))))
|
||||
|
||||
(let [show-dropdown? (mf/use-state false)
|
||||
show-dropdown (mf/use-fn #(reset! show-dropdown? true))
|
||||
|
@ -38,7 +44,8 @@
|
|||
on-navigate
|
||||
(mf/use-callback
|
||||
(fn [thread]
|
||||
(st/emit! (dwcm/navigate thread))))]
|
||||
(st/emit! (-> (dwcm/navigate thread)
|
||||
(with-meta {::ev/origin "dashboard"})))))]
|
||||
|
||||
[:div.dashboard-comments-section
|
||||
[:div.button
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.dashboard.export
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.icons :as i]
|
||||
|
@ -14,6 +15,7 @@
|
|||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(def ^:const options [:all :merge :detach])
|
||||
|
@ -58,6 +60,10 @@
|
|||
|
||||
start-export
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "export-files"
|
||||
:num-files (count (:files @state))
|
||||
:option @selected-option}))
|
||||
|
||||
(swap! state assoc :status :exporting)
|
||||
(->> (uw/ask-many!
|
||||
{:cmd :export-file
|
||||
|
@ -117,7 +123,7 @@
|
|||
(let [selected? (= @selected-option type)]
|
||||
[:div.export-option {:class (when selected? "selected")}
|
||||
[:label.option-container
|
||||
[:h3 (tr (str "dashboard.export.options." (d/name type) ".title"))]
|
||||
[:h3 (tr (str "dashboard.export.options." (d/name type) ".title"))]
|
||||
[:p (tr (str "dashboard.export.options." (d/name type) ".message"))]
|
||||
[:input {:type "radio"
|
||||
:checked selected?
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.repo :as rp]
|
||||
|
@ -159,6 +160,8 @@
|
|||
(mf/use-callback
|
||||
(mf/deps files current-team-id)
|
||||
(fn [_]
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "export-files"
|
||||
:num-files (count files)}))
|
||||
(->> (rx/from files)
|
||||
(rx/flat-map
|
||||
(fn [file]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.dashboard.files
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.dashboard.grid :refer [grid]]
|
||||
|
@ -62,7 +63,8 @@
|
|||
(if (:edition @local)
|
||||
[:& inline-edition {:content (:name project)
|
||||
:on-end (fn [name]
|
||||
(st/emit! (dd/rename-project (assoc project :name name)))
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "project"})))
|
||||
(swap! local assoc :edition false))}]
|
||||
[:div.dashboard-title
|
||||
[:h1 {:on-double-click on-edit}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.dashboard.import
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.file-uploader :refer [file-uploader]]
|
||||
|
@ -17,6 +18,7 @@
|
|||
[app.util.keyboard :as kbd]
|
||||
[app.util.logging :as log]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(log/set-level! :debug)
|
||||
|
@ -214,6 +216,9 @@
|
|||
import-files
|
||||
(mf/use-callback
|
||||
(fn [project-id files]
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "import-files"
|
||||
:num-files (count files)}))
|
||||
|
||||
(->> (uw/ask-many!
|
||||
{:cmd :import-files
|
||||
:project-id project-id
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.dashboard.projects
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.dashboard.grid :refer [line-grid]]
|
||||
|
@ -74,7 +75,8 @@
|
|||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [name]
|
||||
(st/emit! (dd/rename-project (assoc project :name name)))
|
||||
(st/emit! (-> (dd/rename-project (assoc project :name name))
|
||||
(with-meta {::ev/origin "dashboard"})))
|
||||
(swap! local assoc :edition? false)))
|
||||
|
||||
on-file-created
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
[app.common.spec :as us]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.refs :as refs]
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.users :as du]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.settings.sidebar
|
||||
(:require
|
||||
[app.config :as cf]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.users :as du]
|
||||
[app.main.store :as st]
|
||||
|
@ -14,6 +15,7 @@
|
|||
[app.main.ui.icons :as i]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc sidebar-content
|
||||
|
@ -52,6 +54,7 @@
|
|||
(mf/use-callback
|
||||
(fn [event]
|
||||
(let [version (:main @cf/version)]
|
||||
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
|
||||
(if (and (.-ctrlKey ^js event)
|
||||
(.-altKey ^js event))
|
||||
(st/emit! (modal/show {:type :onboarding}))
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as geom]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.comments :as cmt]
|
||||
|
@ -21,7 +22,6 @@
|
|||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
|
||||
(mf/defc comments-menu
|
||||
[]
|
||||
(let [{cmode :mode cshow :show} (mf/deref refs/comments-local)
|
||||
|
@ -105,7 +105,8 @@
|
|||
(fn [thread]
|
||||
(if (= (:open cstate) (:id thread))
|
||||
(st/emit! (dcm/close-thread))
|
||||
(st/emit! (dcm/open-thread thread)))))
|
||||
(st/emit! (-> (dcm/open-thread thread)
|
||||
(with-meta {::ev/origin "viewer"}))))))
|
||||
|
||||
on-click
|
||||
(mf/use-callback
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
(ns app.main.ui.viewer.handoff.code
|
||||
(:require
|
||||
["js-beautify" :as beautify]
|
||||
[app.main.data.events :as ev]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.ui.components.code-block :refer [code-block]]
|
||||
[app.main.ui.components.copy-button :refer [copy-button]]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.store :as st]
|
||||
[potok.core :as ptk]
|
||||
[app.util.code-gen :as cg]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]
|
||||
|
@ -48,7 +51,25 @@
|
|||
(format-code "css"))
|
||||
|
||||
markup-code (-> (mf/use-memo (mf/deps shapes) #(generate-markup-code @markup-type shapes))
|
||||
(format-code "svg"))]
|
||||
(format-code "svg"))
|
||||
|
||||
on-markup-copied
|
||||
(mf/use-callback
|
||||
(mf/deps @markup-type)
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event
|
||||
{::ev/name "copy-handoff-code"
|
||||
:type @markup-type}))))
|
||||
|
||||
on-style-copied
|
||||
(mf/use-callback
|
||||
(mf/deps @style-type)
|
||||
(fn []
|
||||
(st/emit! (ptk/event ::ev/event
|
||||
{::ev/name "copy-handoff-style"
|
||||
:type @style-type}))))
|
||||
]
|
||||
|
||||
[:div.element-options
|
||||
[:div.code-block
|
||||
[:div.code-row-lang
|
||||
|
@ -62,7 +83,8 @@
|
|||
{:on-click on-expand }
|
||||
i/full-screen]
|
||||
|
||||
[:& copy-button { :data style-code }]]
|
||||
[:& copy-button {:data style-code
|
||||
:on-copied on-style-copied}]]
|
||||
|
||||
[:div.code-row-display
|
||||
[:& code-block {:type @style-type
|
||||
|
@ -78,8 +100,8 @@
|
|||
{:on-click on-expand}
|
||||
i/full-screen]
|
||||
|
||||
[:& copy-button { :data markup-code }]]
|
||||
|
||||
[:& copy-button {:data markup-code
|
||||
:on-copied on-markup-copied}]]
|
||||
[:div.code-row-display
|
||||
[:& code-block {:type @markup-type
|
||||
:code markup-code}]]]
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.workspace.comments
|
||||
(:require
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.comments :as dwcm]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -77,8 +78,10 @@
|
|||
(when (not= page-id (:page-id thread))
|
||||
(st/emit! (dw/go-to-page (:page-id thread))))
|
||||
(tm/schedule
|
||||
(st/emitf (dwcm/center-to-comment-thread thread)
|
||||
(dcm/open-thread thread)))))]
|
||||
(fn []
|
||||
(st/emit! (dwcm/center-to-comment-thread thread)
|
||||
(-> (dcm/open-thread thread)
|
||||
(with-meta {::ev/origin "workspace"})))))))]
|
||||
|
||||
[:div.comments-section.comment-threads-section
|
||||
[:div.workspace-comment-threads-sidebar-header
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
do-unmask-group (st/emitf dw/unmask-group)
|
||||
do-flip-vertical (st/emitf (dw/flip-vertical-selected))
|
||||
do-flip-horizontal (st/emitf (dw/flip-horizontal-selected))
|
||||
do-add-component (st/emitf dwl/add-component)
|
||||
do-add-component (st/emitf (dwl/add-component))
|
||||
do-detach-component (st/emitf (dwl/detach-component id))
|
||||
do-reset-component (st/emitf (dwl/reset-component id))
|
||||
do-start-editing (fn []
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[app.main.ui.icons :as i]
|
||||
[app.util.data :refer [matches-search]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [t tr]]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
[rumext.alpha :as mf]))
|
||||
|
@ -78,7 +78,7 @@
|
|||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [library-id]
|
||||
(st/emit! (dw/unlink-file-from-library (:id file) library-id)
|
||||
(st/emit! (dw/unlink-file-from-library (:id file) library-id)
|
||||
(dwl/sync-file (:id file) library-id))))]
|
||||
[:*
|
||||
[:div.section
|
||||
|
@ -151,8 +151,6 @@
|
|||
::mf/register-as :libraries-dialog}
|
||||
[{:keys [] :as ctx}]
|
||||
(let [selected-tab (mf/use-state :libraries)
|
||||
|
||||
locale (mf/deref i18n/locale)
|
||||
project (mf/deref refs/workspace-project)
|
||||
file (mf/deref workspace-file)
|
||||
libraries (->> (mf/deref refs/workspace-libraries)
|
||||
|
@ -176,11 +174,11 @@
|
|||
[:div.header-item
|
||||
{:class (dom/classnames :active (= @selected-tab :libraries))
|
||||
:on-click #(change-tab :libraries)}
|
||||
(t locale "workspace.libraries.libraries")]
|
||||
(tr "workspace.libraries.libraries")]
|
||||
[:div.header-item
|
||||
{:class (dom/classnames :active (= @selected-tab :updates))
|
||||
:on-click #(change-tab :updates)}
|
||||
(t locale "workspace.libraries.updates")]]
|
||||
(tr "workspace.libraries.updates")]]
|
||||
[:div.libraries-content
|
||||
(case @selected-tab
|
||||
:libraries
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.spec :as us]
|
||||
[app.common.text :as txt]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.colors :as dc]
|
||||
|
@ -39,6 +40,7 @@
|
|||
[cljs.spec.alpha :as s]
|
||||
[cuerdas.core :as str]
|
||||
[okulary.core :as l]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
; TODO: refactor to remove duplicate code and less parameter passing.
|
||||
|
@ -621,7 +623,9 @@
|
|||
(fn [blobs]
|
||||
(let [params {:file-id file-id
|
||||
:blobs (seq blobs)}]
|
||||
(st/emit! (dw/upload-media-asset params)))))
|
||||
(st/emit! (dw/upload-media-asset params)
|
||||
(ptk/event ::ev/event {::ev/name "add-asset-to-library"
|
||||
:asset-type "graphics"})))))
|
||||
|
||||
on-delete
|
||||
(mf/use-callback
|
||||
|
@ -977,7 +981,9 @@
|
|||
(mf/use-callback
|
||||
(mf/deps file-id)
|
||||
(fn [event]
|
||||
(st/emitf (dwl/set-assets-box-open file-id :colors true))
|
||||
(st/emit! (dwl/set-assets-box-open file-id :colors true)
|
||||
(ptk/event ::ev/event {::ev/name "add-asset-to-library"
|
||||
:asset-type "color"}))
|
||||
(modal/show! :colorpicker
|
||||
{:x (.-clientX event)
|
||||
:y (.-clientY event)
|
||||
|
@ -1150,7 +1156,9 @@
|
|||
(mf/use-callback
|
||||
(mf/deps file-id)
|
||||
(fn [_]
|
||||
(st/emit! (dwl/add-typography txt/default-typography))))
|
||||
(st/emit! (dwl/add-typography txt/default-typography)
|
||||
(ptk/event ::ev/event {::ev/name "add-asset-to-library"
|
||||
:asset-type "typography"}))))
|
||||
|
||||
handle-change
|
||||
(mf/use-callback
|
||||
|
|
Loading…
Add table
Reference in a new issue