1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00
This commit is contained in:
andreas-unleash 2022-08-04 15:17:17 +03:00
parent 6e190834ff
commit b32ab004c8
4 changed files with 36 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import { useStyles } from './PlaygroundResultFeatureDetails.styles';
import { CloseOutlined } from '@mui/icons-material';
import React from 'react';
import { ConditionallyRender } from '../../../../../common/ConditionallyRender/ConditionallyRender';
import { checkForEmptyValues } from './helpers';
import { checkForEmptyValues, hasCustomStrategies } from './helpers';
interface PlaygroundFeatureResultDetailsProps {
feature: PlaygroundFeatureSchema;
@ -41,6 +41,10 @@ export const PlaygroundResultFeatureDetails = ({
? 'You did not provide a value for your context field in step 2 of the configuration'
: undefined;
const customStrategiesTxt = hasCustomStrategies(feature)
? `You have custom strategies. Custom strategies can't be evaluated and they will be set as Unevaluated`
: undefined;
const onCloseClick =
onClose &&
((event: React.SyntheticEvent) => {
@ -82,6 +86,14 @@ export const PlaygroundResultFeatureDetails = ({
</div>
}
/>
<ConditionallyRender
condition={Boolean(customStrategiesTxt)}
show={
<div className={styles.alertRow}>
<Alert color={'info'}>{customStrategiesTxt}</Alert>
</div>
}
/>
</>
);
};

View File

@ -1,3 +1,16 @@
import { PlaygroundFeatureSchema } from '../../../../../../hooks/api/actions/usePlayground/playground.model';
export const DEFAULT_STRATEGIES = [
'default',
'applicationHostname',
'flexibleRollout',
'gradualRolloutRandom',
'gradualRolloutSessionId',
'gradualRolloutUserId',
'remoteAddress',
'userWithId',
];
export function checkForEmptyValues(object?: Object): boolean {
if (object === undefined) {
return true;
@ -6,3 +19,9 @@ export function checkForEmptyValues(object?: Object): boolean {
v && typeof v === 'object' ? checkForEmptyValues(v) : v === null
);
}
export const hasCustomStrategies = (feature: PlaygroundFeatureSchema) => {
return feature.strategies?.data?.find(strategy =>
DEFAULT_STRATEGIES.includes(strategy.name)
);
};

View File

@ -25,7 +25,7 @@ const StyledItemWrapper = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
margin: theme.spacing(0.5),
margin: theme.spacing(0.5, 0),
gap: theme.spacing(1),
}));
@ -41,7 +41,7 @@ export const PlaygroundResultFeatureStrategyItem = ({
const Icon = getFeatureStrategyIcon(strategy.name);
const label =
result.evaluationStatus === 'incomplete'
? 'Unknown'
? 'Unevaluated'
: result.enabled
? 'True'
: 'False';
@ -87,7 +87,7 @@ export const PlaygroundResultFeatureStrategyItem = ({
label={label}
size={
result.evaluationStatus === 'incomplete'
? 'medium'
? 'large'
: 'default'
}
/>

View File

@ -20,7 +20,7 @@ interface PlaygroundResultStrategyExecutionProps {
}
const StyledStrategyExecutionWrapper = styled('div')(({ theme }) => ({
padding: theme.spacing(1),
padding: theme.spacing(0),
}));
const StyledParamWrapper = styled('div')(({ theme }) => ({