From 080d1ad967f35d588606bf5fc6b07c3827b5e68b Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Wed, 6 Mar 2024 15:19:52 +0100 Subject: [PATCH] :bug: Count custom rules imported from yaml file Reference-Url: https://issues.redhat.com/browse/MTA-2003 Signed-off-by: Radoslaw Szwajkowski --- client/src/app/utils/rules-utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/app/utils/rules-utils.ts b/client/src/app/utils/rules-utils.ts index 3c460d658..e9bdb5f6e 100644 --- a/client/src/app/utils/rules-utils.ts +++ b/client/src/app/utils/rules-utils.ts @@ -21,8 +21,8 @@ export const parseRules = (file: IReadFile): ParsedRule => { const yamlList = Array.isArray(yamlDoc) ? yamlDoc : [yamlDoc]; const yamlLabels = Array.from( new Set( - yamlList?.flatMap((parsedLine) => { - return parsedLine?.labels ? parsedLine?.labels : []; + yamlList?.flatMap((parsedRule) => { + return parsedRule?.labels ? parsedRule?.labels : []; }) || [] ) ); @@ -32,7 +32,8 @@ export const parseRules = (file: IReadFile): ParsedRule => { target: allLabels?.targetLabel, otherLabels: allLabels?.otherLabels, allLabels: allLabels?.allLabels, - total: 0, + total: + yamlList?.filter((parsedRule) => parsedRule?.ruleID)?.length ?? 0, ...(file.responseID && { fileID: file.responseID, }),