diff --git a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx index b4688363ef..cde0213c7a 100644 --- a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx +++ b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx @@ -24,6 +24,7 @@ import { InvertedOperatorButton } from '../StyledToggleButton/InvertedOperatorBu import { CaseSensitiveButton } from '../StyledToggleButton/CaseSensitiveButton/CaseSensitiveButton'; import { ConstraintAccordionHeaderActions } from '../../ConstraintAccordionHeaderActions/ConstraintAccordionHeaderActions'; import { styled } from '@mui/material'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; interface IConstraintAccordionViewHeader { localConstraint: IConstraint; @@ -101,6 +102,11 @@ export const ConstraintAccordionEditHeader = ({ const { contextName, operator } = localConstraint; const [showCaseSensitiveButton, setShowCaseSensitiveButton] = useState(false); + const { uiConfig } = useUiConfig(); + + const caseInsensitiveInOperators = Boolean( + uiConfig.flags.caseInsensitiveInOperators + ); /* We need a special case to handle the currenTime context field. Since this field will be the only one to allow DATE_BEFORE and DATE_AFTER operators @@ -124,12 +130,21 @@ export const ConstraintAccordionEditHeader = ({ setOperator(IN); } - if (oneOf([...stringOperators, ...inOperators], operator)) { + if ( + oneOf(stringOperators, operator) || + (oneOf(inOperators, operator) && caseInsensitiveInOperators) + ) { setShowCaseSensitiveButton(true); } else { setShowCaseSensitiveButton(false); } - }, [contextName, setOperator, operator, setLocalConstraint]); + }, [ + contextName, + setOperator, + operator, + setLocalConstraint, + caseInsensitiveInOperators, + ]); if (!context) { return null; @@ -140,7 +155,10 @@ export const ConstraintAccordionEditHeader = ({ }); const onOperatorChange = (operator: Operator) => { - if (oneOf(stringOperators, operator)) { + if ( + oneOf(stringOperators, operator) || + (oneOf(inOperators, operator) && caseInsensitiveInOperators) + ) { setShowCaseSensitiveButton(true); } else { setShowCaseSensitiveButton(false); diff --git a/frontend/src/interfaces/uiConfig.ts b/frontend/src/interfaces/uiConfig.ts index 0f7c06185a..7a0f96bcde 100644 --- a/frontend/src/interfaces/uiConfig.ts +++ b/frontend/src/interfaces/uiConfig.ts @@ -46,6 +46,7 @@ export interface IFlags { serviceAccounts?: boolean; featuresExportImport?: boolean; newProjectOverview?: boolean; + caseInsensitiveInOperators?: boolean; } export interface IVersionInfo { diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index 358d94852c..82783012cb 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -70,6 +70,7 @@ exports[`should create default config 1`] = ` "ENABLE_DARK_MODE_SUPPORT": false, "anonymiseEventLog": false, "batchMetrics": false, + "caseInsensitiveInOperators": false, "embedProxy": true, "embedProxyFrontend": true, "featuresExportImport": false, @@ -89,6 +90,7 @@ exports[`should create default config 1`] = ` "ENABLE_DARK_MODE_SUPPORT": false, "anonymiseEventLog": false, "batchMetrics": false, + "caseInsensitiveInOperators": false, "embedProxy": true, "embedProxyFrontend": true, "featuresExportImport": false, diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index c35f25180b..b058d79e8b 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -58,6 +58,10 @@ const flags = { process.env.UNLEASH_EXPERIMENTAL_FEATURES_EXPORT_IMPORT, false, ), + caseInsensitiveInOperators: parseEnvVarBoolean( + process.env.UNLEASH_EXPERIMENTAL_CASE_INSENSITIVE_IN_OPERATORS, + false, + ), }; export const defaultExperimentalOptions: IExperimentalOptions = {