0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

Enter in dashboard to open files

This commit is contained in:
alonso.torres 2022-02-04 15:57:11 +01:00
parent 76b34bb600
commit 1abcd5819b
2 changed files with 26 additions and 2 deletions

View file

@ -834,4 +834,15 @@
action (if in-project? file-created project-created)]
(->> (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))))))

View file

@ -22,7 +22,10 @@
[app.main.ui.dashboard.sidebar :refer [sidebar]]
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page]]
[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?
[s]
@ -95,6 +98,16 @@
(mf/with-effect [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-project-id) {:value project-id}
;; NOTE: dashboard events and other related functions assumes