mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 12:59:12 -05:00
✨ Enter in dashboard to open files
This commit is contained in:
parent
76b34bb600
commit
1abcd5819b
2 changed files with 26 additions and 2 deletions
|
@ -834,4 +834,15 @@
|
||||||
action (if in-project? file-created project-created)]
|
action (if in-project? file-created project-created)]
|
||||||
|
|
||||||
(->> (rp/mutation! action-name params)
|
(->> (rp/mutation! action-name params)
|
||||||
(rx/map action))))))
|
(rx/map action))))))
|
||||||
|
|
||||||
|
(defn open-selected-file
|
||||||
|
[]
|
||||||
|
(ptk/reify ::open-selected-file
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state _]
|
||||||
|
(let [files (get-in state [:dashboard-local :selected-files])]
|
||||||
|
(if (= 1 (count files))
|
||||||
|
(let [file (get-in state [:dashboard-files (first files)])]
|
||||||
|
(rx/of (go-to-workspace file)))
|
||||||
|
(rx/empty))))))
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
[app.main.ui.dashboard.sidebar :refer [sidebar]]
|
[app.main.ui.dashboard.sidebar :refer [sidebar]]
|
||||||
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page]]
|
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page]]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[rumext.alpha :as mf]))
|
[app.util.keyboard :as kbd]
|
||||||
|
[goog.events :as events]
|
||||||
|
[rumext.alpha :as mf])
|
||||||
|
(:import goog.events.EventType))
|
||||||
|
|
||||||
(defn ^boolean uuid-str?
|
(defn ^boolean uuid-str?
|
||||||
[s]
|
[s]
|
||||||
|
@ -95,6 +98,16 @@
|
||||||
(mf/with-effect [team-id]
|
(mf/with-effect [team-id]
|
||||||
(st/emit! (dd/initialize {:id team-id})))
|
(st/emit! (dd/initialize {:id team-id})))
|
||||||
|
|
||||||
|
(mf/use-effect
|
||||||
|
(fn []
|
||||||
|
(let [events [(events/listen goog/global EventType.KEYDOWN
|
||||||
|
(fn [event]
|
||||||
|
(when (kbd/enter? event)
|
||||||
|
(st/emit! (dd/open-selected-file)))))]]
|
||||||
|
(fn []
|
||||||
|
(doseq [key events]
|
||||||
|
(events/unlistenByKey key))))))
|
||||||
|
|
||||||
[:& (mf/provider ctx/current-team-id) {:value team-id}
|
[:& (mf/provider ctx/current-team-id) {:value team-id}
|
||||||
[:& (mf/provider ctx/current-project-id) {:value project-id}
|
[:& (mf/provider ctx/current-project-id) {:value project-id}
|
||||||
;; NOTE: dashboard events and other related functions assumes
|
;; NOTE: dashboard events and other related functions assumes
|
||||||
|
|
Loading…
Add table
Reference in a new issue