|
|
@@ -3,6 +3,7 @@
|
|
|
[frontend.components.plugins :as plugins]
|
|
|
[frontend.components.repo :as repo]
|
|
|
[frontend.components.page :as page]
|
|
|
+ [clojure.string :as str]
|
|
|
[frontend.components.page-menu :as page-menu]
|
|
|
[frontend.components.right-sidebar :as sidebar]
|
|
|
[frontend.components.search :as search]
|
|
|
@@ -21,6 +22,7 @@
|
|
|
[frontend.util :as util]
|
|
|
[cljs-bean.core :as bean]
|
|
|
[reitit.frontend.easy :as rfe]
|
|
|
+ [frontend.modules.shortcut.data-helper :as shortcut-helper]
|
|
|
[rum.core :as rum]
|
|
|
[frontend.mobile.util :as mobile-util]
|
|
|
[frontend.components.widgets :as widgets]))
|
|
|
@@ -55,11 +57,30 @@
|
|
|
list))
|
|
|
nil))))
|
|
|
|
|
|
+(defn keyboard-shortcut [shortcut-name]
|
|
|
+ (print "state/shortcuts: " (state/shortcuts))
|
|
|
+ (ui/keyboard-shortcut (or (shortcut-helper/decorate-binding
|
|
|
+ "(:go/search (state/shortcuts))"
|
|
|
+ #_(get (state/shortcuts) shortcut-name))
|
|
|
+ ["x"])))
|
|
|
+
|
|
|
(rum/defc left-menu-button < rum/reactive
|
|
|
[{:keys [on-click]}]
|
|
|
- (let [left-sidebar-open? (state/sub :ui/left-sidebar-open?)]
|
|
|
|
|
|
- (ui/tippy
|
|
|
+ (ui/tippy
|
|
|
+ {:html [:div.text-sm.font-medium
|
|
|
+ #_(ui/keyboard-shortcut "x")
|
|
|
+ (keyboard-shortcut :ui/toggle-left-sidebar)]
|
|
|
+ :position "right"
|
|
|
+ :interactive true
|
|
|
+ :arrow true}
|
|
|
+
|
|
|
+ [:a#left-menu.cp__header-left-menu.button
|
|
|
+ {:on-click on-click
|
|
|
+ :style {:margin-left 12}}
|
|
|
+ (ui/icon "menu-2" {:style {:fontSize 20}})]))
|
|
|
+
|
|
|
+ #_(ui/tippy
|
|
|
{:html [:div.text-sm.font-medium
|
|
|
"Shortcut: "
|
|
|
[:code (util/->platform-shortcut "t l")]]
|
|
|
@@ -72,7 +93,7 @@
|
|
|
[:a#left-menu.cp__header-left-menu.button
|
|
|
{:on-click on-click
|
|
|
:style {:margin-left 12}}
|
|
|
- (ui/icon "menu-2" {:style {:fontSize 20}})])))
|
|
|
+ (ui/icon "menu-2" {:style {:fontSize 20}})])
|
|
|
|
|
|
(rum/defc dropdown-menu < rum/reactive
|
|
|
[{:keys [me current-repo t default-home]}]
|
|
|
@@ -141,17 +162,17 @@
|
|
|
[t]
|
|
|
(let [[downloaded, set-downloaded] (rum/use-state nil)
|
|
|
_ (rum/use-effect!
|
|
|
- (fn []
|
|
|
- (when-let [channel (and (util/electron?) "auto-updater-downloaded")]
|
|
|
- (let [callback (fn [_ args]
|
|
|
- (js/console.debug "[new-version downloaded] args:" args)
|
|
|
- (let [args (bean/->clj args)]
|
|
|
- (set-downloaded args)
|
|
|
- (state/set-state! :electron/auto-updater-downloaded args))
|
|
|
- nil)]
|
|
|
- (js/apis.addListener channel callback)
|
|
|
- #(js/apis.removeListener channel callback))))
|
|
|
- [])]
|
|
|
+ (fn []
|
|
|
+ (when-let [channel (and (util/electron?) "auto-updater-downloaded")]
|
|
|
+ (let [callback (fn [_ args]
|
|
|
+ (js/console.debug "[new-version downloaded] args:" args)
|
|
|
+ (let [args (bean/->clj args)]
|
|
|
+ (set-downloaded args)
|
|
|
+ (state/set-state! :electron/auto-updater-downloaded args))
|
|
|
+ nil)]
|
|
|
+ (js/apis.addListener channel callback)
|
|
|
+ #(js/apis.removeListener channel callback))))
|
|
|
+ [])]
|
|
|
|
|
|
(when downloaded
|
|
|
[:div.cp__header-tips
|
|
|
@@ -183,26 +204,26 @@
|
|
|
(left-menu-button {:on-click (fn []
|
|
|
(open-fn)
|
|
|
(state/set-left-sidebar-open!
|
|
|
- (not (:ui/left-sidebar-open? @state/state))))})
|
|
|
+ (not (:ui/left-sidebar-open? @state/state))))})
|
|
|
|
|
|
(when current-repo
|
|
|
(ui/tippy
|
|
|
- {:html [:div.text-sm.font-medium
|
|
|
- "Shortcut: "
|
|
|
+ {:html [:div.text-sm.font-medium
|
|
|
+ "Shortcut: "
|
|
|
;; TODO: Pull from config so it displays custom shortcut, not just the default
|
|
|
- [:code (util/->platform-shortcut "Ctrl + k")]]
|
|
|
- :interactive true
|
|
|
- :delay 2000
|
|
|
- :position "right"
|
|
|
- :arrow true}
|
|
|
- [:a.button#search-button
|
|
|
- {:on-click #(state/pub-event! [:go/search])}
|
|
|
- (ui/icon "search" {:style {:fontSize 20}})]))]
|
|
|
+ [:code (util/->platform-shortcut "Ctrl + k")]]
|
|
|
+ :interactive true
|
|
|
+ :delay 2000
|
|
|
+ :position "right"
|
|
|
+ :arrow true}
|
|
|
+ [:a.button#search-button
|
|
|
+ {:on-click #(state/pub-event! [:go/search])}
|
|
|
+ (ui/icon "search" {:style {:fontSize 20}})]))]
|
|
|
|
|
|
[:div.r.flex
|
|
|
(when (and
|
|
|
- (not (mobile-util/is-native-platform?))
|
|
|
- (not (util/electron?)))
|
|
|
+ (not (mobile-util/is-native-platform?))
|
|
|
+ (not (util/electron?)))
|
|
|
(login logged?))
|
|
|
|
|
|
(when plugin-handler/lsp-enabled?
|