From 904e50c2b02ebb4306aa76db661396430f394c97 Mon Sep 17 00:00:00 2001 From: Shahar Glazner Date: Wed, 31 Jan 2024 12:19:02 +0200 Subject: [PATCH] feat: fix (#765) --- keep-ui/app/alerts/models.tsx | 1 + keep-ui/app/rules/rules.client.tsx | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/keep-ui/app/alerts/models.tsx b/keep-ui/app/alerts/models.tsx index 36e156d07..d29b3bb35 100644 --- a/keep-ui/app/alerts/models.tsx +++ b/keep-ui/app/alerts/models.tsx @@ -66,4 +66,5 @@ export const AlertKnownKeys = [ "alertMenu", "group", "extraPayload", + "note", ]; diff --git a/keep-ui/app/rules/rules.client.tsx b/keep-ui/app/rules/rules.client.tsx index 1d7787c87..ec07c7db5 100644 --- a/keep-ui/app/rules/rules.client.tsx +++ b/keep-ui/app/rules/rules.client.tsx @@ -342,14 +342,24 @@ export default function Page() { const CustomFieldSelector = (props: any) => { const { options, value, handleOnChange, path, currentQuery, setFields } = props; - - // Assuming path[0] is the group index and path[1] is the rule index - let currentGroup = currentQuery.rules[path[0]]; - let isRuleNew = path[1] === currentGroup.rules.length - 1 && currentGroup.rules[path[1]].value === ''; - let currentRule = currentGroup.rules[path[1]]; + let groupIndex = 0; + let ruleIndex = 0; + let currentGroup = currentQuery.rules[groupIndex]; + // if its a rule with one group + if(path.length === 1){ + ruleIndex = path[0]; + currentGroup = currentQuery; + } + else{ + // Assuming path[0] is the group index and path[1] is the rule index + ruleIndex = path[1]; + groupIndex = path[0]; + } + let isRuleNew = ruleIndex === currentGroup.rules.length - 1 && currentGroup.rules[ruleIndex].value === ''; + let currentRule = currentGroup.rules[ruleIndex]; // Get other rules in the same group, excluding the current rule if it's not new let otherRules = currentGroup ? currentGroup.rules.filter((index: any) => - isRuleNew || index !== path[1]) : []; + isRuleNew || index !== ruleIndex) : []; // Filter out options that are already used in other rules of the current group, // unless the current rule is new