1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Add flag to control CASE_INSENSITIVE_IN_OPERATORS until SDKs catch up (#2927)

Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2023-01-18 15:53:14 +02:00 committed by GitHub
parent 6b458fedbb
commit 5ceab6f989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 3 deletions

View File

@ -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);

View File

@ -46,6 +46,7 @@ export interface IFlags {
serviceAccounts?: boolean;
featuresExportImport?: boolean;
newProjectOverview?: boolean;
caseInsensitiveInOperators?: boolean;
}
export interface IVersionInfo {

View File

@ -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,

View File

@ -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 = {