Minor improvements to <Hotkeys /> component (#7261)
* 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
This commit is contained in:
parent
763db8fd76
commit
14647fc2ed
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
)}
|
||||
<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}
|
||||
|
|
@ -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()}
|
||||
|
|
|
|||
Loading…
Reference in New Issue