diff --git a/superset/assets/src/components/Hotkeys.jsx b/superset/assets/src/components/Hotkeys.jsx index 36e7d572d3..0d455244cd 100644 --- a/superset/assets/src/components/Hotkeys.jsx +++ b/superset/assets/src/components/Hotkeys.jsx @@ -25,7 +25,7 @@ const propTypes = { hotkeys: PropTypes.arrayOf(PropTypes.shape({ key: PropTypes.string.isRequired, descr: PropTypes.string.isRequired, - func: PropTypes.func.isRequired, + func: PropTypes.func, })).isRequired, header: PropTypes.string, placement: PropTypes.string, @@ -38,7 +38,9 @@ const defaultProps = { export default class Hotkeys extends React.PureComponent { componentDidMount() { this.props.hotkeys.forEach((keyConfig) => { - Mousetrap.bind([keyConfig.key], keyConfig.func); + if (keyConfig.func) { + Mousetrap.bind([keyConfig.key], keyConfig.func); + } }); } renderPopover() { diff --git a/superset/assets/src/explore/components/ExploreViewContainer.jsx b/superset/assets/src/explore/components/ExploreViewContainer.jsx index 9ef7e9ebac..1f11582807 100644 --- a/superset/assets/src/explore/components/ExploreViewContainer.jsx +++ b/superset/assets/src/explore/components/ExploreViewContainer.jsx @@ -47,17 +47,11 @@ const keymap = { SAVE: 'ctrl + s', }; -const getHotKeys = () => { - const d = []; - Object.keys(keymap).forEach((k) => { - d.push({ - name: k, - descr: keymap[k], - key: k, - }); - }); - return d; -}; +const getHotKeys = () => Object.keys(keymap).map(k => ({ + name: k, + descr: keymap[k], + key: k, +})); const propTypes = { actions: PropTypes.object.isRequired, @@ -321,7 +315,7 @@ class ExploreViewContainer extends React.Component { )}