mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
chore: convert newContextFieldUI to kill switch (#6752)
Converts `newContextFieldUI` release flag to `disableShowContextFieldSelectionValues` kill switch. The kill switch controls whether we show the value selection above the search filed when > 100 values --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
501acd080a
commit
d466f608c2
@ -4,7 +4,9 @@ import { RestrictiveLegalValues } from './RestrictiveLegalValues';
|
|||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
vi.mock('../../../../../../hooks/useUiFlag', () => ({
|
vi.mock('../../../../../../hooks/useUiFlag', () => ({
|
||||||
useUiFlag: vi.fn(() => true),
|
useUiFlag: vi.fn(
|
||||||
|
(flag: string) => flag !== 'disableShowContextFieldSelectionValues',
|
||||||
|
),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('should show alert when you have illegal legal values', async () => {
|
test('should show alert when you have illegal legal values', async () => {
|
||||||
|
@ -88,7 +88,9 @@ export const RestrictiveLegalValues = ({
|
|||||||
// Lazily initialise the values because there might be a lot of them.
|
// Lazily initialise the values because there might be a lot of them.
|
||||||
const [valuesMap, setValuesMap] = useState(() => createValuesMap(values));
|
const [valuesMap, setValuesMap] = useState(() => createValuesMap(values));
|
||||||
|
|
||||||
const newContextFieldsUI = useUiFlag('newContextFieldsUI');
|
const disableShowContextFieldSelectionValues = useUiFlag(
|
||||||
|
'disableShowContextFieldSelectionValues',
|
||||||
|
);
|
||||||
|
|
||||||
const cleanDeletedLegalValues = (constraintValues: string[]): string[] => {
|
const cleanDeletedLegalValues = (constraintValues: string[]): string[] => {
|
||||||
const deletedValuesSet = getLegalValueSet(deletedLegalValues);
|
const deletedValuesSet = getLegalValueSet(deletedLegalValues);
|
||||||
@ -162,14 +164,9 @@ export const RestrictiveLegalValues = ({
|
|||||||
<ConstraintFormHeader>
|
<ConstraintFormHeader>
|
||||||
Select values from a predefined set
|
Select values from a predefined set
|
||||||
</ConstraintFormHeader>
|
</ConstraintFormHeader>
|
||||||
<ConditionallyRender
|
<Button variant={'text'} onClick={onSelectAll}>
|
||||||
condition={newContextFieldsUI}
|
{isAllSelected ? 'Unselect all' : 'Select all'}
|
||||||
show={
|
</Button>
|
||||||
<Button variant={'text'} onClick={onSelectAll}>
|
|
||||||
{isAllSelected ? 'Unselect all' : 'Select all'}
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</StyledStack>
|
</StyledStack>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={legalValues.length > 100}
|
condition={legalValues.length > 100}
|
||||||
@ -177,7 +174,8 @@ export const RestrictiveLegalValues = ({
|
|||||||
<>
|
<>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={
|
||||||
Boolean(newContextFieldsUI) && Boolean(values)
|
!disableShowContextFieldSelectionValues &&
|
||||||
|
Boolean(values)
|
||||||
}
|
}
|
||||||
show={
|
show={
|
||||||
<StyledValuesContainer sx={{ border: 0 }}>
|
<StyledValuesContainer sx={{ border: 0 }}>
|
||||||
|
@ -77,7 +77,7 @@ export type UiFlags = {
|
|||||||
outdatedSdksBanner?: boolean;
|
outdatedSdksBanner?: boolean;
|
||||||
projectOverviewRefactor?: string;
|
projectOverviewRefactor?: string;
|
||||||
collectTrafficDataUsage?: boolean;
|
collectTrafficDataUsage?: boolean;
|
||||||
newContextFieldsUI?: boolean;
|
disableShowContextFieldSelectionValues?: boolean;
|
||||||
variantDependencies?: boolean;
|
variantDependencies?: boolean;
|
||||||
projectOverviewRefactorFeedback?: boolean;
|
projectOverviewRefactorFeedback?: boolean;
|
||||||
};
|
};
|
||||||
|
@ -86,6 +86,7 @@ exports[`should create default config 1`] = `
|
|||||||
"disableMetrics": false,
|
"disableMetrics": false,
|
||||||
"disableNotifications": false,
|
"disableNotifications": false,
|
||||||
"disablePublishUnannouncedEvents": false,
|
"disablePublishUnannouncedEvents": false,
|
||||||
|
"disableShowContextFieldSelectionValues": false,
|
||||||
"disableUpdateMaxRevisionId": false,
|
"disableUpdateMaxRevisionId": false,
|
||||||
"displayEdgeBanner": false,
|
"displayEdgeBanner": false,
|
||||||
"edgeBulkMetrics": false,
|
"edgeBulkMetrics": false,
|
||||||
@ -129,7 +130,6 @@ exports[`should create default config 1`] = `
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
"migrationLock": true,
|
"migrationLock": true,
|
||||||
"newContextFieldsUI": false,
|
|
||||||
"outdatedSdksBanner": false,
|
"outdatedSdksBanner": false,
|
||||||
"personalAccessTokensKillSwitch": false,
|
"personalAccessTokensKillSwitch": false,
|
||||||
"projectOverviewRefactor": false,
|
"projectOverviewRefactor": false,
|
||||||
|
@ -55,7 +55,7 @@ export type IFlagKey =
|
|||||||
| 'returnGlobalFrontendApiCache'
|
| 'returnGlobalFrontendApiCache'
|
||||||
| 'projectOverviewRefactor'
|
| 'projectOverviewRefactor'
|
||||||
| 'variantDependencies'
|
| 'variantDependencies'
|
||||||
| 'newContextFieldsUI'
|
| 'disableShowContextFieldSelectionValues'
|
||||||
| 'bearerTokenMiddleware'
|
| 'bearerTokenMiddleware'
|
||||||
| 'projectOverviewRefactorFeedback';
|
| 'projectOverviewRefactorFeedback';
|
||||||
|
|
||||||
@ -266,8 +266,9 @@ const flags: IFlags = {
|
|||||||
process.env.UNLEASH_EXPERIMENTAL_PROJECT_OVERVIEW_REFACTOR,
|
process.env.UNLEASH_EXPERIMENTAL_PROJECT_OVERVIEW_REFACTOR,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
newContextFieldsUI: parseEnvVarBoolean(
|
disableShowContextFieldSelectionValues: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_EXPERIMENTAL_NEW_CONTEXT_FIELDS_UI,
|
process.env
|
||||||
|
.UNLEASH_EXPERIMENTAL_DISABLE_SHOW_CONTEXT_FIELD_SELECTION_VALUES,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
variantDependencies: parseEnvVarBoolean(
|
variantDependencies: parseEnvVarBoolean(
|
||||||
|
@ -51,7 +51,7 @@ process.nextTick(async () => {
|
|||||||
globalFrontendApiCache: true,
|
globalFrontendApiCache: true,
|
||||||
returnGlobalFrontendApiCache: false,
|
returnGlobalFrontendApiCache: false,
|
||||||
projectOverviewRefactor: true,
|
projectOverviewRefactor: true,
|
||||||
newContextFieldsUI: true,
|
disableShowContextFieldSelectionValues: false,
|
||||||
variantDependencies: true,
|
variantDependencies: true,
|
||||||
projectOverviewRefactorFeedback: true,
|
projectOverviewRefactorFeedback: true,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user