aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2022-08-03 11:57:31 +0200
committersonartech <sonartech@sonarsource.com>2022-08-05 20:03:26 +0000
commit60686586a638bd709dbbfc3b1dcba5839ac01bc4 (patch)
treecedd7f2dda32e24cf1e519972a00f04c2ffe5f14
parent29997bf05aea661222d80ea48163554dc7ced826 (diff)
downloadsonarqube-60686586a638bd709dbbfc3b1dcba5839ac01bc4.tar.gz
sonarqube-60686586a638bd709dbbfc3b1dcba5839ac01bc4.zip
SONAR-16731 [891648] Buttons have same name but different actions
-rw-r--r--server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx1
-rw-r--r--server/sonar-web/src/main/js/components/controls/Favorite.tsx16
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties32
3 files changed, 25 insertions, 24 deletions
diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
index e7d95020d66..7b06cc6385d 100644
--- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
+++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
@@ -70,6 +70,7 @@ function renderFirstLine(project: Props['project'], handleFavorite: Props['handl
<Favorite
className="spacer-right"
component={key}
+ componentName={name}
favorite={isFavorite}
handleFavorite={handleFavorite}
qualifier={qualifier}
diff --git a/server/sonar-web/src/main/js/components/controls/Favorite.tsx b/server/sonar-web/src/main/js/components/controls/Favorite.tsx
index f64f01365ba..dff52de6bb3 100644
--- a/server/sonar-web/src/main/js/components/controls/Favorite.tsx
+++ b/server/sonar-web/src/main/js/components/controls/Favorite.tsx
@@ -20,7 +20,7 @@
import classNames from 'classnames';
import * as React from 'react';
import { addFavorite, removeFavorite } from '../../api/favorites';
-import { translate } from '../../helpers/l10n';
+import { translate, translateWithParameters } from '../../helpers/l10n';
import FavoriteIcon from '../icons/FavoriteIcon';
import { ButtonLink } from './buttons';
import Tooltip from './Tooltip';
@@ -28,6 +28,7 @@ import Tooltip from './Tooltip';
interface Props {
className?: string;
component: string;
+ componentName?: string;
favorite: boolean;
qualifier: string;
handleFavorite?: (component: string, isFavorite: boolean) => void;
@@ -82,22 +83,21 @@ export default class Favorite extends React.PureComponent<Props, State> {
};
render() {
- const { className, qualifier } = this.props;
+ const { className, componentName, qualifier } = this.props;
const { favorite } = this.state;
- const tooltip = favorite
- ? translate('favorite.current', qualifier)
- : translate('favorite.check', qualifier);
- const ariaLabel = translate('favorite.action', favorite ? 'remove' : 'add');
+ const actionName = favorite ? 'remove' : 'add';
+ const tooltip = componentName
+ ? translateWithParameters(`favorite.action.${qualifier}.${actionName}_x`, componentName)
+ : translate('favorite.action', qualifier, actionName);
return (
<Tooltip overlay={tooltip}>
<ButtonLink
- aria-label={ariaLabel}
innerRef={node => (this.buttonNode = node)}
className={classNames('favorite-link', 'link-no-underline', className)}
onClick={this.toggleFavorite}>
- <FavoriteIcon favorite={favorite} />
+ <FavoriteIcon aria-label={tooltip} favorite={favorite} />
</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 daba2a880ff..95aef3ccd94 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -4243,22 +4243,22 @@ homepage.check=Click 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-portfolio as favorite.
-favorite.check.APP=Click to mark this application as favorite.
-favorite.check.FIL=Click to mark this file as favorite.
-favorite.check.UTS=Click to mark this test file as favorite.
-
-favorite.current.TRK=This project is marked as favorite.
-favorite.current.VW=This portfolio is marked as favorite.
-favorite.current.SVW=This sub-portfolio is marked as favorite.
-favorite.current.APP=This application is marked as favorite.
-favorite.current.FIL=This file is marked as favorite.
-favorite.current.UTS=This test file is marked as favorite.
-
+favorite.action.TRK.add=Add this project to favorites
+favorite.action.TRK.remove=Remove this project from favorites
+favorite.action.VW.add=Add this portfolio to favorites
+favorite.action.VW.remove=Remove this portfolio from favorites
+favorite.action.SVW.add=Add sub-this portfolio to favorites
+favorite.action.SVW.remove=Remove sub-this portfolio from favorites
+favorite.action.APP.add=Add this application to favorites
+favorite.action.APP.remove=Remove this application from favorites
+favorite.action.TRK.add_x=Add project {0} to favorites
+favorite.action.TRK.remove_x=Remove project {0} from favorites
+favorite.action.VW.add_x=Add portfolio {0} to favorites
+favorite.action.VW.remove_x=Remove portfolio {0} from favorites
+favorite.action.SVW.add_x=Add sub-portfolio {0} to favorites
+favorite.action.SVW.remove_x=Remove sub-portfolio {0} from favorites
+favorite.action.APP.add_x=Add application {0} to favorites
+favorite.action.APP.remove_x=Remove application {0} from favorites
#------------------------------------------------------------------------------