From: Jeremy Davis Date: Wed, 31 Jan 2024 14:21:10 +0000 (+0100) Subject: SONAR-21380 migrate QG status in measures to new UI X-Git-Tag: 10.4.0.87286~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2769a5e143813f8ffa3fc39a8f64911decf8bfd7;p=sonarqube.git SONAR-21380 migrate QG status in measures to new UI --- diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx index d3d4a052100..c4e45eab070 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx @@ -280,7 +280,7 @@ class ComponentMeasuresApp extends React.PureComponent { - + {measures.length > 0 ? ( diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx index 8066803a613..0d784992527 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureHeader.tsx @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import classNames from 'classnames'; -import { Highlight, Link, MetricsLabel, MetricsRatingBadge } from 'design-system'; +import { Link, MetricsLabel, MetricsRatingBadge } from 'design-system'; import * as React from 'react'; import LanguageDistribution from '../../../components/charts/LanguageDistribution'; import Tooltip from '../../../components/controls/Tooltip'; @@ -58,36 +58,39 @@ export default function MeasureHeader(props: Props) {
{getLocalizedMetricName(metric)} - - } - /> + +
+ + } + /> +
{!isDiff && hasHistory && ( - + {translate('component_measures.see_metric_history')} - + )}
diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/SubnavigationMeasureValue.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/SubnavigationMeasureValue.tsx index 44e9f48de56..3deb76113b3 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/SubnavigationMeasureValue.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/SubnavigationMeasureValue.tsx @@ -53,6 +53,7 @@ export default function SubnavigationMeasureValue({ measure }: Props) { } metricKey={measure.metric.key} metricType={measure.metric.type} + small value={value} /> diff --git a/server/sonar-web/src/main/js/components/measure/Measure.tsx b/server/sonar-web/src/main/js/components/measure/Measure.tsx index 2747b801004..c665ada3e79 100644 --- a/server/sonar-web/src/main/js/components/measure/Measure.tsx +++ b/server/sonar-web/src/main/js/components/measure/Measure.tsx @@ -17,12 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +import { QualityGateIndicator } from 'design-system'; import * as React from 'react'; import Tooltip from '../../components/controls/Tooltip'; -import Level from '../../components/ui/Level'; import Rating from '../../components/ui/Rating'; +import { translateWithParameters } from '../../helpers/l10n'; import { formatMeasure } from '../../helpers/measures'; import { MetricType } from '../../types/metrics'; +import { Status } from '../../types/types'; import RatingTooltipContent from './RatingTooltipContent'; interface Props { @@ -49,7 +51,20 @@ export default function Measure({ } if (metricType === MetricType.Level) { - return ; + const formatted = formatMeasure(value, MetricType.Level); + const ariaLabel = translateWithParameters('overview.quality_gate_x', formatted); + + return ( + <> + + {formatted} + + ); } if (metricType !== MetricType.Rating) { diff --git a/server/sonar-web/src/main/js/components/measure/__tests__/MeasureIndicator-test.tsx b/server/sonar-web/src/main/js/components/measure/__tests__/MeasureIndicator-test.tsx index c6607109496..621cf364c11 100644 --- a/server/sonar-web/src/main/js/components/measure/__tests__/MeasureIndicator-test.tsx +++ b/server/sonar-web/src/main/js/components/measure/__tests__/MeasureIndicator-test.tsx @@ -19,6 +19,7 @@ */ import { render, screen } from '@testing-library/react'; import * as React from 'react'; +import { Status } from '../../../apps/overview/utils'; import { MetricKey, MetricType } from '../../../types/metrics'; import MeasureIndicator from '../MeasureIndicator'; @@ -32,3 +33,26 @@ it('renders correctly for coverage', () => { ); expect(screen.getByRole('img')).toMatchSnapshot(); }); + +it('renders correctly for failed quality gate', () => { + const wrapper = render( + , + ); + expect(wrapper.baseElement).toMatchSnapshot(); +}); + +it('renders correctly for passed quality gate', () => { + const wrapper = render( + , + ); + expect(wrapper.baseElement).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/components/measure/__tests__/__snapshots__/MeasureIndicator-test.tsx.snap b/server/sonar-web/src/main/js/components/measure/__tests__/__snapshots__/MeasureIndicator-test.tsx.snap index 41fcb0725e8..b088c02d4c2 100644 --- a/server/sonar-web/src/main/js/components/measure/__tests__/__snapshots__/MeasureIndicator-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/measure/__tests__/__snapshots__/MeasureIndicator-test.tsx.snap @@ -25,3 +25,83 @@ exports[`renders correctly for coverage 1`] = ` `; + +exports[`renders correctly for failed quality gate 1`] = ` + +
+
+ + + + + +
+ + ERROR + +
+ +`; + +exports[`renders correctly for passed quality gate 1`] = ` + +
+
+ + + + + +
+ + OK + +
+ +`;