From 41c1327463c9c7bf2df7f272ddf83b524e6d9007 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Wed, 19 Jun 2019 09:48:56 +0200 Subject: [PATCH] SONAR-11685 Make 'Add to favorites' link more accessible --- .../src/main/js/app/styles/init/links.css | 2 +- .../js/components/controls/FavoriteBase.tsx | 18 ++++++++++-------- .../controls/__tests__/FavoriteBase-test.tsx | 4 ++-- .../__snapshots__/FavoriteBase-test.tsx.snap | 16 ++++++++-------- .../resources/org/sonar/l10n/core.properties | 2 ++ 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/server/sonar-web/src/main/js/app/styles/init/links.css b/server/sonar-web/src/main/js/app/styles/init/links.css index ee41f91b2cd..df652e50de1 100644 --- a/server/sonar-web/src/main/js/app/styles/init/links.css +++ b/server/sonar-web/src/main/js/app/styles/init/links.css @@ -53,7 +53,7 @@ a:focus { } .link-no-underline { - border-bottom: none; + border-bottom: none !important; } .link-underline { diff --git a/server/sonar-web/src/main/js/components/controls/FavoriteBase.tsx b/server/sonar-web/src/main/js/components/controls/FavoriteBase.tsx index 10865ee16c7..45a812d5425 100644 --- a/server/sonar-web/src/main/js/components/controls/FavoriteBase.tsx +++ b/server/sonar-web/src/main/js/components/controls/FavoriteBase.tsx @@ -20,6 +20,7 @@ import * as React from 'react'; import * as classNames from 'classnames'; import Tooltip from './Tooltip'; +import { ButtonLink } from '../ui/buttons'; import FavoriteIcon from '../icons-components/FavoriteIcon'; import { translate } from '../../helpers/l10n'; @@ -51,8 +52,7 @@ export default class FavoriteBase extends React.PureComponent { this.mounted = false; } - toggleFavorite = (event: React.SyntheticEvent) => { - event.preventDefault(); + toggleFavorite = () => { if (this.state.favorite) { this.removeFavorite(); } else { @@ -83,17 +83,19 @@ export default class FavoriteBase extends React.PureComponent { } render() { - const tooltip = this.state.favorite + const { favorite } = this.state; + const tooltip = favorite ? translate('favorite.current', this.props.qualifier) : translate('favorite.check', this.props.qualifier); + const ariaLabel = translate('favorite.action', favorite ? 'remove' : 'add'); return ( - - - + + ); } diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/FavoriteBase-test.tsx b/server/sonar-web/src/main/js/components/controls/__tests__/FavoriteBase-test.tsx index 58041c11898..7368291c8c7 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/FavoriteBase-test.tsx +++ b/server/sonar-web/src/main/js/components/controls/__tests__/FavoriteBase-test.tsx @@ -35,14 +35,14 @@ it('should render not favorite', () => { it('should add favorite', () => { const addFavorite = jest.fn(() => Promise.resolve()); const favorite = renderFavoriteBase({ favorite: false, addFavorite }); - click(favorite.find('a')); + click(favorite.find('ButtonLink')); expect(addFavorite).toBeCalled(); }); it('should remove favorite', () => { const removeFavorite = jest.fn(() => Promise.resolve()); const favorite = renderFavoriteBase({ favorite: true, removeFavorite }); - click(favorite.find('a')); + click(favorite.find('ButtonLink')); expect(removeFavorite).toBeCalled(); }); diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/FavoriteBase-test.tsx.snap b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/FavoriteBase-test.tsx.snap index f24dedb7531..22815684de0 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/FavoriteBase-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/FavoriteBase-test.tsx.snap @@ -4,15 +4,15 @@ exports[`should render favorite 1`] = ` - - + `; @@ -20,14 +20,14 @@ exports[`should render not favorite 1`] = ` - - + `; 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 4fbc0c17990..43371e87325 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3173,6 +3173,8 @@ homepage.check=Check to make the current page your homepage # FAVORITE # #------------------------------------------------------------------------------ +favorite.action.add=Add project to favorites +favorite.action.remove=Remove project from favorites favorite.check.TRK=Click to mark this project as favorite. favorite.check.VW=Click to mark this portfolio as favorite. favorite.check.SVW=Click to mark this sub-ortfolio as favorite. -- 2.39.5