From 11b3bbf2dab0d5bbea25148d72a4d73f83cbf374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Thu, 21 Jun 2018 14:43:52 +0200 Subject: [PATCH] add Ctrl+E to export logs --- package.json | 1 + src/components/ExportLogsBtn.js | 14 ++++++++++++-- src/components/layout/Default.js | 2 ++ yarn.lock | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fd3f3fca..68be57e9 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "react": "^16.4.1", "react-dom": "^16.4.1", "react-i18next": "^7.7.0", + "react-key-handler": "^1.0.1", "react-markdown": "^3.3.2", "react-mortal": "^3.2.0", "react-motion": "^0.5.2", diff --git a/src/components/ExportLogsBtn.js b/src/components/ExportLogsBtn.js index 98a5750e..a64c6df7 100644 --- a/src/components/ExportLogsBtn.js +++ b/src/components/ExportLogsBtn.js @@ -6,6 +6,7 @@ import { webFrame, remote } from 'electron' import React, { Component } from 'react' import { translate } from 'react-i18next' import { connect } from 'react-redux' +import KeyHandler from 'react-key-handler' import { createStructuredSelector, createSelector } from 'reselect' import { accountsSelector, encodeAccountsModel } from 'reducers/accounts' import { storeSelector as settingsSelector } from 'reducers/settings' @@ -20,6 +21,7 @@ class ExportLogsBtn extends Component<{ t: *, settings: *, accounts: *, + hookToShortcut?: boolean, }> { handleExportLogs = () => { const { accounts, settings } = this.props @@ -49,9 +51,17 @@ class ExportLogsBtn extends Component<{ } } + onKeyHandle = e => { + if (e.ctrlKey) { + this.handleExportLogs() + } + } + render() { - const { t } = this.props - return ( + const { t, hookToShortcut } = this.props + return hookToShortcut ? ( + + ) : ( diff --git a/src/components/layout/Default.js b/src/components/layout/Default.js index c107392e..393c91f7 100644 --- a/src/components/layout/Default.js +++ b/src/components/layout/Default.js @@ -20,6 +20,7 @@ import SettingsPage from 'components/SettingsPage' import LibcoreBusyIndicator from 'components/LibcoreBusyIndicator' import DeviceBusyIndicator from 'components/DeviceBusyIndicator' import TriggerAppReady from 'components/TriggerAppReady' +import ExportLogsBtn from 'components/ExportLogsBtn' import AppRegionDrag from 'components/AppRegionDrag' import IsUnlocked from 'components/IsUnlocked' @@ -75,6 +76,7 @@ class Default extends Component { {process.platform === 'darwin' && } + {Object.entries(modals).map(([name, ModalComponent]: [string, any]) => ( diff --git a/yarn.lock b/yarn.lock index 6b7bad59..7d258cce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11553,6 +11553,13 @@ react-is@^16.4.1: version "16.4.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.4.1.tgz#d624c4650d2c65dbd52c72622bbf389435d9776e" +react-key-handler@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/react-key-handler/-/react-key-handler-1.0.1.tgz#1fc0f4f4855f506a192c2cbe9fe8cb78fc553191" + dependencies: + exenv "^1.2.0" + prop-types "^15.5.7" + react-lifecycles-compat@^3.0.0, react-lifecycles-compat@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"