aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src')
-rw-r--r--server/sonar-web/src/main/js/helpers/constants.ts17
-rw-r--r--server/sonar-web/src/main/js/helpers/doc-links.ts1
-rw-r--r--server/sonar-web/src/main/js/queries/measures.ts55
3 files changed, 72 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts
index 82c0fd1ca6e..64f92f5c95a 100644
--- a/server/sonar-web/src/main/js/helpers/constants.ts
+++ b/server/sonar-web/src/main/js/helpers/constants.ts
@@ -192,10 +192,19 @@ export const DEPRECATED_ACTIVITY_METRICS = [
export const SOFTWARE_QUALITY_RATING_METRICS_MAP: Record<string, MetricKey> = {
[MetricKey.releasability_rating]: MetricKey.software_quality_releasability_rating,
+ [MetricKey.releasability_rating_distribution]:
+ MetricKey.software_quality_releasability_rating_distribution,
[MetricKey.sqale_rating]: MetricKey.software_quality_maintainability_rating,
+ [MetricKey.maintainability_rating_distribution]:
+ MetricKey.software_quality_maintainability_rating_distribution,
[MetricKey.security_rating]: MetricKey.software_quality_security_rating,
+ [MetricKey.security_rating_distribution]: MetricKey.software_quality_security_rating_distribution,
[MetricKey.reliability_rating]: MetricKey.software_quality_reliability_rating,
+ [MetricKey.reliability_rating_distribution]:
+ MetricKey.software_quality_reliability_rating_distribution,
[MetricKey.security_review_rating]: MetricKey.software_quality_security_review_rating,
+ [MetricKey.security_review_rating_distribution]:
+ MetricKey.software_quality_security_review_rating_distribution,
[MetricKey.reliability_remediation_effort]:
MetricKey.software_quality_reliability_remediation_effort,
[MetricKey.security_remediation_effort]: MetricKey.software_quality_security_remediation_effort,
@@ -204,9 +213,17 @@ export const SOFTWARE_QUALITY_RATING_METRICS_MAP: Record<string, MetricKey> = {
[MetricKey.effort_to_reach_maintainability_rating_a]:
MetricKey.effort_to_reach_software_quality_maintainability_rating_a,
[MetricKey.new_maintainability_rating]: MetricKey.new_software_quality_maintainability_rating,
+ [MetricKey.new_maintainability_rating_distribution]:
+ MetricKey.new_software_quality_maintainability_rating_distribution,
[MetricKey.new_security_rating]: MetricKey.new_software_quality_security_rating,
+ [MetricKey.new_security_rating_distribution]:
+ MetricKey.new_software_quality_security_rating_distribution,
[MetricKey.new_reliability_rating]: MetricKey.new_software_quality_reliability_rating,
+ [MetricKey.new_reliability_rating_distribution]:
+ MetricKey.new_software_quality_reliability_rating_distribution,
[MetricKey.new_security_review_rating]: MetricKey.new_software_quality_security_review_rating,
+ [MetricKey.new_security_review_rating_distribution]:
+ MetricKey.new_software_quality_security_review_rating_distribution,
[MetricKey.new_technical_debt]: MetricKey.new_software_quality_maintainability_remediation_effort,
[MetricKey.new_reliability_remediation_effort]:
MetricKey.new_software_quality_reliability_remediation_effort,
diff --git a/server/sonar-web/src/main/js/helpers/doc-links.ts b/server/sonar-web/src/main/js/helpers/doc-links.ts
index 0f4c5a2f83b..b02acce18ad 100644
--- a/server/sonar-web/src/main/js/helpers/doc-links.ts
+++ b/server/sonar-web/src/main/js/helpers/doc-links.ts
@@ -63,6 +63,7 @@ export enum DocLink {
Issues = '/user-guide/issues/introduction/',
IssueStatuses = '/user-guide/issues/solution-overview/#life-cycle',
MainBranchAnalysis = '/project-administration/maintaining-the-branches-of-your-project/',
+ ManagingPortfolios = '/project-administration/managing-portfolios/',
MetricDefinitions = '/user-guide/code-metrics/metrics-definition/',
Monorepos = '/project-administration/monorepos/',
NewCodeDefinition = '/project-administration/clean-as-you-code-settings/defining-new-code/',
diff --git a/server/sonar-web/src/main/js/queries/measures.ts b/server/sonar-web/src/main/js/queries/measures.ts
index 57a5f6fb182..68cc602ea89 100644
--- a/server/sonar-web/src/main/js/queries/measures.ts
+++ b/server/sonar-web/src/main/js/queries/measures.ts
@@ -38,7 +38,7 @@ import { getBranchLikeQuery } from '../sonar-aligned/helpers/branch-like';
import { MetricKey } from '../sonar-aligned/types/metrics';
import { BranchLike } from '../types/branch-like';
import { Measure } from '../types/types';
-import { createInfiniteQueryHook, createQueryHook } from './common';
+import { createInfiniteQueryHook, createQueryHook, StaleTime } from './common';
export function useAllMeasuresHistoryQuery(
component: string | undefined,
@@ -268,3 +268,56 @@ export const useMeasureQuery = createQueryHook(
});
},
);
+
+const PORTFOLIO_OVERVIEW_METRIC_KEYS = [
+ MetricKey.software_quality_releasability_rating,
+ MetricKey.software_quality_releasability_rating_distribution,
+ MetricKey.software_quality_security_rating_distribution,
+ MetricKey.software_quality_security_review_rating_distribution,
+ MetricKey.software_quality_maintainability_rating_distribution,
+ MetricKey.software_quality_reliability_rating_distribution,
+ MetricKey.new_software_quality_security_rating_distribution,
+ MetricKey.new_software_quality_security_review_rating_distribution,
+ MetricKey.new_software_quality_maintainability_rating_distribution,
+ MetricKey.new_software_quality_reliability_rating_distribution,
+];
+
+export const useMeasuresQuery = createQueryHook(
+ ({
+ componentKey,
+ metricKeys,
+ branchLike,
+ }: {
+ branchLike?: BranchLike;
+ componentKey: string;
+ metricKeys: string;
+ }) => {
+ const queryClient = useQueryClient();
+ const branchLikeQuery = getBranchLikeQuery(branchLike);
+
+ return queryOptions({
+ queryKey: ['measures', 'list', componentKey, 'branchLike', branchLikeQuery, metricKeys],
+ queryFn: async () => {
+ const measures = await getMeasures({
+ component: componentKey,
+ // TODO Remove once BE is ready
+ metricKeys: metricKeys
+ .split(',')
+ .filter((key) => !PORTFOLIO_OVERVIEW_METRIC_KEYS.includes(key as MetricKey))
+ .join(),
+ });
+
+ const measuresMapByMetricKey = groupBy(measures, 'metric');
+ metricKeys.split(',').forEach((metricKey) => {
+ const measure = measuresMapByMetricKey[metricKey]?.[0] ?? null;
+ queryClient.setQueryData<Measure>(
+ ['measures', 'details', componentKey, 'branchLike', branchLike, metricKey],
+ measure,
+ );
+ });
+ return measures;
+ },
+ staleTime: StaleTime.LONG,
+ });
+ },
+);