From c3b09a7d49833587a6ab3a83cd6dedbc5f06f583 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Thu, 8 Apr 2021 13:59:54 +0200 Subject: [PATCH] SONAR-12082 Adjust keyboard navigation instruction visibility --- .../src/main/js/app/styles/components/ui.css | 13 + .../coding-rules/components/PageActions.tsx | 31 +- .../__tests__/PageActions-test.tsx} | 27 +- .../__snapshots__/PageActions-test.tsx.snap | 63 ++++ .../main/js/apps/issues/components/App.tsx | 27 +- .../js/apps/issues/components/PageActions.tsx | 67 ++--- .../issues/components/__tests__/App-test.tsx | 4 - .../components/__tests__/PageActions-test.tsx | 12 +- .../__tests__/__snapshots__/App-test.tsx.snap | 1 - ...nNavigationKeyboardShortcuts-test.tsx.snap | 23 -- .../__snapshots__/PageActions-test.tsx.snap | 47 +-- .../conciseIssuesList/ConciseIssueBox.tsx | 18 +- .../ConciseIssuesListHeader.tsx | 33 +-- .../ConciseIssuesListHeader-test.tsx} | 28 +- .../ConciseIssueBox-test.tsx.snap | 135 --------- .../ConciseIssuesListHeader-test.tsx.snap | 56 ++++ .../src/main/js/apps/issues/styles.css | 9 - .../js/components/ui/PageShortcutsTooltip.tsx | 109 +++++++ .../__tests__/PageShortcutsTooltip-test.tsx | 36 +++ .../PageShortcutsTooltip-test.tsx.snap | 268 ++++++++++++++++++ .../resources/org/sonar/l10n/core.properties | 7 + 21 files changed, 640 insertions(+), 374 deletions(-) rename server/sonar-web/src/main/js/apps/{issues/components/LocationNavigationKeyboardShortcuts.tsx => coding-rules/components/__tests__/PageActions-test.tsx} (58%) create mode 100644 server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/PageActions-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/LocationNavigationKeyboardShortcuts-test.tsx.snap rename server/sonar-web/src/main/js/apps/issues/{components/__tests__/LocationNavigationKeyboardShortcuts-test.tsx => conciseIssuesList/__tests__/ConciseIssuesListHeader-test.tsx} (57%) create mode 100644 server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssuesListHeader-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx create mode 100644 server/sonar-web/src/main/js/components/ui/__tests__/PageShortcutsTooltip-test.tsx create mode 100644 server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/PageShortcutsTooltip-test.tsx.snap diff --git a/server/sonar-web/src/main/js/app/styles/components/ui.css b/server/sonar-web/src/main/js/app/styles/components/ui.css index 268d3b08b62..7379714e8a6 100644 --- a/server/sonar-web/src/main/js/app/styles/components/ui.css +++ b/server/sonar-web/src/main/js/app/styles/components/ui.css @@ -41,6 +41,19 @@ margin-right: 4px; } +.shortcut-button-tiny { + width: 14px; + min-width: auto; + padding: 0; + height: 14px; + line-height: inherit; + font-size: 6px; +} + +.page-shortcuts-tooltip { + line-height: 12px; +} + .identity-provider { display: inline-block; line-height: 14px; diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx index 6966a81b536..4c4d8b9ed4d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/PageActions.tsx @@ -22,18 +22,23 @@ import ReloadButton from 'sonar-ui-common/components/controls/ReloadButton'; import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner'; import { translate } from 'sonar-ui-common/helpers/l10n'; import PageCounter from '../../../components/common/PageCounter'; +import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip'; -interface Props { +export interface PageActionsProps { loading: boolean; onReload: () => void; paging?: T.Paging; selectedIndex?: number; } -export default function PageActions(props: Props) { +export default function PageActions(props: PageActionsProps) { return ( -
- +
+ @@ -50,21 +55,3 @@ export default function PageActions(props: Props) {
); } - -function Shortcuts() { - return ( - - - ↑ - ↓ - {translate('coding_rules.to_select_rules')} - - - - ← - → - {translate('issues.to_navigate')} - - - ); -} diff --git a/server/sonar-web/src/main/js/apps/issues/components/LocationNavigationKeyboardShortcuts.tsx b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx similarity index 58% rename from server/sonar-web/src/main/js/apps/issues/components/LocationNavigationKeyboardShortcuts.tsx rename to server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx index ebeeb6b098d..a4b82a0412a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/LocationNavigationKeyboardShortcuts.tsx +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/PageActions-test.tsx @@ -17,24 +17,17 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +import { shallow } from 'enzyme'; import * as React from 'react'; -import { translate } from 'sonar-ui-common/helpers/l10n'; +import PageActions, { PageActionsProps } from '../PageActions'; -export interface Props { - issue: Pick | undefined; -} +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); + expect(shallowRender({ paging: { total: 100 } as T.Paging })).toMatchSnapshot('with paging'); +}); -export default function LocationNavigationKeyboardShortcuts({ issue }: Props) { - if (!issue || (!issue.secondaryLocations.length && !issue.flows.length)) { - return null; - } - const hasSeveralFlows = issue.flows.length > 1; - return ( -
- - alt + ↑ ↓ {hasSeveralFlows && <>←→} - {translate('issues.to_navigate_issue_locations')} - -
- ); +function shallowRender(props: Partial = {}) { + return shallow(); } diff --git a/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/PageActions-test.tsx.snap new file mode 100644 index 00000000000..d31ccfe18f2 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/coding-rules/components/__tests__/__snapshots__/PageActions-test.tsx.snap @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: default 1`] = ` +
+ + + + +
+`; + +exports[`should render correctly: loading 1`] = ` +
+ + + + +
+`; + +exports[`should render correctly: with paging 1`] = ` +
+ + + + + +
+`; diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.tsx b/server/sonar-web/src/main/js/apps/issues/components/App.tsx index ed5155c767f..0c92c8f0eff 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/App.tsx @@ -797,26 +797,6 @@ export default class App extends React.PureComponent { this.handleCloseBulkChange(); }; - handleReload = () => { - this.fetchFirstIssues(); - this.refreshBranchStatus(); - const { branchLike, onBranchesChange } = this.props; - if (onBranchesChange && isPullRequest(branchLike)) { - onBranchesChange(); - } - }; - - handleReloadAndOpenFirst = () => { - this.fetchFirstIssues().then( - (issues: T.Issue[]) => { - if (issues.length > 0) { - this.openIssue(issues[0].key); - } - }, - () => {} - ); - }; - selectLocation = (index: number) => { this.setState(actions.selectLocation(index)); }; @@ -946,9 +926,6 @@ export default class App extends React.PureComponent { displayBackButton={query.issues.length !== 1} loading={this.state.loading} onBackClick={this.closeIssue} - onReload={this.handleReloadAndOpenFirst} - paging={paging} - selectedIndex={this.getSelectedIndex()} /> { @@ -1124,7 +1100,8 @@ export default class App extends React.PureComponent { } render() { - const { openIssue } = this.state; + const { openIssue, paging } = this.state; + const selectedIndex = this.getSelectedIndex(); return (
diff --git a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx index e401c145624..09f9fc8a224 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/PageActions.tsx @@ -18,60 +18,41 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import ReloadButton from 'sonar-ui-common/components/controls/ReloadButton'; import { translate } from 'sonar-ui-common/helpers/l10n'; import HomePageSelect from '../../../components/controls/HomePageSelect'; +import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip'; import { isSonarCloud } from '../../../helpers/system'; import IssuesCounter from './IssuesCounter'; import TotalEffort from './TotalEffort'; -interface Props { +export interface PageActionsProps { canSetHome: boolean; effortTotal: number | undefined; - onReload: () => void; - paging: T.Paging | undefined; - selectedIndex: number | undefined; + paging?: T.Paging; + selectedIndex?: number; } -export default class PageActions extends React.PureComponent { - renderShortcuts() { - return ( - - - ↑ - ↓ - {translate('issues.to_select_issues')} - +export default function PageActions(props: PageActionsProps) { + const { canSetHome, effortTotal, paging, selectedIndex } = props; - - ← - → - {translate('issues.to_navigate')} - - - ); - } + return ( +
+ - render() { - const { effortTotal, paging, selectedIndex } = this.props; - - return ( -
- {this.renderShortcuts()} - -
- - {paging != null && } - {effortTotal !== undefined && } -
- - {this.props.canSetHome && ( - - )} +
+ {paging != null && } + {effortTotal !== undefined && }
- ); - } + + {canSetHome && ( + + )} +
+ ); } diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx index d87c2db51d4..f4169cbabd1 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/App-test.tsx @@ -467,10 +467,6 @@ it('should refresh branch status if issues are updated', async () => { fetchBranchStatus.mockClear(); instance.handleBulkChangeDone(); expect(fetchBranchStatus).toBeCalled(); - - fetchBranchStatus.mockClear(); - instance.handleReload(); - expect(fetchBranchStatus).toBeCalled(); }); it('should update the open issue when it is changed', async () => { diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/PageActions-test.tsx b/server/sonar-web/src/main/js/apps/issues/components/__tests__/PageActions-test.tsx index 5b6088de213..40da1057147 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/PageActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/PageActions-test.tsx @@ -22,15 +22,5 @@ import * as React from 'react'; import PageActions from '../PageActions'; it('should render', () => { - expect( - shallow( - - ) - ).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap index a465c14212f..aa9a378fa01 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/App-test.tsx.snap @@ -82,7 +82,6 @@ exports[`should switch to source view if an issue is selected 1`] = ` - - alt + ↑ ↓ - issues.to_navigate_issue_locations - -
-`; - -exports[`should render correctly 2`] = ` -
- - alt + ↑ ↓ - issues.to_navigate_issue_locations - -
-`; diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap index 09f7ccf406e..7424582257a 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/components/__tests__/__snapshots__/PageActions-test.tsx.snap @@ -2,50 +2,15 @@ exports[`should render 1`] = `
- - - - ↑ - - - ↓ - - issues.to_select_issues - - - - ← - - - → - - issues.to_navigate - - +
- - diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx index 6d36de259d8..587c64ca672 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssueBox.tsx @@ -20,7 +20,6 @@ import * as classNames from 'classnames'; import * as React from 'react'; import TypeHelper from '../../../components/shared/TypeHelper'; -import LocationNavigationKeyboardShortcuts from '../components/LocationNavigationKeyboardShortcuts'; import ConciseIssueLocations from './ConciseIssueLocations'; import ConciseIssueLocationsNavigator from './ConciseIssueLocationsNavigator'; @@ -105,16 +104,13 @@ export default class ConciseIssueBox extends React.PureComponent { />
{selected && ( - <> - - - + )}
); diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx index 9604ebf52db..bd036c78aaf 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/ConciseIssuesListHeader.tsx @@ -19,33 +19,28 @@ */ import * as React from 'react'; import BackButton from 'sonar-ui-common/components/controls/BackButton'; -import ReloadButton from 'sonar-ui-common/components/controls/ReloadButton'; -import IssuesCounter from '../components/IssuesCounter'; +import { translate } from 'sonar-ui-common/helpers/l10n'; +import PageShortcutsTooltip from '../../../components/ui/PageShortcutsTooltip'; -interface Props { - displayBackButton?: boolean; +export interface ConciseIssuesListHeaderProps { + displayBackButton: boolean; loading: boolean; onBackClick: () => void; - onReload: () => void; - paging: T.Paging | undefined; - selectedIndex: number | undefined; } -export default function ConciseIssuesListHeader(props: Props) { - const { displayBackButton = true, paging, selectedIndex } = props; +export default function ConciseIssuesListHeader(props: ConciseIssuesListHeaderProps) { + const { displayBackButton, loading } = props; return (
-
- {displayBackButton && ( - - )} - {props.loading ? ( - - ) : ( - - )} - {paging && } +
+ {displayBackButton && } + + {loading && }
); diff --git a/server/sonar-web/src/main/js/apps/issues/components/__tests__/LocationNavigationKeyboardShortcuts-test.tsx b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesListHeader-test.tsx similarity index 57% rename from server/sonar-web/src/main/js/apps/issues/components/__tests__/LocationNavigationKeyboardShortcuts-test.tsx rename to server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesListHeader-test.tsx index ea126245482..68d0566c1cd 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/__tests__/LocationNavigationKeyboardShortcuts-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/ConciseIssuesListHeader-test.tsx @@ -17,22 +17,24 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + import { shallow } from 'enzyme'; import * as React from 'react'; -import { mockFlowLocation } from '../../../../helpers/testMocks'; -import LocationNavigationKeyboardShortcuts, { Props } from '../LocationNavigationKeyboardShortcuts'; +import ConciseIssuesListHeader, { ConciseIssuesListHeaderProps } from '../ConciseIssuesListHeader'; it('should render correctly', () => { - expect(shallowRender().type()).toBeNull(); - expect(shallowRender({ issue: { flows: [], secondaryLocations: [] } }).type()).toBeNull(); - expect( - shallowRender({ issue: { flows: [], secondaryLocations: [mockFlowLocation()] } }) - ).toMatchSnapshot(); - expect( - shallowRender({ issue: { flows: [[mockFlowLocation()]], secondaryLocations: [] } }) - ).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ loading: true })).toMatchSnapshot('loading'); + expect(shallowRender({ displayBackButton: true })).toMatchSnapshot('with back button'); }); -const shallowRender = (props: Partial = {}) => { - return shallow(); -}; +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap index 4eb63a1a28c..6947b89f047 100644 --- a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssueBox-test.tsx.snap @@ -92,39 +92,6 @@ exports[`should render correctly 1`] = ` selectedFlowIndex={0} selectedLocationIndex={0} /> -
`; @@ -358,107 +325,5 @@ exports[`should render correctly 2`] = ` selectedFlowIndex={0} selectedLocationIndex={0} /> -
`; diff --git a/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssuesListHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssuesListHeader-test.tsx.snap new file mode 100644 index 00000000000..3887851221e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/issues/conciseIssuesList/__tests__/__snapshots__/ConciseIssuesListHeader-test.tsx.snap @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: default 1`] = ` +
+
+ +
+
+`; + +exports[`should render correctly: loading 1`] = ` +
+
+ + +
+
+`; + +exports[`should render correctly: with back button 1`] = ` +
+
+ + +
+
+`; diff --git a/server/sonar-web/src/main/js/apps/issues/styles.css b/server/sonar-web/src/main/js/apps/issues/styles.css index a5133691406..2c2f1c8178c 100644 --- a/server/sonar-web/src/main/js/apps/issues/styles.css +++ b/server/sonar-web/src/main/js/apps/issues/styles.css @@ -327,12 +327,3 @@ .bulk-change-radio-button:hover { background-color: var(--barBackgroundColor); } - -.navigation-keyboard-shortcuts > span { - background-color: var(--transparentGray); - border-radius: 16px; - display: inline-block; - font-size: var(--smallFontSize); - height: 16px; - padding: calc(var(--gridSize) / 2) var(--gridSize); -} diff --git a/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx b/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx new file mode 100644 index 00000000000..5af086cd941 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/PageShortcutsTooltip.tsx @@ -0,0 +1,109 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import * as classNames from 'classnames'; +import * as React from 'react'; +import Tooltip from 'sonar-ui-common/components/controls/Tooltip'; +import { translate, translateWithParameters } from 'sonar-ui-common/helpers/l10n'; + +export interface PageShortcutsTooltipProps { + className?: string; + leftAndRightLabel?: string; + leftLabel?: string; + upAndDownLabel?: string; + metaModifierLabel?: string; +} + +export default function PageShortcutsTooltip(props: PageShortcutsTooltipProps) { + const { className, leftAndRightLabel, leftLabel, upAndDownLabel, metaModifierLabel } = props; + return ( + +
+ {upAndDownLabel && ( + + ↑ + ↓ + {upAndDownLabel} + + )} + {leftAndRightLabel && ( + + ← + → + {leftAndRightLabel} + + )} + {leftLabel && ( + + ← + {leftLabel} + + )} +
+ {metaModifierLabel && ( +
+ alt + + + ↑ + ↓ + ← + → + {metaModifierLabel} +
+ )} + + }> +
+
+ ↑ +
+
+ ← + ↓ + → +
+
+
+ ); +} diff --git a/server/sonar-web/src/main/js/components/ui/__tests__/PageShortcutsTooltip-test.tsx b/server/sonar-web/src/main/js/components/ui/__tests__/PageShortcutsTooltip-test.tsx new file mode 100644 index 00000000000..e49323adb30 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/__tests__/PageShortcutsTooltip-test.tsx @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import { shallow } from 'enzyme'; +import * as React from 'react'; +import PageShortcutsTooltip, { PageShortcutsTooltipProps } from '../PageShortcutsTooltip'; + +it('should render correctly', () => { + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ upAndDownLabel: 'foo', leftAndRightLabel: 'bar' })).toMatchSnapshot( + 'with up/down and left/right labels' + ); + expect(shallowRender({ leftLabel: 'baz' })).toMatchSnapshot('only left label'); + expect(shallowRender({ metaModifierLabel: 'funky' })).toMatchSnapshot('with meta label'); +}); + +function shallowRender(props: Partial = {}) { + return shallow(); +} diff --git a/server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/PageShortcutsTooltip-test.tsx.snap b/server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/PageShortcutsTooltip-test.tsx.snap new file mode 100644 index 00000000000..cb4aa6e79b9 --- /dev/null +++ b/server/sonar-web/src/main/js/components/ui/__tests__/__snapshots__/PageShortcutsTooltip-test.tsx.snap @@ -0,0 +1,268 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: default 1`] = ` + +
+
+ } +> +
+
+ + ↑ + +
+
+ + ← + + + ↓ + + + → + +
+
+
+`; + +exports[`should render correctly: only left label 1`] = ` + +
+ + + ← + + baz + +
+ + } +> +
+
+ + ↑ + +
+
+ + ← + + + ↓ + + + → + +
+
+
+`; + +exports[`should render correctly: with meta label 1`] = ` + +
+
+ + alt + + + + + + + ↑ + + + ↓ + + + ← + + + → + + funky +
+
+ } +> +
+
+ + ↑ + +
+
+ + ← + + + ↓ + + + → + +
+
+
+`; + +exports[`should render correctly: with up/down and left/right labels 1`] = ` + +
+ + + ↑ + + + ↓ + + foo + + + + ← + + + → + + bar + +
+ + } +> +
+
+ + ↑ + +
+
+ + ← + + + ↓ + + + → + +
+
+
+`; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 70aaea77792..8e4490ebcbb 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -863,6 +863,7 @@ issues.select_all_issues=Select all Issues issues.issues=issues issues.to_select_issues=to select issues issues.to_navigate=to navigate +issues.to_navigate_back=to navigate back issues.to_navigate_issue_locations=to navigate issue locations issues.to_switch_flows=to switch flows issues.new_code=New code @@ -1316,6 +1317,12 @@ shortcuts.section.rules.return_to_list=return back to the list shortcuts.section.rules.activate=activate selected rule shortcuts.section.rules.deactivate=deactivate selected rule +shortcuts.on_page.intro=This page allows you to use the following keyboard shortcuts: +shortcuts.on_page.left_x=Left arrow key: {0} +shortcuts.on_page.left_right_x=Left and right arrow keys: {0} +shortcuts.on_page.up_down_x=Up and down arrow keys: {0} +shortcuts.on_page.meta_x=Alt key + arrow keys: {0} + tutorials.onboarding=Analyze a new project tutorials.skip=Skip this tutorial tutorials.finish=Finish this tutorial -- 2.39.5