Skip to content

Commit

Permalink
Minor improvements to <Hotkeys /> component (apache#7261)
Browse files Browse the repository at this point in the history
* left align, close to button it's related to
* text-muted, so it's a bit more subtle
* fix required func props, where no func it actually passed
  • Loading branch information
mistercrunch authored Apr 12, 2019
1 parent 763db8f commit 14647fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
6 changes: 4 additions & 2 deletions superset/assets/src/components/Hotkeys.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand Down
20 changes: 7 additions & 13 deletions superset/assets/src/explore/components/ExploreViewContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -321,7 +315,7 @@ class ExploreViewContainer extends React.Component {
)}
<div className="row">
<div className="col-sm-4">
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<QueryAndSaveBtns
canAdd="True"
onQuery={this.onQuery}
Expand All @@ -332,7 +326,7 @@ class ExploreViewContainer extends React.Component {
errorMessage={this.renderErrorMessage()}
datasourceType={this.props.datasource_type}
/>
<div>
<div className="m-l-5 text-muted">
<Hotkeys
header="Keyboard shortcuts"
hotkeys={getHotKeys()}
Expand Down

0 comments on commit 14647fc

Please sign in to comment.