aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers/query.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/query.ts')
-rw-r--r--server/sonar-web/src/main/js/helpers/query.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts
index 37ced126f60..97238fc4ab8 100644
--- a/server/sonar-web/src/main/js/helpers/query.ts
+++ b/server/sonar-web/src/main/js/helpers/query.ts
@@ -17,7 +17,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { isEqual, isNil, omitBy } from 'lodash';
+import { compact, isEqual, isNil, omitBy, uniq } from 'lodash';
+import { SoftwareImpactSeverity } from '../types/clean-code-taxonomy';
import { RawQuery } from '../types/types';
import { isValidDate, parseDate, toISO8601WithOffsetString, toShortISO8601String } from './dates';
@@ -125,3 +126,26 @@ export function serializeOptionalBoolean(value: boolean | undefined): string | u
}
return undefined;
}
+
+export function parseImpactSeverityQuery(
+ newSeverities: string,
+ oldSeverities?: string
+): SoftwareImpactSeverity[] {
+ const OLD_TO_NEW_MAPPER = {
+ BLOCKER: SoftwareImpactSeverity.High,
+ CRITICAL: SoftwareImpactSeverity.High,
+ MAJOR: SoftwareImpactSeverity.Medium,
+ MINOR: SoftwareImpactSeverity.Low,
+ INFO: SoftwareImpactSeverity.Low,
+ };
+
+ // Merging new and old severities includes mapping for old to new
+ return compact(
+ uniq([
+ ...parseAsArray<SoftwareImpactSeverity>(newSeverities, parseAsString),
+ ...parseAsArray(oldSeverities, parseAsString).map(
+ (oldSeverity: string) => OLD_TO_NEW_MAPPER[oldSeverity as keyof typeof OLD_TO_NEW_MAPPER]
+ ),
+ ])
+ );
+}