aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/js/app/styles/init/links.css2
-rw-r--r--server/sonar-web/src/main/js/components/controls/FavoriteBase.tsx18
-rw-r--r--server/sonar-web/src/main/js/components/controls/__tests__/FavoriteBase-test.tsx4
-rw-r--r--server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/FavoriteBase-test.tsx.snap16
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties2
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<Props, State> {
this.mounted = false;
}
- toggleFavorite = (event: React.SyntheticEvent<HTMLAnchorElement>) => {
- event.preventDefault();
+ toggleFavorite = () => {
if (this.state.favorite) {
this.removeFavorite();
} else {
@@ -83,17 +83,19 @@ export default class FavoriteBase extends React.PureComponent<Props, State> {
}
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 (
<Tooltip overlay={tooltip}>
- <a
- className={classNames('display-inline-block', 'link-no-underline', this.props.className)}
- href="#"
+ <ButtonLink
+ aria-label={ariaLabel}
+ className={classNames('favorite-link', 'link-no-underline', this.props.className)}
onClick={this.toggleFavorite}>
- <FavoriteIcon favorite={this.state.favorite} />
- </a>
+ <FavoriteIcon favorite={favorite} />
+ </ButtonLink>
</Tooltip>
);
}
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`] = `
<Tooltip
overlay="favorite.current.TRK"
>
- <a
- className="display-inline-block link-no-underline"
- href="#"
+ <ButtonLink
+ aria-label="favorite.action.remove"
+ className="favorite-link link-no-underline"
onClick={[Function]}
>
<FavoriteIcon
favorite={true}
/>
- </a>
+ </ButtonLink>
</Tooltip>
`;
@@ -20,14 +20,14 @@ exports[`should render not favorite 1`] = `
<Tooltip
overlay="favorite.check.TRK"
>
- <a
- className="display-inline-block link-no-underline"
- href="#"
+ <ButtonLink
+ aria-label="favorite.action.add"
+ className="favorite-link link-no-underline"
onClick={[Function]}
>
<FavoriteIcon
favorite={false}
/>
- </a>
+ </ButtonLink>
</Tooltip>
`;
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.