Skip to content

Commit

Permalink
chore: convert newContextFieldUI to kill switch (#6752)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
andreas-unleash committed Apr 3, 2024
1 parent 501acd0 commit d466f60
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
Expand Up @@ -4,7 +4,9 @@ import { RestrictiveLegalValues } from './RestrictiveLegalValues';
import { vi } from 'vitest';

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 () => {
Expand Down
Expand Up @@ -88,7 +88,9 @@ export const RestrictiveLegalValues = ({
// Lazily initialise the values because there might be a lot of them.
const [valuesMap, setValuesMap] = useState(() => createValuesMap(values));

const newContextFieldsUI = useUiFlag('newContextFieldsUI');
const disableShowContextFieldSelectionValues = useUiFlag(
'disableShowContextFieldSelectionValues',
);

const cleanDeletedLegalValues = (constraintValues: string[]): string[] => {
const deletedValuesSet = getLegalValueSet(deletedLegalValues);
Expand Down Expand Up @@ -162,22 +164,18 @@ export const RestrictiveLegalValues = ({
<ConstraintFormHeader>
Select values from a predefined set
</ConstraintFormHeader>
<ConditionallyRender
condition={newContextFieldsUI}
show={
<Button variant={'text'} onClick={onSelectAll}>
{isAllSelected ? 'Unselect all' : 'Select all'}
</Button>
}
/>
<Button variant={'text'} onClick={onSelectAll}>
{isAllSelected ? 'Unselect all' : 'Select all'}
</Button>
</StyledStack>
<ConditionallyRender
condition={legalValues.length > 100}
show={
<>
<ConditionallyRender
condition={
Boolean(newContextFieldsUI) && Boolean(values)
!disableShowContextFieldSelectionValues &&
Boolean(values)
}
show={
<StyledValuesContainer sx={{ border: 0 }}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/interfaces/uiConfig.ts
Expand Up @@ -77,7 +77,7 @@ export type UiFlags = {
outdatedSdksBanner?: boolean;
projectOverviewRefactor?: string;
collectTrafficDataUsage?: boolean;
newContextFieldsUI?: boolean;
disableShowContextFieldSelectionValues?: boolean;
variantDependencies?: boolean;
projectOverviewRefactorFeedback?: boolean;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -86,6 +86,7 @@ exports[`should create default config 1`] = `
"disableMetrics": false,
"disableNotifications": false,
"disablePublishUnannouncedEvents": false,
"disableShowContextFieldSelectionValues": false,
"disableUpdateMaxRevisionId": false,
"displayEdgeBanner": false,
"edgeBulkMetrics": false,
Expand Down Expand Up @@ -129,7 +130,6 @@ exports[`should create default config 1`] = `
},
},
"migrationLock": true,
"newContextFieldsUI": false,
"outdatedSdksBanner": false,
"personalAccessTokensKillSwitch": false,
"projectOverviewRefactor": false,
Expand Down
7 changes: 4 additions & 3 deletions src/lib/types/experimental.ts
Expand Up @@ -55,7 +55,7 @@ export type IFlagKey =
| 'returnGlobalFrontendApiCache'
| 'projectOverviewRefactor'
| 'variantDependencies'
| 'newContextFieldsUI'
| 'disableShowContextFieldSelectionValues'
| 'bearerTokenMiddleware'
| 'projectOverviewRefactorFeedback';

Expand Down Expand Up @@ -266,8 +266,9 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_PROJECT_OVERVIEW_REFACTOR,
false,
),
newContextFieldsUI: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_NEW_CONTEXT_FIELDS_UI,
disableShowContextFieldSelectionValues: parseEnvVarBoolean(
process.env
.UNLEASH_EXPERIMENTAL_DISABLE_SHOW_CONTEXT_FIELD_SELECTION_VALUES,
false,
),
variantDependencies: parseEnvVarBoolean(
Expand Down
2 changes: 1 addition & 1 deletion src/server-dev.ts
Expand Up @@ -51,7 +51,7 @@ process.nextTick(async () => {
globalFrontendApiCache: true,
returnGlobalFrontendApiCache: false,
projectOverviewRefactor: true,
newContextFieldsUI: true,
disableShowContextFieldSelectionValues: false,
variantDependencies: true,
projectOverviewRefactorFeedback: true,
},
Expand Down

0 comments on commit d466f60

Please sign in to comment.