superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [incubator-superset] 01/01: working .... hotkeys in example of hotkeys in explore
Date Wed, 12 Dec 2018 23:29:10 GMT
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch hotkeys
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 8d3dcf4b5e79e49237342639dc846169ea199c32
Author: hughhhh <hmiles@lyft.com>
AuthorDate: Wed Dec 12 15:28:52 2018 -0800

    working .... hotkeys in example of hotkeys in explore
---
 superset/assets/package.json                       |  1 +
 .../explore/components/ExploreViewContainer.jsx    | 43 ++++++++++++++++++++++
 superset/assets/yarn.lock                          | 21 ++++++++++-
 3 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/superset/assets/package.json b/superset/assets/package.json
index 466ad3e..9ac4bb5 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -121,6 +121,7 @@
     "react-search-input": "^0.11.3",
     "react-select": "1.2.1",
     "react-select-fast-filter-options": "^0.2.1",
+    "react-shortcuts": "^1.6.2",
     "react-sortable-hoc": "^0.8.3",
     "react-split-pane": "^0.1.66",
     "react-sticky": "^6.0.2",
diff --git a/superset/assets/src/explore/components/ExploreViewContainer.jsx b/superset/assets/src/explore/components/ExploreViewContainer.jsx
index 162cb16..bb2fba5 100644
--- a/superset/assets/src/explore/components/ExploreViewContainer.jsx
+++ b/superset/assets/src/explore/components/ExploreViewContainer.jsx
@@ -3,6 +3,7 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import { bindActionCreators } from 'redux';
 import { connect } from 'react-redux';
+import { Shortcuts, ShortcutManager } from 'react-shortcuts';
 
 import ExploreChartPanel from './ExploreChartPanel';
 import ControlPanelsContainer from './ControlPanelsContainer';
@@ -18,6 +19,18 @@ import * as chartActions from '../../chart/chartAction';
 import { fetchDatasourceMetadata } from '../../dashboard/actions/datasources';
 import { Logger, ActionLog, EXPLORE_EVENT_NAMES, LOG_ACTIONS_MOUNT_EXPLORER } from '../../logger';
 
+
+const keymap = {
+  BOX: {
+    MOVE_LEFT: ['left', 'a'],
+    MOVE_RIGHT: ['right', 'd'],
+    MOVE_UP: ['up', 'w'],
+    MOVE_DOWN: ['down', 's'],
+  },
+};
+
+const shortcutManager = new ShortcutManager(keymap)
+
 const propTypes = {
   actions: PropTypes.object.isRequired,
   datasource_type: PropTypes.string.isRequired,
@@ -59,6 +72,28 @@ class ExploreViewContainer extends React.Component {
     this.toggleModal = this.toggleModal.bind(this);
   }
 
+  getChildContext() {
+    return { shortcuts: shortcutManager }
+  }
+
+  handleShortcuts(action, event) {
+    console.log(action, event)
+    switch (action) {
+      case 'MOVE_LEFT':
+        console.log('moving left')
+        break
+      case 'MOVE_RIGHT':
+        console.log('moving right')
+        break
+      case 'MOVE_UP':
+        console.log('moving up')
+        break
+      case 'COPY':
+        console.log('copying stuff')
+        break
+    }
+  }
+
   componentDidMount() {
     window.addEventListener('resize', this.handleResize);
     window.addEventListener('popstate', this.handlePopstate);
@@ -252,6 +287,10 @@ class ExploreViewContainer extends React.Component {
       return this.renderChartContainer();
     }
     return (
+      <Shortcuts
+        name='BOX'
+        handler={this.handleShortcuts}
+      >
       <div
         id="explore-container"
         className="container-fluid"
@@ -291,11 +330,15 @@ class ExploreViewContainer extends React.Component {
           <div className="col-sm-8">{this.renderChartContainer()}</div>
         </div>
       </div>
+      </Shortcuts>
     );
   }
 }
 
 ExploreViewContainer.propTypes = propTypes;
+ExploreViewContainer.childContextTypes = {
+  shortcuts: PropTypes.object.isRequired
+}
 
 function mapStateToProps(state) {
   const { explore, charts, impressionId } = state;
diff --git a/superset/assets/yarn.lock b/superset/assets/yarn.lock
index 9cdccb9..7293953 100644
--- a/superset/assets/yarn.lock
+++ b/superset/assets/yarn.lock
@@ -2900,6 +2900,10 @@ combined-stream@^1.0.5, combined-stream@^1.0.6, combined-stream@~1.0.5,
combined
   dependencies:
     delayed-stream "~1.0.0"
 
+combokeys@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/combokeys/-/combokeys-3.0.0.tgz#955c59a3959af40d26846ab6fc3c682448e7572e"
+
 comma-separated-tokens@^1.0.0:
   version "1.0.5"
   resolved "https://registry.yarnpkg.com/comma-separated-tokens/-/comma-separated-tokens-1.0.5.tgz#b13793131d9ea2d2431cf5b507ddec258f0ce0db"
@@ -4446,7 +4450,7 @@ eventemitter3@^3.0.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.0.tgz#090b4d6cdbd645ed10bf750d4b5407942d7ba163"
 
-events@^1.0.0:
+events@^1.0.0, events@^1.0.2:
   version "1.1.1"
   resolved "http://registry.npmjs.org/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
 
@@ -8710,6 +8714,10 @@ pkg-dir@^3.0.0:
   dependencies:
     find-up "^3.0.0"
 
+platform@^1.3.0:
+  version "1.3.5"
+  resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.5.tgz#fb6958c696e07e2918d2eeda0f0bc9448d733444"
+
 pluralize@^7.0.0:
   version "7.0.0"
   resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
@@ -9590,6 +9598,17 @@ react-select@^1.0.0-rc.2, react-select@^1.0.0-rc.5:
     prop-types "^15.5.8"
     react-input-autosize "^2.1.2"
 
+react-shortcuts@^1.6.2:
+  version "1.6.2"
+  resolved "https://registry.yarnpkg.com/react-shortcuts/-/react-shortcuts-1.6.2.tgz#ba43f4d7f33d0994ae9d65380fb6d5f03cc3b8cb"
+  dependencies:
+    combokeys "^3.0.0"
+    events "^1.0.2"
+    invariant "^2.1.0"
+    lodash "^4.15.0"
+    platform "^1.3.0"
+    prop-types "^15.5.8"
+
 react-sortable-hoc@^0.8.3:
   version "0.8.3"
   resolved "https://registry.yarnpkg.com/react-sortable-hoc/-/react-sortable-hoc-0.8.3.tgz#8537e8ab8d6bad6829885755a0f847817ed78648"


Mime
View raw message