mirror of
https://github.com/penpot/penpot.git
synced 2025-03-27 23:21:47 -05:00
Merge pull request #5584 from penpot/ddb-comments-fixes
✨ Open comments from email with parameter
This commit is contained in:
commit
0d70ceb264
4 changed files with 47 additions and 20 deletions
|
@ -47,13 +47,14 @@
|
|||
(str/join "")))
|
||||
|
||||
(defn- format-comment-url
|
||||
[{:keys [team-id file-id page-id]}]
|
||||
[thread {:keys [team-id file-id page-id]}]
|
||||
(str/ffmt "%/#/workspace?%"
|
||||
(cf/get :public-uri)
|
||||
(uri/map->query-string
|
||||
{:file-id file-id
|
||||
:page-id page-id
|
||||
:team-id team-id})))
|
||||
:team-id team-id
|
||||
:comment-id (:id thread)})))
|
||||
|
||||
(defn- format-comment-ref
|
||||
[{:keys [seqn]} {:keys [file-name page-name]}]
|
||||
|
@ -89,7 +90,7 @@
|
|||
|
||||
comment-reference (format-comment-ref thread params)
|
||||
comment-content (format-comment comment)
|
||||
comment-url (format-comment-url params)
|
||||
comment-url (format-comment-url thread params)
|
||||
|
||||
;; Users mentioned in this comment
|
||||
comment-mentions
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
[app.main.data.workspace.bool :as dwb]
|
||||
[app.main.data.workspace.collapse :as dwco]
|
||||
[app.main.data.workspace.colors :as dwcl]
|
||||
[app.main.data.workspace.comments :as dwcm]
|
||||
[app.main.data.workspace.drawing :as dwd]
|
||||
[app.main.data.workspace.edition :as dwe]
|
||||
[app.main.data.workspace.fix-broken-shapes :as fbs]
|
||||
|
@ -356,6 +357,13 @@
|
|||
(rx/take 1)
|
||||
(rx/map zoom-to-frame)))
|
||||
|
||||
(when-let [comment-id (some-> rparams :comment-id parse-uuid)]
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::workspace-initialized))
|
||||
(rx/observe-on :async)
|
||||
(rx/take 1)
|
||||
(rx/map #(dwcm/navigate-to-comment-id comment-id))))
|
||||
|
||||
(->> stream
|
||||
(rx/filter dch/commit?)
|
||||
(rx/map deref)
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.data.workspace.comments
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.changes-builder :as pcb]
|
||||
[app.common.geom.point :as gpt]
|
||||
|
@ -16,12 +17,14 @@
|
|||
[app.main.data.comments :as dcmt]
|
||||
[app.main.data.common :as dcm]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.common :as dwco]
|
||||
[app.main.data.workspace.drawing :as dwd]
|
||||
[app.main.data.workspace.edition :as dwe]
|
||||
[app.main.data.workspace.selection :as dws]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.viewport :as dwv]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.router :as rt]
|
||||
[app.main.streams :as ms]
|
||||
[app.util.mouse :as mse]
|
||||
[beicon.v2.core :as rx]
|
||||
|
@ -64,8 +67,8 @@
|
|||
(:open local) (rx/of (dcmt/close-thread))
|
||||
|
||||
:else
|
||||
(rx/of (dw/clear-edition-mode)
|
||||
(dw/deselect-all true)))))))
|
||||
(rx/of (dwe/clear-edition-mode)
|
||||
(dws/deselect-all true)))))))
|
||||
|
||||
;; Event responsible of the what should be executed when user clicked
|
||||
;; on the comments layer. An option can be create a new draft thread,
|
||||
|
@ -200,3 +203,31 @@
|
|||
(filter (comp frame-ids? :frame-id))
|
||||
(map build-move-event)
|
||||
(rx/from))))))
|
||||
|
||||
(defn navigate-to-comment
|
||||
[thread]
|
||||
(ptk/reify ::navigate-to-comment
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(rx/concat
|
||||
(rx/of
|
||||
(rt/nav :workspace
|
||||
(-> (rt/get-params state)
|
||||
(assoc :page-id (:page-id thread))
|
||||
(dissoc :comment-id))
|
||||
{::rt/replace true}))
|
||||
(->> (rx/of
|
||||
(dwd/select-for-drawing :comments)
|
||||
(center-to-comment-thread thread)
|
||||
(with-meta (dcmt/open-thread thread) {::ev/origin "workspace"}))
|
||||
(rx/observe-on :async))))))
|
||||
|
||||
(defn navigate-to-comment-id
|
||||
[thread-id]
|
||||
(ptk/reify ::navigate-to-comment-id
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [file-id (:current-file-id state)]
|
||||
(->> (rp/cmd! :get-comment-threads {:file-id file-id})
|
||||
(rx/map #(d/seek (fn [{:keys [id]}] (= thread-id id)) %))
|
||||
(rx/map navigate-to-comment))))))
|
||||
|
|
|
@ -8,12 +8,9 @@
|
|||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.main.data.comments :as dcmt]
|
||||
[app.main.data.common :as dcm]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.comments :as dwcm]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.comments :as cmt]
|
||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||
|
@ -22,7 +19,6 @@
|
|||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.timers :as tm]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -119,16 +115,7 @@
|
|||
(mf/use-fn
|
||||
(mf/deps page-id)
|
||||
(fn [thread]
|
||||
(when (not= page-id (:page-id thread))
|
||||
(st/emit! (dcm/go-to-workspace :page-id (:page-id thread)
|
||||
::rt/new-window true)))
|
||||
(tm/schedule
|
||||
(fn []
|
||||
(st/emit! (when (not= page-id (:page-id thread))
|
||||
(dw/select-for-drawing :comments))
|
||||
(dwcm/center-to-comment-thread thread)
|
||||
(-> (dcmt/open-thread thread)
|
||||
(with-meta {::ev/origin "workspace"})))))))]
|
||||
(st/emit! (dwcm/navigate-to-comment thread))))]
|
||||
|
||||
[:div {:class (stl/css-case :comments-section true
|
||||
:from-viewer from-viewer)}
|
||||
|
|
Loading…
Add table
Reference in a new issue