aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/security-hotspots/utils.ts')
-rw-r--r--server/sonar-web/src/main/js/apps/security-hotspots/utils.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts b/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts
index cfa1e81f5ed..0f3165da554 100644
--- a/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts
+++ b/server/sonar-web/src/main/js/apps/security-hotspots/utils.ts
@@ -20,6 +20,9 @@
import { groupBy, sortBy } from 'lodash';
import {
Hotspot,
+ HotspotResolution,
+ HotspotStatus,
+ HotspotStatusOption,
RawHotspot,
ReviewHistoryElement,
ReviewHistoryType,
@@ -137,3 +140,35 @@ export function getHotspotReviewHistory(
functionalCount
};
}
+
+const STATUS_AND_RESOLUTION_TO_STATUS_OPTION = {
+ [HotspotStatus.TO_REVIEW]: HotspotStatusOption.TO_REVIEW,
+ [HotspotStatus.REVIEWED]: HotspotStatusOption.FIXED,
+ [HotspotResolution.FIXED]: HotspotStatusOption.FIXED,
+ [HotspotResolution.SAFE]: HotspotStatusOption.SAFE
+};
+
+export function getStatusOptionFromStatusAndResolution(
+ status: HotspotStatus,
+ resolution?: HotspotResolution
+) {
+ // Resolution is the most determinist info here, so we use it first to get the matching status option
+ // If not provided, we use the status (which will be TO_REVIEW)
+ return STATUS_AND_RESOLUTION_TO_STATUS_OPTION[resolution ?? status];
+}
+
+const STATUS_OPTION_TO_STATUS_AND_RESOLUTION_MAP = {
+ [HotspotStatusOption.TO_REVIEW]: { status: HotspotStatus.TO_REVIEW, resolution: undefined },
+ [HotspotStatusOption.FIXED]: {
+ status: HotspotStatus.REVIEWED,
+ resolution: HotspotResolution.FIXED
+ },
+ [HotspotStatusOption.SAFE]: {
+ status: HotspotStatus.REVIEWED,
+ resolution: HotspotResolution.SAFE
+ }
+};
+
+export function getStatusAndResolutionFromStatusOption(statusOption: HotspotStatusOption) {
+ return STATUS_OPTION_TO_STATUS_AND_RESOLUTION_MAP[statusOption];
+}