]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22728 Fix bubble chart
authorViktor Vorona <viktor.vorona@sonarsource.com>
Fri, 23 Aug 2024 14:40:09 +0000 (16:40 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 26 Aug 2024 20:03:08 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChartView.tsx
server/sonar-web/src/main/js/apps/component-measures/drilldown/ColorRatingsLegend.tsx
server/sonar-web/src/main/js/components/charts/__tests__/__snapshots__/AdvancedTimeline-test.tsx.snap
server/sonar-web/src/main/js/helpers/measures.ts

index 3368e745100de1eac778bf33476a725b5aab9daa..5a56b9c6e81836cf6646d4c8d0dfdbcf5f7d7738 100644 (file)
@@ -32,6 +32,7 @@ import * as React from 'react';
 import HelpTooltip from '~sonar-aligned/components/controls/HelpTooltip';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
 import { MetricKey } from '~sonar-aligned/types/metrics';
+import { SOFTWARE_QUALITY_RATING_METRICS } from '../../../helpers/constants';
 import {
   getLocalizedMetricDomain,
   getLocalizedMetricName,
@@ -224,6 +225,12 @@ export default function BubbleChartView(props: Readonly<Props>) {
           </div>
           {bubbleMetrics.colors && (
             <ColorRatingsLegend
+              isLegacy={
+                isLegacy ||
+                bubbleMetrics.colors.every(
+                  (m) => !SOFTWARE_QUALITY_RATING_METRICS.includes(m.key as MetricKey),
+                )
+              }
               className="sw-mt-2"
               filters={ratingFilters}
               onRatingClick={handleRatingFilterClick}
index 5919e1c6842a329a25a15b4bfe01edd9a843eed6..80acadf8b66ccc22da43266b102d78a4c409c8b6 100644 (file)
@@ -29,21 +29,19 @@ import * as React from 'react';
 import { formatMeasure } from '~sonar-aligned/helpers/measures';
 import { MetricType } from '~sonar-aligned/types/metrics';
 import { translateWithParameters } from '../../../helpers/l10n';
-import { useIsLegacyCCTMode } from '../../../queries/settings';
 
 export interface ColorRatingsLegendProps {
   className?: string;
   filters: { [rating: number]: boolean };
+  isLegacy?: boolean;
   onRatingClick: (selection: number) => void;
 }
 
 export default function ColorRatingsLegend(props: ColorRatingsLegendProps) {
-  const { data: isLegacy } = useIsLegacyCCTMode();
+  const { className, filters, isLegacy } = props;
   const theme = useTheme();
   const RATINGS = isLegacy ? [1, 2, 3, 4, 5] : [1, 2, 3, 4];
 
-  const { className, filters } = props;
-
   const ratingsColors = RATINGS.map((rating: BubbleColorVal) => {
     const formattedMeasure = formatMeasure(rating, MetricType.Rating);
     return {
index 1d357bc97b8f4772064aecf09ecd2d3723d374f7..93c34d14707d1022fdacbe91eefa4e86bbbbfa74 100644 (file)
@@ -2337,6 +2337,14 @@ exports[`should render correctly: not legacy + split point, but not Rating 1`] =
       height="24"
       width="40"
     />
+    <line
+      class="line-tooltip"
+      stroke-dasharray="2"
+      x1="20"
+      x2="20"
+      y1="24"
+      y2="-10"
+    />
   </g>
 </svg>
 `;
index 12aa7e736b059282acd59c37b0eb71935622d43d..d7569bbb15dec795233d323eb378fc130ebf2843 100644 (file)
@@ -108,6 +108,9 @@ export function areLeakCCTMeasuresComputed(measures?: Measure[] | MeasureEnhance
 }
 
 export function areCCTMeasuresComputed(measures?: Measure[] | MeasureEnhanced[]) {
+  if (!measures || measures.length === 0) {
+    return true;
+  }
   return CCT_SOFTWARE_QUALITY_METRICS.every((metric) =>
     measures?.find((measure) =>
       isMeasureEnhanced(measure) ? measure.metric.key === metric : measure.metric === metric,