From 15364b9623843d2e84f9dd317a7bf64dc555340f Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Wed, 13 Mar 2024 10:33:21 +0100 Subject: [PATCH] SONAR-21798 Portfolio reflects Software Qualities --- .../main/js/apps/code/__tests__/Code-it.ts | 16 ++++++------- .../__snapshots__/utils-test.tsx.snap | 24 +++++++++---------- .../apps/code/components/CodeAppRenderer.tsx | 2 +- .../apps/code/components/ComponentsHeader.tsx | 4 ++-- .../sonar-web/src/main/js/apps/code/utils.ts | 8 +++---- .../shared/AnalysisMissingInfoMessage.tsx | 5 ++++ .../resources/org/sonar/l10n/core.properties | 4 ++-- 7 files changed, 34 insertions(+), 29 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts index 83d30d441fa..441cb8a1f08 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts +++ b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts @@ -380,10 +380,10 @@ it('should correctly show new VS overall measures for Portfolios', async () => { let child1Row = ui.measureRow(/^Child 1/); [ ['Releasability', 'OK'], + ['security', 'C'], ['Reliability', 'C'], - ['vulnerabilities', 'C'], - ['security_hotspots', 'C'], ['Maintainability', 'C'], + ['security_review', 'C'], ['ncloc', '3'], ['last_analysis_date', '2022-02-01'], ].forEach(([domain, value]) => { @@ -394,10 +394,10 @@ it('should correctly show new VS overall measures for Portfolios', async () => { let child2Row = ui.measureRow(/^Child 2/); [ ['Releasability', 'ERROR'], + ['security', '—'], ['Reliability', '—'], - ['vulnerabilities', '—'], - ['security_hotspots', '—'], ['Maintainability', '—'], + ['security_review', '—'], ['ncloc', '—'], ['last_analysis_date', '—'], ].forEach(([domain, value]) => { @@ -411,10 +411,10 @@ it('should correctly show new VS overall measures for Portfolios', async () => { child1Row = ui.measureRow(/^Child 1/); [ ['Releasability', 'OK'], + ['security', 'B'], ['Reliability', 'B'], - ['vulnerabilities', 'B'], - ['security_hotspots', 'B'], ['Maintainability', 'B'], + ['security_review', 'B'], ['ncloc', '2'], ].forEach(([domain, value]) => { expect(ui.measureValueCell(child1Row, domain, value)).toBeInTheDocument(); @@ -424,10 +424,10 @@ it('should correctly show new VS overall measures for Portfolios', async () => { child2Row = ui.measureRow(/^Child 2/); [ ['Releasability', 'ERROR'], + ['security', '—'], ['Reliability', '—'], - ['vulnerabilities', '—'], - ['security_hotspots', '—'], ['Maintainability', '—'], + ['security_review', '—'], ['ncloc', '—'], ].forEach(([domain, value]) => { expect(ui.measureValueCell(child2Row, domain, value)).toBeInTheDocument(); diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap index 202da74f5ad..016ff06d553 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap @@ -19,16 +19,16 @@ exports[`getCodeMetrics should return the right metrics for apps 1`] = ` exports[`getCodeMetrics should return the right metrics for portfolios 1`] = ` [ "releasability_rating", - "new_reliability_rating", "new_security_rating", - "new_security_review_rating", + "new_reliability_rating", "new_maintainability_rating", + "new_security_review_rating", "new_lines", "releasability_rating", - "reliability_rating", "security_rating", - "security_review_rating", + "reliability_rating", "sqale_rating", + "security_review_rating", "ncloc", ] `; @@ -36,16 +36,16 @@ exports[`getCodeMetrics should return the right metrics for portfolios 1`] = ` exports[`getCodeMetrics should return the right metrics for portfolios 2`] = ` [ "releasability_rating", - "new_reliability_rating", "new_security_rating", - "new_security_review_rating", + "new_reliability_rating", "new_maintainability_rating", + "new_security_review_rating", "new_lines", "releasability_rating", - "reliability_rating", "security_rating", - "security_review_rating", + "reliability_rating", "sqale_rating", + "security_review_rating", "ncloc", "alert_status", ] @@ -54,10 +54,10 @@ exports[`getCodeMetrics should return the right metrics for portfolios 2`] = ` exports[`getCodeMetrics should return the right metrics for portfolios 3`] = ` [ "releasability_rating", - "new_reliability_rating", "new_security_rating", - "new_security_review_rating", + "new_reliability_rating", "new_maintainability_rating", + "new_security_review_rating", "new_lines", "alert_status", ] @@ -66,10 +66,10 @@ exports[`getCodeMetrics should return the right metrics for portfolios 3`] = ` exports[`getCodeMetrics should return the right metrics for portfolios 4`] = ` [ "releasability_rating", - "reliability_rating", "security_rating", - "security_review_rating", + "reliability_rating", "sqale_rating", + "security_review_rating", "ncloc", "alert_status", ] diff --git a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx index 493b623f77c..83f6ff1ae85 100644 --- a/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx @@ -72,7 +72,7 @@ interface Props { handleSelectNewCode: (newCodeSelected: boolean) => void; } -export default function CodeAppRenderer(props: Props) { +export default function CodeAppRenderer(props: Readonly) { const { branchLike, component, diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx index 312ea27eb4c..c0ffe39b973 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentsHeader.tsx @@ -52,10 +52,10 @@ export default function ComponentsHeader(props: ComponentsHeaderProps) { if (isPortfolio) { columns = [ translate('metric_domain.Releasability'), + translate('portfolio.metric_domain.security'), translate('metric_domain.Reliability'), - translate('portfolio.metric_domain.vulnerabilities'), - translate('portfolio.metric_domain.security_hotspots'), translate('metric_domain.Maintainability'), + translate('portfolio.metric_domain.security_review'), translate('metric.ncloc.name'), ]; diff --git a/server/sonar-web/src/main/js/apps/code/utils.ts b/server/sonar-web/src/main/js/apps/code/utils.ts index ca7fbc55154..207b1f87200 100644 --- a/server/sonar-web/src/main/js/apps/code/utils.ts +++ b/server/sonar-web/src/main/js/apps/code/utils.ts @@ -46,19 +46,19 @@ const APPLICATION_METRICS = [MetricKey.alert_status, ...METRICS]; const PORTFOLIO_METRICS = [ MetricKey.releasability_rating, - MetricKey.reliability_rating, MetricKey.security_rating, - MetricKey.security_review_rating, + MetricKey.reliability_rating, MetricKey.sqale_rating, + MetricKey.security_review_rating, MetricKey.ncloc, ]; const NEW_PORTFOLIO_METRICS = [ MetricKey.releasability_rating, - MetricKey.new_reliability_rating, MetricKey.new_security_rating, - MetricKey.new_security_review_rating, + MetricKey.new_reliability_rating, MetricKey.new_maintainability_rating, + MetricKey.new_security_review_rating, MetricKey.new_lines, ]; diff --git a/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx b/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx index 685f987470e..42a8909842b 100644 --- a/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx +++ b/server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx @@ -21,6 +21,7 @@ import { FlagMessage } from 'design-system'; import * as React from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import DocumentationLink from '../common/DocumentationLink'; +import { ComponentQualifier } from '../../types/component'; interface AnalysisMissingInfoMessageProps { qualifier: string; @@ -33,6 +34,10 @@ export default function AnalysisMissingInfoMessage({ }: Readonly) { const intl = useIntl(); + if (qualifier === ComponentQualifier.Portfolio) { + return null; + } + return (