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

feat: strategy variant test UI (#4199)

This commit is contained in:
Mateusz Kwasniewski 2023-07-11 09:21:01 +02:00 committed by GitHub
parent f83350cb2a
commit 5c4f15ea5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 6 deletions

View File

@ -17,6 +17,8 @@ import Loader from '../../../common/Loader/Loader';
import { useEffect, useMemo } from 'react'; import { useEffect, useMemo } from 'react';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { useLocation } from 'react-router'; import { useLocation } from 'react-router';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
interface IFlexibleStrategyProps { interface IFlexibleStrategyProps {
parameters: IFeatureStrategyParameters; parameters: IFeatureStrategyParameters;
@ -33,6 +35,7 @@ const FlexibleStrategy = ({
const projectId = useRequiredPathParam('projectId'); const projectId = useRequiredPathParam('projectId');
const { defaultStickiness, loading } = useDefaultProjectSettings(projectId); const { defaultStickiness, loading } = useDefaultProjectSettings(projectId);
const { pathname } = useLocation(); const { pathname } = useLocation();
const { uiConfig } = useUiConfig();
const isDefaultStrategyEdit = pathname.includes('default-strategy'); const isDefaultStrategyEdit = pathname.includes('default-strategy');
const onUpdate = (field: string) => (newValue: string) => { const onUpdate = (field: string) => (newValue: string) => {
@ -123,6 +126,34 @@ const FlexibleStrategy = ({
onChange={e => onUpdate('groupId')(e.target.value)} onChange={e => onUpdate('groupId')(e.target.value)}
data-testid={FLEXIBLE_STRATEGY_GROUP_ID} data-testid={FLEXIBLE_STRATEGY_GROUP_ID}
/> />
<ConditionallyRender
condition={Boolean(uiConfig?.flags?.strategyVariant)}
show={
<>
<br />
<Typography
variant="subtitle2"
style={{
marginBottom: '1rem',
display: 'flex',
gap: '1ch',
}}
component="h2"
>
Variant
</Typography>
<Input
label="variant"
id="variant-input"
value={parseParameterString(parameters.variant)}
disabled={!editable}
onChange={e =>
onUpdate('variant')(e.target.value)
}
/>
</>
}
/>
</div> </div>
</div> </div>
); );

View File

@ -53,6 +53,7 @@ export interface IFlags {
advancedPlayground?: boolean; advancedPlayground?: boolean;
customRootRoles?: boolean; customRootRoles?: boolean;
strategySplittedButton?: boolean; strategySplittedButton?: boolean;
strategyVariant?: boolean;
newProjectLayout?: boolean; newProjectLayout?: boolean;
} }

View File

@ -89,7 +89,6 @@ exports[`should create default config 1`] = `
}, },
}, },
"migrationLock": false, "migrationLock": false,
"newProjectLayout": false,
"personalAccessTokensKillSwitch": false, "personalAccessTokensKillSwitch": false,
"proPlanAutoCharge": false, "proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false, "responseTimeWithAppNameKillSwitch": false,
@ -122,7 +121,6 @@ exports[`should create default config 1`] = `
}, },
}, },
"migrationLock": false, "migrationLock": false,
"newProjectLayout": false,
"personalAccessTokensKillSwitch": false, "personalAccessTokensKillSwitch": false,
"proPlanAutoCharge": false, "proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false, "responseTimeWithAppNameKillSwitch": false,

View File

@ -24,6 +24,7 @@ export type IFlagKey =
| 'advancedPlayground' | 'advancedPlayground'
| 'customRootRoles' | 'customRootRoles'
| 'strategySplittedButton' | 'strategySplittedButton'
| 'strategyVariant'
| 'newProjectLayout'; | 'newProjectLayout';
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>; export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
@ -109,10 +110,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_CUSTOM_ROOT_ROLES, process.env.UNLEASH_EXPERIMENTAL_CUSTOM_ROOT_ROLES,
false, false,
), ),
newProjectLayout: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_NEW_PROJECT_LAYOUT,
false,
),
}; };
export const defaultExperimentalOptions: IExperimentalOptions = { export const defaultExperimentalOptions: IExperimentalOptions = {

View File

@ -40,6 +40,7 @@ process.nextTick(async () => {
segmentContextFieldUsage: true, segmentContextFieldUsage: true,
advancedPlayground: true, advancedPlayground: true,
strategySplittedButton: true, strategySplittedButton: true,
strategyVariant: true,
newProjectLayout: true, newProjectLayout: true,
}, },
}, },