Skip to content

Commit

Permalink
Close confirm_integration On Enter Keypress
Browse files Browse the repository at this point in the history
  • Loading branch information
ry-wang committed Mar 2, 2017
1 parent daef8d8 commit 7a61329
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -5,7 +5,7 @@ import React from 'react';

import BackstageHeader from 'components/backstage/components/backstage_header.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import {Link} from 'react-router/es6';
import {Link, browserHistory} from 'react-router/es6';

import UserStore from 'stores/user_store.jsx';
import IntegrationStore from 'stores/integration_store.jsx';
Expand All @@ -25,6 +25,7 @@ export default class ConfirmIntegration extends React.Component {
super(props);

this.handleIntegrationChange = this.handleIntegrationChange.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);

const userId = UserStore.getCurrentId();

Expand All @@ -38,6 +39,7 @@ export default class ConfirmIntegration extends React.Component {

componentDidMount() {
IntegrationStore.addChangeListener(this.handleIntegrationChange);
window.addEventListener('keypress', this.handleKeyPress);
}

componentWillUnmount() {
Expand All @@ -53,6 +55,12 @@ export default class ConfirmIntegration extends React.Component {
});
}

handleKeyPress(e) {
if (e.key === 'Enter') {
browserHistory.push('/' + this.props.team.name + '/integrations/' + this.state.type);
}
}

render() {
let headerText = null;
let helpText = null;
Expand Down

0 comments on commit 7a61329

Please sign in to comment.