Skip to content

Commit f95a4f6

Browse files
authored
fix: switched-allow-context-values-to-disabled (#6216)
1 parent 9ad82d5 commit f95a4f6

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

frontend/web/components/base/select/SearchableSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Icon from 'components/Icon'
22
import React from 'react'
33
export interface OptionType {
4-
enabled?: boolean
4+
disabled?: boolean
55
label: string
66
value: string
77
}

frontend/web/components/segments/Rule/Rule.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ const Rule: React.FC<RuleProps> = ({
9797
} else {
9898
updates.value = updates.value?.toString().split(':')[0]
9999
}
100+
} else if (
101+
// If previous operator was PERCENTAGE_SPLIT and property was IDENTITY_KEY, reset property
102+
condition?.operator === 'PERCENTAGE_SPLIT' &&
103+
condition?.property === RuleContextValues.IDENTITY_KEY
104+
) {
105+
updates.property = ''
100106
}
101107

102108
updateCondition(conditionIndex, updates)

frontend/web/components/segments/Rule/components/RuleConditionRow.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react'
1+
import React, { useEffect } from 'react'
22
import Icon from 'components/Icon'
33
import Utils from 'common/utils/utils'
44
import {
@@ -67,15 +67,15 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
6767
if (rule.delete) {
6868
return null
6969
}
70+
7071
const valuePlaceholder = operatorObj?.hideValue
7172
? 'Value (N/A)'
7273
: operatorObj?.valuePlaceholder || 'Value'
7374

7475
// TODO: Move this to the parent component in next iteration
75-
7676
const ALLOWED_CONTEXT_VALUES: OptionType[] = [
7777
{
78-
enabled: operator === 'PERCENTAGE_SPLIT',
78+
disabled: operator !== 'PERCENTAGE_SPLIT',
7979
label: RuleContextLabels.IDENTITY_KEY,
8080
value: RuleContextValues.IDENTITY_KEY,
8181
},
@@ -87,7 +87,7 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
8787
label: RuleContextLabels.ENVIRONMENT_NAME,
8888
value: RuleContextValues.ENVIRONMENT_NAME,
8989
},
90-
]?.filter((option) => !!option.enabled)
90+
]?.filter((option) => !option.disabled)
9191

9292
const isValueFromContext = !!ALLOWED_CONTEXT_VALUES.find(
9393
(option) => option.value === rule.property,
@@ -133,9 +133,9 @@ const RuleConditionRow: React.FC<RuleConditionRowProps> = ({
133133
<Select
134134
data-test={`${dataTest}-operator-${ruleIndex}`}
135135
value={operator && find(operators, { value: operator })}
136-
onChange={(value: { value: string }) =>
136+
onChange={(value: { value: string }) => {
137137
setRuleProperty(ruleIndex, 'operator', value)
138-
}
138+
}}
139139
options={operators}
140140
style={{ width: '190px' }}
141141
/>

0 commit comments

Comments
 (0)