diff options
author | Ismail Cherri <ismail.cherri@sonarsource.com> | 2024-12-09 11:13:02 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-12-09 20:03:17 +0000 |
commit | d2b48b2ebe30fe2726a1f28656f2fdb3dd7d7706 (patch) | |
tree | b3960deb15d8d17802d713b70219a5c83fb08484 /server | |
parent | 585d6bd17f785796407dec9ac534020c6fdb1118 (diff) | |
download | sonarqube-d2b48b2ebe30fe2726a1f28656f2fdb3dd7d7706.tar.gz sonarqube-d2b48b2ebe30fe2726a1f28656f2fdb3dd7d7706.zip |
SONAR-23523 Hide Effort to reach maintainability rating A for Portfolio and Applications
Diffstat (limited to 'server')
3 files changed, 46 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx index faca7a5d808..b1f611cc1bd 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.tsx @@ -40,7 +40,7 @@ import { StaleTime } from '../../../queries/common'; import { useAllMeasuresHistoryQuery } from '../../../queries/measures'; import { useStandardExperienceModeQuery } from '../../../queries/mode'; import { useAllProjectAnalysesQuery } from '../../../queries/project-analyses'; -import { isApplication, isProject } from '../../../types/component'; +import { isApplication, isApplicationOrPortfolio, isProject } from '../../../types/component'; import { MeasureHistory, ParsedAnalysis } from '../../../types/project-activity'; import { Query, parseQuery, serializeUrlQuery } from '../utils'; import ProjectActivityAppRenderer from './ProjectActivityAppRenderer'; @@ -117,6 +117,18 @@ export function ProjectActivityApp() { ) { return false; } + + // Application and Portfolio don't have these metrics + if ( + isApplicationOrPortfolio(component?.qualifier) && + [ + MetricKey.effort_to_reach_software_quality_maintainability_rating_a, + MetricKey.effort_to_reach_maintainability_rating_a, + ].includes(metric.key as MetricKey) + ) { + return false; + } + if (isProject(component?.qualifier) && metric.key === MetricKey.security_review_rating) { return false; } diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx index 22dc1b0aa72..d436241692d 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx @@ -250,6 +250,32 @@ describe('rendering', () => { }, ); + it.each([ + ComponentQualifier.Portfolio, + ComponentQualifier.SubPortfolio, + ComponentQualifier.Application, + ])( + 'should hide efforts to reach maintainability rating a metrics for a %s', + async (qualifier) => { + const { ui } = getPageObject(); + + renderProjectActivityAppContainer( + mockComponent({ + qualifier, + breadcrumbs: [{ key: 'breadcrumb', name: 'breadcrumb', qualifier }], + }), + ); + + await ui.changeGraphType(GraphType.custom); + await ui.openMetricsDropdown(); + expect(ui.metricCheckbox(MetricKey.security_review_rating).get()).toBeInTheDocument(); + + expect( + ui.metricCheckbox(MetricKey.effort_to_reach_maintainability_rating_a).query(), + ).not.toBeInTheDocument(); + }, + ); + it('should render graph gap info message', async () => { timeMachineHandler.setMeasureHistory([ mockMeasureHistory({ @@ -975,6 +1001,7 @@ function renderProjectActivityAppContainer( mockMetric({ key: MetricKey.bugs, type: MetricType.Integer }), mockMetric({ key: MetricKey.code_smells, type: MetricType.Integer }), mockMetric({ key: MetricKey.security_hotspots_reviewed }), + mockMetric({ key: MetricKey.effort_to_reach_maintainability_rating_a }), mockMetric({ key: MetricKey.security_review_rating, type: MetricType.Rating }), mockMetric({ key: MetricKey.reliability_rating, type: MetricType.Rating }), mockMetric({ diff --git a/server/sonar-web/src/main/js/types/component.ts b/server/sonar-web/src/main/js/types/component.ts index f23341ba933..3678e6b7d0a 100644 --- a/server/sonar-web/src/main/js/types/component.ts +++ b/server/sonar-web/src/main/js/types/component.ts @@ -44,6 +44,12 @@ export interface TreeComponentWithPath extends TreeComponent { path: string; } +export function isApplicationOrPortfolio( + componentQualifier?: string | ComponentQualifier, +): componentQualifier is ComponentQualifier.Application | ComponentQualifier.Portfolio { + return isPortfolioLike(componentQualifier) || isApplication(componentQualifier); +} + export function isApplication( componentQualifier?: string | ComponentQualifier, ): componentQualifier is ComponentQualifier.Application { |