From: Grégoire Aubert Date: Mon, 2 Oct 2017 07:19:23 +0000 (+0200) Subject: SONAR-9504 Support ESC key in onboarding tutorial X-Git-Tag: 6.6-RC1~61 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a142eeed9d3b002718c48a719bb7ee009e398b89;p=sonarqube.git SONAR-9504 Support ESC key in onboarding tutorial --- diff --git a/server/sonar-web/src/main/js/apps/tutorials/onboarding/Onboarding.js b/server/sonar-web/src/main/js/apps/tutorials/onboarding/Onboarding.js index 03dd358299a..f14988a2ddb 100644 --- a/server/sonar-web/src/main/js/apps/tutorials/onboarding/Onboarding.js +++ b/server/sonar-web/src/main/js/apps/tutorials/onboarding/Onboarding.js @@ -21,6 +21,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Helmet from 'react-helmet'; +import key from 'keymaster'; import TokenStep from './TokenStep'; import OrganizationStep from './OrganizationStep'; import AnalysisStep from './AnalysisStep'; @@ -71,6 +72,7 @@ export default class Onboarding extends React.PureComponent { componentDidMount() { this.mounted = true; + this.attachShortcuts(); if (!this.props.currentUser.isLoggedIn) { handleRequiredAuthentication(); } @@ -78,6 +80,19 @@ export default class Onboarding extends React.PureComponent { componentWillUnmount() { this.mounted = false; + this.detachShortcuts(); + } + + attachShortcuts() { + key.setScope('onboarding'); + key('esc', 'onboarding', () => { + this.finishOnboarding(); + return false; + }); + } + + detachShortcuts() { + key.deleteScope('onboarding'); } finishOnboarding = () => {