aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
author7PH <benjamin.raymond@sonarsource.com>2023-11-06 11:33:38 +0100
committersonartech <sonartech@sonarsource.com>2023-11-08 20:02:52 +0000
commit34dffa98cc400f52b59826670c765a77e07316e9 (patch)
treea31c679d5dba4d76752f321c9f7f3f2d1c76607c /server
parentc1d24054768c2cecd6c600a47107097925cd2000 (diff)
downloadsonarqube-34dffa98cc400f52b59826670c765a77e07316e9.tar.gz
sonarqube-34dffa98cc400f52b59826670c765a77e07316e9.zip
SONAR-20872 Rename and use accepted_metric in place of won't fix metric in measures page
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/utils.ts5
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.ts7
-rw-r--r--server/sonar-web/src/main/js/helpers/measures.ts4
-rw-r--r--server/sonar-web/src/main/js/helpers/mocks/metrics.ts10
-rw-r--r--server/sonar-web/src/main/js/types/metrics.ts1
5 files changed, 19 insertions, 8 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
index e146258c985..ca845e698b2 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts
+++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts
@@ -21,7 +21,7 @@ import { groupBy, memoize, sortBy, toPairs } from 'lodash';
import { enhanceMeasure } from '../../components/measure/utils';
import { isBranch, isPullRequest } from '../../helpers/branch-like';
import { getLocalizedMetricName } from '../../helpers/l10n';
-import { getDisplayMetrics, isDiffMetric } from '../../helpers/measures';
+import { MEASURES_REDIRECTION, getDisplayMetrics, isDiffMetric } from '../../helpers/measures';
import {
cleanQuery,
parseAsOptionalBoolean,
@@ -231,7 +231,8 @@ export interface Query {
}
export const parseQuery = memoize((urlQuery: RawQuery): Query => {
- const metric = (parseAsString(urlQuery['metric']) || DEFAULT_METRIC) as MetricKey;
+ const parsedMetric = parseAsString<MetricKey>(urlQuery['metric']) || DEFAULT_METRIC;
+ const metric = MEASURES_REDIRECTION[parsedMetric] ?? parsedMetric;
return {
metric,
selected: parseAsString(urlQuery['selected']),
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts
index 0e705c97498..593bed6b881 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/utils.ts
+++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.ts
@@ -21,6 +21,7 @@ import { startOfDay } from 'date-fns';
import { isEqual } from 'lodash';
import { DEFAULT_GRAPH } from '../../components/activity-graph/utils';
import { parseDate } from '../../helpers/dates';
+import { MEASURES_REDIRECTION } from '../../helpers/measures';
import {
cleanQuery,
parseAsArray,
@@ -30,6 +31,7 @@ import {
serializeString,
serializeStringArray,
} from '../../helpers/query';
+import { MetricKey } from '../../types/metrics';
import { GraphType, ParsedAnalysis } from '../../types/project-activity';
import { Dict, RawQuery } from '../../types/types';
@@ -109,9 +111,12 @@ export function getAnalysesByVersionByDay(
}
export function parseQuery(urlQuery: RawQuery): Query {
+ const parsedMetrics = parseAsArray(urlQuery['custom_metrics'], parseAsString<MetricKey>);
+ const customMetrics = parsedMetrics.map((metric) => MEASURES_REDIRECTION[metric] ?? metric);
+
return {
category: parseAsString(urlQuery['category']),
- customMetrics: parseAsArray(urlQuery['custom_metrics'], parseAsString),
+ customMetrics,
from: parseAsDate(urlQuery['from']),
graph: parseGraph(urlQuery['graph']),
project: parseAsString(urlQuery['id']),
diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts
index 3eda07fb334..7071e4c965e 100644
--- a/server/sonar-web/src/main/js/helpers/measures.ts
+++ b/server/sonar-web/src/main/js/helpers/measures.ts
@@ -28,6 +28,10 @@ import { translate, translateWithParameters } from './l10n';
import { getCurrentLocale } from './l10nBundle';
import { isDefined } from './types';
+export const MEASURES_REDIRECTION: Partial<Record<MetricKey, MetricKey>> = {
+ [MetricKey.wont_fix_issues]: MetricKey.accepted_issues,
+};
+
export function enhanceMeasuresWithMetrics(
measures: Measure[],
metrics: Metric[],
diff --git a/server/sonar-web/src/main/js/helpers/mocks/metrics.ts b/server/sonar-web/src/main/js/helpers/mocks/metrics.ts
index cc5f689ba96..6e48ffd22ff 100644
--- a/server/sonar-web/src/main/js/helpers/mocks/metrics.ts
+++ b/server/sonar-web/src/main/js/helpers/mocks/metrics.ts
@@ -1485,12 +1485,12 @@ export const DEFAULT_METRICS: Dict<Metric> = {
qualitative: false,
hidden: false,
},
- wont_fix_issues: {
- id: 'AXJMbIl_PAOIsUIE3gt5',
- key: 'wont_fix_issues',
+ accepted_issues: {
+ id: 'AXJMbIl_PAOIsUIE3ga7',
+ key: 'accepted_issues',
type: 'INT',
- name: "Won't Fix Issues",
- description: "Won't fix issues",
+ name: 'Accepted Issues',
+ description: 'Accepted issues',
domain: 'Issues',
direction: -1,
qualitative: false,
diff --git a/server/sonar-web/src/main/js/types/metrics.ts b/server/sonar-web/src/main/js/types/metrics.ts
index 14bc165900c..92578074dde 100644
--- a/server/sonar-web/src/main/js/types/metrics.ts
+++ b/server/sonar-web/src/main/js/types/metrics.ts
@@ -152,6 +152,7 @@ export enum MetricKey {
uncovered_lines = 'uncovered_lines',
violations = 'violations',
vulnerabilities = 'vulnerabilities',
+ accepted_issues = 'accepted_issues',
wont_fix_issues = 'wont_fix_issues',
}