From 16119bec36fb0ca3a832258ffe62d8bce4556ff7 Mon Sep 17 00:00:00 2001 From: Viktor Vorona Date: Fri, 23 Aug 2024 17:25:58 +0200 Subject: [PATCH] SONAR-22728 Update tooltips --- .../components/metrics/RatingComponent.tsx | 14 ++++++++--- .../components/measure/Measure.tsx | 6 +++-- .../resources/org/sonar/l10n/core.properties | 24 +++++++++---------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx b/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx index 5029f84679a..b5c1c51651e 100644 --- a/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx +++ b/server/sonar-web/src/main/js/app/components/metrics/RatingComponent.tsx @@ -37,7 +37,11 @@ interface Props { componentKey: string; forceMetric?: boolean; getLabel?: (rating: RatingEnum) => string; - getTooltip?: (rating: RatingEnum) => React.ReactNode; + getTooltip?: ( + rating: RatingEnum, + value: string | undefined, + metricKey?: MetricKey, + ) => React.ReactNode; ratingMetric: MetricKey; size?: SizeType; } @@ -114,9 +118,13 @@ export default function RatingComponent(props: Readonly) { {getTooltip ? ( <> - {badge} + + {badge} + {/* The badge is not interactive, so show the tooltip content for screen-readers only */} - {getTooltip(rating)} + + {getTooltip(rating, value, measure?.metric as MetricKey)} + ) : ( badge diff --git a/server/sonar-web/src/main/js/sonar-aligned/components/measure/Measure.tsx b/server/sonar-web/src/main/js/sonar-aligned/components/measure/Measure.tsx index dc0f4c4b28d..798ea6cf5cd 100644 --- a/server/sonar-web/src/main/js/sonar-aligned/components/measure/Measure.tsx +++ b/server/sonar-web/src/main/js/sonar-aligned/components/measure/Measure.tsx @@ -59,8 +59,10 @@ export default function Measure({ const classNameWithFont = classNames(className, fontClassName); const getTooltip = useCallback( - () => value !== undefined && , - [metricKey, value], + (_: RatingEnum, value: string | undefined, metric?: MetricKey) => + value !== undefined && + metric !== undefined && , + [], ); const getLabel = useCallback( 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 c3caf43e39c..314b850b8fe 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3329,11 +3329,11 @@ metric.software_quality_releasability_rating.name=Releasability Rating metric.software_quality_reliability_rating.description=Reliability rating metric.software_quality_reliability_rating.name=Reliability Rating metric.software_quality_reliability_rating.extra_short_name=Rating -metric.software_quality_reliability_rating.tooltip.A=Reliability rating is A when there are no bugs. -metric.software_quality_reliability_rating.tooltip.B=Reliability rating is B when there is at least one minor bug. -metric.software_quality_reliability_rating.tooltip.C=Reliability rating is C when there is at least one major bug. -metric.software_quality_reliability_rating.tooltip.D=Reliability rating is D when there is at least one critical bug. -metric.software_quality_reliability_rating.tooltip.E=Reliability rating is E when there is at least one blocker bug. +metric.software_quality_reliability_rating.tooltip.A=Reliability rating is A when there are no reliability issues. +metric.software_quality_reliability_rating.tooltip.B=Reliability rating is B when there is at least one low reliability issue. +metric.software_quality_reliability_rating.tooltip.C=Reliability rating is C when there is at least one medium reliability issue. +metric.software_quality_reliability_rating.tooltip.D=Reliability rating is D when there is at least one high reliability issue. +metric.software_quality_reliability_rating.tooltip.E=Reliability rating is E when there is at least one high reliability issue. metric.reliability_remediation_effort.description=Reliability Remediation Effort metric.reliability_remediation_effort.name=Reliability Remediation Effort metric.reliability_remediation_effort.extra_short_name=Remediation Effort @@ -3368,11 +3368,11 @@ metric.security_rating.tooltip.E=Security rating is E when there is at least one metric.software_quality_security_rating.description=Security rating metric.software_quality_security_rating.name=Security Rating metric.software_quality_security_rating.extra_short_name=Rating -metric.software_quality_security_rating.tooltip.A=Security rating is A when there are no vulnerabilities. -metric.software_quality_security_rating.tooltip.B=Security rating is B when there is at least one minor vulnerability. -metric.software_quality_security_rating.tooltip.C=Security rating is C when there is at least one major vulnerability. -metric.software_quality_security_rating.tooltip.D=Security rating is D when there is at least one critical vulnerability. -metric.software_quality_security_rating.tooltip.E=Security rating is E when there is at least one blocker vulnerability. +metric.software_quality_security_rating.tooltip.A=Security rating is A when there are no security issues. +metric.software_quality_security_rating.tooltip.B=Security rating is B when there is at least one low security issue. +metric.software_quality_security_rating.tooltip.C=Security rating is C when there is at least one medium security issue. +metric.software_quality_security_rating.tooltip.D=Security rating is D when there is at least one high security issue. +metric.software_quality_security_rating.tooltip.E=Security rating is E when there is at least one high security issue. metric.security_remediation_effort.description=Security remediation effort metric.security_remediation_effort.name=Security Remediation Effort metric.security_remediation_effort.extra_short_name=Remediation Effort @@ -3390,8 +3390,8 @@ metric.security_review_rating.tooltip.B=Security Review rating is B when less th metric.security_review_rating.tooltip.C=Security Review rating is C when less than 70% of Security Hotspots are reviewed. metric.security_review_rating.tooltip.D=Security Review rating is D when less than 50% of Security Hotspots are reviewed. metric.security_review_rating.tooltip.E=Security Review rating is E when less than 30% of Security Hotspots are reviewed. -metric.software_quality_security_review_rating.tooltip.A=Security Review rating is A when at least 80% of Security Hotspots are reviewed. -metric.software_quality_security_review_rating.tooltip.B=Security Review rating is B when less than 80% of Security Hotspots are reviewed. +metric.software_quality_security_review_rating.tooltip.A=Security Review rating is A when all Security Hotspots are reviewed. +metric.software_quality_security_review_rating.tooltip.B=Security Review rating is B when less than 100% of Security Hotspots are reviewed. metric.software_quality_security_review_rating.tooltip.C=Security Review rating is C when less than 70% of Security Hotspots are reviewed. metric.software_quality_security_review_rating.tooltip.D=Security Review rating is D when less than 50% of Security Hotspots are reviewed. metric.software_quality_security_review_rating.tooltip.E=Security Review rating is E when less than 30% of Security Hotspots are reviewed. -- 2.39.5