From a142eeed9d3b002718c48a719bb7ee009e398b89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Mon, 2 Oct 2017 09:19:23 +0200 Subject: [PATCH] SONAR-9504 Support ESC key in onboarding tutorial --- .../js/apps/tutorials/onboarding/Onboarding.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 = () => { -- 2.39.5