mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix playground custom strategy parameters debugging (#1213)
* fix playground custom strategy parameters debugging * fix playground strategy parameters and chips consistency
This commit is contained in:
		
							parent
							
								
									2c3b0bbebd
								
							
						
					
					
						commit
						d2225c62c9
					
				@ -7,7 +7,7 @@ import {
 | 
				
			|||||||
    StyledToggleButtonOn,
 | 
					    StyledToggleButtonOn,
 | 
				
			||||||
} from '../StyledToggleButton';
 | 
					} from '../StyledToggleButton';
 | 
				
			||||||
import { ConditionallyRender } from '../../../../ConditionallyRender/ConditionallyRender';
 | 
					import { ConditionallyRender } from '../../../../ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
import { IConstraint } from '../../../../../../interfaces/strategy';
 | 
					import { IConstraint } from 'interfaces/strategy';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface CaseSensitiveButtonProps {
 | 
					interface CaseSensitiveButtonProps {
 | 
				
			||||||
    localConstraint: IConstraint;
 | 
					    localConstraint: IConstraint;
 | 
				
			||||||
 | 
				
			|||||||
@ -8,8 +8,7 @@ export const useStyles = makeStyles()(theme => ({
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    titleRow: {
 | 
					    titleRow: {
 | 
				
			||||||
        display: 'inline-flex',
 | 
					        display: 'inline-flex',
 | 
				
			||||||
        alignItems: 'flex-start',
 | 
					        alignItems: 'center',
 | 
				
			||||||
        justifyContent: 'center',
 | 
					 | 
				
			||||||
        gap: theme.spacing(1.5),
 | 
					        gap: theme.spacing(1.5),
 | 
				
			||||||
        marginTop: theme.spacing(1.5),
 | 
					        marginTop: theme.spacing(1.5),
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
				
			|||||||
@ -69,12 +69,22 @@ export const FeatureDetails = ({
 | 
				
			|||||||
                    <Typography variant={'subtitle1'} className={styles.name}>
 | 
					                    <Typography variant={'subtitle1'} className={styles.name}>
 | 
				
			||||||
                        {feature.name}
 | 
					                        {feature.name}
 | 
				
			||||||
                    </Typography>
 | 
					                    </Typography>
 | 
				
			||||||
                    <span>
 | 
					                    <ConditionallyRender
 | 
				
			||||||
 | 
					                        condition={feature?.strategies?.result !== 'unknown'}
 | 
				
			||||||
 | 
					                        show={() => (
 | 
				
			||||||
                            <PlaygroundResultChip
 | 
					                            <PlaygroundResultChip
 | 
				
			||||||
                                enabled={feature.isEnabled}
 | 
					                                enabled={feature.isEnabled}
 | 
				
			||||||
                                label={feature.isEnabled ? 'True' : 'False'}
 | 
					                                label={feature.isEnabled ? 'True' : 'False'}
 | 
				
			||||||
                            />
 | 
					                            />
 | 
				
			||||||
                    </span>
 | 
					                        )}
 | 
				
			||||||
 | 
					                        elseShow={() => (
 | 
				
			||||||
 | 
					                            <PlaygroundResultChip
 | 
				
			||||||
 | 
					                                enabled="unknown"
 | 
				
			||||||
 | 
					                                label={'Unknown'}
 | 
				
			||||||
 | 
					                                showIcon={false}
 | 
				
			||||||
 | 
					                            />
 | 
				
			||||||
 | 
					                        )}
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                <IconButton onClick={onCloseClick} className={styles.icon}>
 | 
					                <IconButton onClick={onCloseClick} className={styles.icon}>
 | 
				
			||||||
                    <CloseOutlined />
 | 
					                    <CloseOutlined />
 | 
				
			||||||
 | 
				
			|||||||
@ -44,11 +44,6 @@ export const FeatureStrategyItem = ({
 | 
				
			|||||||
                    showIcon={false}
 | 
					                    showIcon={false}
 | 
				
			||||||
                    enabled={result.enabled}
 | 
					                    enabled={result.enabled}
 | 
				
			||||||
                    label={label}
 | 
					                    label={label}
 | 
				
			||||||
                    size={
 | 
					 | 
				
			||||||
                        result.evaluationStatus === 'incomplete'
 | 
					 | 
				
			||||||
                            ? 'large'
 | 
					 | 
				
			||||||
                            : 'default'
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        >
 | 
					        >
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
import { styled, Tooltip, Typography, useTheme } from '@mui/material';
 | 
					import { styled, Tooltip, Typography, useTheme } from '@mui/material';
 | 
				
			||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
					import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
import { PlaygroundSingleValue } from './PlaygroundSingleValue/PlaygroundSingleValue';
 | 
					import { PlaygroundSingleValue } from './PlaygroundSingleValue/PlaygroundSingleValue';
 | 
				
			||||||
import { PLaygroundMultipleValues } from './PlaygroundMultipleValues/PLaygroundMultipleValues';
 | 
					import { PLaygroundMultipleValues } from './PlaygroundMultipleValues/PlaygroundMultipleValues';
 | 
				
			||||||
import React from 'react';
 | 
					import React from 'react';
 | 
				
			||||||
import { useStyles } from '../../ConstraintAccordion.styles';
 | 
					import { useStyles } from '../../ConstraintAccordion.styles';
 | 
				
			||||||
import { CancelOutlined } from '@mui/icons-material';
 | 
					import { CancelOutlined } from '@mui/icons-material';
 | 
				
			||||||
 | 
				
			|||||||
@ -59,7 +59,7 @@ export const PLaygroundMultipleValues = ({
 | 
				
			|||||||
                            noWrap={true}
 | 
					                            noWrap={true}
 | 
				
			||||||
                            sx={{ mr: 1 }}
 | 
					                            sx={{ mr: 1 }}
 | 
				
			||||||
                        >
 | 
					                        >
 | 
				
			||||||
                            does not match any values{' '}
 | 
					                            does not match values{' '}
 | 
				
			||||||
                        </Typography>
 | 
					                        </Typography>
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
@ -35,7 +35,7 @@ export const PlaygroundSingleValue = ({
 | 
				
			|||||||
                condition={!Boolean(constraint.result)}
 | 
					                condition={!Boolean(constraint.result)}
 | 
				
			||||||
                show={
 | 
					                show={
 | 
				
			||||||
                    <Typography variant={'body1'} color={'error'}>
 | 
					                    <Typography variant={'body1'} color={'error'}>
 | 
				
			||||||
                        does not match any values{' '}
 | 
					                        does not match values{' '}
 | 
				
			||||||
                    </Typography>
 | 
					                    </Typography>
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,97 @@
 | 
				
			|||||||
 | 
					import { Box, styled, Typography, useTheme } from '@mui/material';
 | 
				
			||||||
 | 
					import { CancelOutlined } from '@mui/icons-material';
 | 
				
			||||||
 | 
					import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
 | 
					import StringTruncator from 'component/common/StringTruncator/StringTruncator';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface ICustomParameterItem {
 | 
				
			||||||
 | 
					    text: string;
 | 
				
			||||||
 | 
					    input?: string | null;
 | 
				
			||||||
 | 
					    isRequired?: boolean;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const StyledWrapper = styled(Box)(({ theme }) => ({
 | 
				
			||||||
 | 
					    width: '100%',
 | 
				
			||||||
 | 
					    padding: theme.spacing(2, 3),
 | 
				
			||||||
 | 
					    borderRadius: theme.shape.borderRadiusMedium,
 | 
				
			||||||
 | 
					    border: `1px solid ${theme.palette.dividerAlternative}`,
 | 
				
			||||||
 | 
					    display: 'flex',
 | 
				
			||||||
 | 
					    flexDirection: 'row',
 | 
				
			||||||
 | 
					    alignItems: 'center',
 | 
				
			||||||
 | 
					    gap: 2,
 | 
				
			||||||
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const CustomParameterItem = ({
 | 
				
			||||||
 | 
					    text,
 | 
				
			||||||
 | 
					    input = null,
 | 
				
			||||||
 | 
					    isRequired = false,
 | 
				
			||||||
 | 
					}: ICustomParameterItem) => {
 | 
				
			||||||
 | 
					    const theme = useTheme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const color = input === null ? 'error' : 'neutral';
 | 
				
			||||||
 | 
					    const requiredError = isRequired && input === null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					        <StyledWrapper>
 | 
				
			||||||
 | 
					            <Typography
 | 
				
			||||||
 | 
					                variant="subtitle1"
 | 
				
			||||||
 | 
					                color={theme.palette[color].main}
 | 
				
			||||||
 | 
					                sx={{ minWidth: 118 }}
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
 | 
					                {`${input === null ? 'no value' : input}`}
 | 
				
			||||||
 | 
					            </Typography>
 | 
				
			||||||
 | 
					            <Box
 | 
				
			||||||
 | 
					                sx={{
 | 
				
			||||||
 | 
					                    flexGrow: 1,
 | 
				
			||||||
 | 
					                    flexDirection: 'column',
 | 
				
			||||||
 | 
					                }}
 | 
				
			||||||
 | 
					            >
 | 
				
			||||||
 | 
					                <Box sx={{ flexGrow: 1 }}>
 | 
				
			||||||
 | 
					                    <ConditionallyRender
 | 
				
			||||||
 | 
					                        condition={Boolean(requiredError)}
 | 
				
			||||||
 | 
					                        show={
 | 
				
			||||||
 | 
					                            <>
 | 
				
			||||||
 | 
					                                <Typography
 | 
				
			||||||
 | 
					                                    component="span"
 | 
				
			||||||
 | 
					                                    color={theme.palette.error.main}
 | 
				
			||||||
 | 
					                                >
 | 
				
			||||||
 | 
					                                    {' required parameter '}
 | 
				
			||||||
 | 
					                                </Typography>
 | 
				
			||||||
 | 
					                                <StringTruncator
 | 
				
			||||||
 | 
					                                    maxWidth="300"
 | 
				
			||||||
 | 
					                                    text={text}
 | 
				
			||||||
 | 
					                                    maxLength={50}
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					                                <Typography
 | 
				
			||||||
 | 
					                                    component="span"
 | 
				
			||||||
 | 
					                                    color={theme.palette.error.main}
 | 
				
			||||||
 | 
					                                >
 | 
				
			||||||
 | 
					                                    {' is not set '}
 | 
				
			||||||
 | 
					                                </Typography>
 | 
				
			||||||
 | 
					                            </>
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        elseShow={
 | 
				
			||||||
 | 
					                            <>
 | 
				
			||||||
 | 
					                                <Typography
 | 
				
			||||||
 | 
					                                    component="span"
 | 
				
			||||||
 | 
					                                    color="text.disabled"
 | 
				
			||||||
 | 
					                                >
 | 
				
			||||||
 | 
					                                    {' set on parameter '}
 | 
				
			||||||
 | 
					                                </Typography>
 | 
				
			||||||
 | 
					                                <StringTruncator
 | 
				
			||||||
 | 
					                                    maxWidth="300"
 | 
				
			||||||
 | 
					                                    text={text}
 | 
				
			||||||
 | 
					                                    maxLength={50}
 | 
				
			||||||
 | 
					                                />
 | 
				
			||||||
 | 
					                            </>
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
 | 
					                </Box>
 | 
				
			||||||
 | 
					            </Box>
 | 
				
			||||||
 | 
					            <ConditionallyRender
 | 
				
			||||||
 | 
					                condition={Boolean(requiredError)}
 | 
				
			||||||
 | 
					                show={<CancelOutlined color={'error'} />}
 | 
				
			||||||
 | 
					                elseShow={<div />}
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
 | 
					        </StyledWrapper>
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -4,23 +4,18 @@ import {
 | 
				
			|||||||
    parseParameterString,
 | 
					    parseParameterString,
 | 
				
			||||||
    parseParameterStrings,
 | 
					    parseParameterStrings,
 | 
				
			||||||
} from 'utils/parseParameter';
 | 
					} from 'utils/parseParameter';
 | 
				
			||||||
import { PlaygroundParameterItem } from '../PlaygroundParameterItem/PlaygroundParameterItem';
 | 
					 | 
				
			||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
					import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
 | 
					import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
 | 
				
			||||||
import { Chip } from '@mui/material';
 | 
					 | 
				
			||||||
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle';
 | 
					 | 
				
			||||||
import { PlaygroundConstraintSchema } from 'component/playground/Playground/interfaces/playground.model';
 | 
					 | 
				
			||||||
import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies';
 | 
					import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies';
 | 
				
			||||||
 | 
					import { CustomParameterItem } from './CustomParameterItem/CustomParameterItem';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface ICustomStrategyProps {
 | 
					interface ICustomStrategyProps {
 | 
				
			||||||
    parameters: { [key: string]: string };
 | 
					    parameters: { [key: string]: string };
 | 
				
			||||||
    strategyName: string;
 | 
					    strategyName: string;
 | 
				
			||||||
    constraints: PlaygroundConstraintSchema[];
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const CustomStrategyParams: VFC<ICustomStrategyProps> = ({
 | 
					export const CustomStrategyParams: VFC<ICustomStrategyProps> = ({
 | 
				
			||||||
    strategyName,
 | 
					    strategyName,
 | 
				
			||||||
    constraints,
 | 
					 | 
				
			||||||
    parameters,
 | 
					    parameters,
 | 
				
			||||||
}) => {
 | 
					}) => {
 | 
				
			||||||
    const { strategies } = useStrategies();
 | 
					    const { strategies } = useStrategies();
 | 
				
			||||||
@ -32,109 +27,84 @@ export const CustomStrategyParams: VFC<ICustomStrategyProps> = ({
 | 
				
			|||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const renderCustomStrategyParameters = () => {
 | 
					    const items = definition?.parameters.map(param => {
 | 
				
			||||||
        return definition?.parameters.map((param: any, index: number) => {
 | 
					        const paramValue = parameters[param.name];
 | 
				
			||||||
            const notLastItem = index !== definition?.parameters?.length - 1;
 | 
					        const isRequired = param.required;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (param?.type) {
 | 
					        switch (param?.type) {
 | 
				
			||||||
            case 'list':
 | 
					            case 'list':
 | 
				
			||||||
                    const values = parseParameterStrings(
 | 
					                const values = parseParameterStrings(paramValue);
 | 
				
			||||||
                        parameters[param.name]
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                return (
 | 
					                return (
 | 
				
			||||||
                        <Fragment key={param?.name}>
 | 
					                    <CustomParameterItem
 | 
				
			||||||
                            <PlaygroundParameterItem
 | 
					                        isRequired={isRequired}
 | 
				
			||||||
                                value={values}
 | 
					 | 
				
			||||||
                        text={param.name}
 | 
					                        text={param.name}
 | 
				
			||||||
 | 
					                        input={values?.length > 0 ? values.join(', ') : null}
 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
                            <ConditionallyRender
 | 
					 | 
				
			||||||
                                condition={notLastItem}
 | 
					 | 
				
			||||||
                                show={<StrategySeparator text="AND" />}
 | 
					 | 
				
			||||||
                            />
 | 
					 | 
				
			||||||
                        </Fragment>
 | 
					 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            case 'percentage':
 | 
					            case 'percentage':
 | 
				
			||||||
 | 
					                const percentage = parseParameterNumber(paramValue);
 | 
				
			||||||
 | 
					                const correctPercentage = !(
 | 
				
			||||||
 | 
					                    paramValue === undefined ||
 | 
				
			||||||
 | 
					                    paramValue === '' ||
 | 
				
			||||||
 | 
					                    percentage < 0 ||
 | 
				
			||||||
 | 
					                    percentage > 100
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
                return (
 | 
					                return (
 | 
				
			||||||
                        <Fragment key={param?.name}>
 | 
					                    <CustomParameterItem
 | 
				
			||||||
                            <div>
 | 
					                        text={param.name}
 | 
				
			||||||
                                <Chip
 | 
					                        isRequired={isRequired}
 | 
				
			||||||
                                    size="small"
 | 
					                        input={correctPercentage ? `${percentage}%` : undefined}
 | 
				
			||||||
                                    variant="outlined"
 | 
					 | 
				
			||||||
                                    color="success"
 | 
					 | 
				
			||||||
                                    label={`${parameters[param.name]}%`}
 | 
					 | 
				
			||||||
                                />{' '}
 | 
					 | 
				
			||||||
                                of your base{' '}
 | 
					 | 
				
			||||||
                                {constraints?.length > 0
 | 
					 | 
				
			||||||
                                    ? 'who match constraints'
 | 
					 | 
				
			||||||
                                    : ''}{' '}
 | 
					 | 
				
			||||||
                                is included.
 | 
					 | 
				
			||||||
                            </div>
 | 
					 | 
				
			||||||
                            <PercentageCircle
 | 
					 | 
				
			||||||
                                percentage={parseParameterNumber(
 | 
					 | 
				
			||||||
                                    parameters[param.name]
 | 
					 | 
				
			||||||
                                )}
 | 
					 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
                            <ConditionallyRender
 | 
					 | 
				
			||||||
                                condition={notLastItem}
 | 
					 | 
				
			||||||
                                show={<StrategySeparator text="AND" />}
 | 
					 | 
				
			||||||
                            />
 | 
					 | 
				
			||||||
                        </Fragment>
 | 
					 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            case 'boolean':
 | 
					            case 'boolean':
 | 
				
			||||||
                    const bool = Boolean(parameters[param?.name]);
 | 
					                const bool = ['true', 'false'].includes(paramValue)
 | 
				
			||||||
 | 
					                    ? paramValue
 | 
				
			||||||
 | 
					                    : undefined;
 | 
				
			||||||
                return (
 | 
					                return (
 | 
				
			||||||
                        <Fragment key={param?.name}>
 | 
					                    <CustomParameterItem
 | 
				
			||||||
                            <PlaygroundParameterItem
 | 
					                        isRequired={isRequired}
 | 
				
			||||||
                                value={bool ? ['True'] : []}
 | 
					 | 
				
			||||||
                        text={param.name}
 | 
					                        text={param.name}
 | 
				
			||||||
                                showReason={!bool}
 | 
					                        input={paramValue !== undefined ? bool : undefined}
 | 
				
			||||||
                                input={bool ? bool : 'no value'}
 | 
					 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
                            <ConditionallyRender
 | 
					 | 
				
			||||||
                                condition={notLastItem}
 | 
					 | 
				
			||||||
                                show={<StrategySeparator text="AND" />}
 | 
					 | 
				
			||||||
                            />
 | 
					 | 
				
			||||||
                        </Fragment>
 | 
					 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            case 'string':
 | 
					            case 'string':
 | 
				
			||||||
                    const value =
 | 
					                const value = parseParameterString(paramValue);
 | 
				
			||||||
                        parseParameterString(parameters[param.name]) ??
 | 
					 | 
				
			||||||
                        'no value';
 | 
					 | 
				
			||||||
                return (
 | 
					                return (
 | 
				
			||||||
                        <Fragment key={param?.name}>
 | 
					                    <CustomParameterItem
 | 
				
			||||||
                            <PlaygroundParameterItem
 | 
					 | 
				
			||||||
                                value={value !== '' ? [value] : []}
 | 
					 | 
				
			||||||
                        text={param.name}
 | 
					                        text={param.name}
 | 
				
			||||||
                                showReason={value === ''}
 | 
					                        isRequired={isRequired}
 | 
				
			||||||
                                input={value !== '' ? value : 'no value'}
 | 
					                        input={value !== undefined ? value : undefined}
 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
                            <ConditionallyRender
 | 
					 | 
				
			||||||
                                condition={notLastItem}
 | 
					 | 
				
			||||||
                                show={<StrategySeparator text="AND" />}
 | 
					 | 
				
			||||||
                            />
 | 
					 | 
				
			||||||
                        </Fragment>
 | 
					 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            case 'number':
 | 
					            case 'number':
 | 
				
			||||||
                    const number = parseParameterNumber(parameters[param.name]);
 | 
					                const isCorrect = !(
 | 
				
			||||||
 | 
					                    paramValue === undefined || paramValue === ''
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					                const number = parseParameterNumber(paramValue);
 | 
				
			||||||
                return (
 | 
					                return (
 | 
				
			||||||
                        <Fragment key={param?.name}>
 | 
					                    <CustomParameterItem
 | 
				
			||||||
                            <PlaygroundParameterItem
 | 
					 | 
				
			||||||
                                value={Boolean(number) ? [number] : []}
 | 
					 | 
				
			||||||
                        text={param.name}
 | 
					                        text={param.name}
 | 
				
			||||||
                                showReason={Boolean(number)}
 | 
					                        isRequired={isRequired}
 | 
				
			||||||
                                input={Boolean(number) ? number : 'no value'}
 | 
					                        input={isCorrect ? `${number}` : undefined}
 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
                            <ConditionallyRender
 | 
					 | 
				
			||||||
                                condition={notLastItem}
 | 
					 | 
				
			||||||
                                show={<StrategySeparator text="AND" />}
 | 
					 | 
				
			||||||
                            />
 | 
					 | 
				
			||||||
                        </Fragment>
 | 
					 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
            case 'default':
 | 
					            case 'default':
 | 
				
			||||||
                return null;
 | 
					                return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return <>{renderCustomStrategyParameters()}</>;
 | 
					    return (
 | 
				
			||||||
 | 
					        <>
 | 
				
			||||||
 | 
					            {items.map((item, index) => (
 | 
				
			||||||
 | 
					                <Fragment key={index}>
 | 
				
			||||||
 | 
					                    <ConditionallyRender
 | 
				
			||||||
 | 
					                        condition={index > 0}
 | 
				
			||||||
 | 
					                        show={<StrategySeparator text="AND" />}
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
 | 
					                    {item}
 | 
				
			||||||
 | 
					                </Fragment>
 | 
				
			||||||
 | 
					            ))}
 | 
				
			||||||
 | 
					        </>
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -4,8 +4,8 @@ export const useStyles = makeStyles()(theme => ({
 | 
				
			|||||||
    container: {
 | 
					    container: {
 | 
				
			||||||
        width: '100%',
 | 
					        width: '100%',
 | 
				
			||||||
        padding: theme.spacing(2, 3),
 | 
					        padding: theme.spacing(2, 3),
 | 
				
			||||||
        borderRadius: theme.shape.borderRadius,
 | 
					        borderRadius: theme.shape.borderRadiusMedium,
 | 
				
			||||||
        border: `1px solid ${theme.palette.divider}`,
 | 
					        border: `1px solid ${theme.palette.dividerAlternative}`,
 | 
				
			||||||
        display: 'flex',
 | 
					        display: 'flex',
 | 
				
			||||||
        flexDirection: 'row',
 | 
					        flexDirection: 'row',
 | 
				
			||||||
        alignItems: 'center',
 | 
					        alignItems: 'center',
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ export const useStyles = makeStyles()(theme => ({
 | 
				
			|||||||
        width: 'auto',
 | 
					        width: 'auto',
 | 
				
			||||||
        height: 'auto',
 | 
					        height: 'auto',
 | 
				
			||||||
        padding: theme.spacing(2, 3),
 | 
					        padding: theme.spacing(2, 3),
 | 
				
			||||||
        borderRadius: theme.shape.borderRadius,
 | 
					        borderRadius: theme.shape.borderRadiusMedium,
 | 
				
			||||||
        border: `1px solid ${theme.palette.divider}`,
 | 
					        border: `1px solid ${theme.palette.dividerAlternative}`,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
				
			|||||||
@ -23,10 +23,6 @@ const StyledStrategyExecutionWrapper = styled('div')(({ theme }) => ({
 | 
				
			|||||||
    padding: theme.spacing(0),
 | 
					    padding: theme.spacing(0),
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const StyledParamWrapper = styled('div')(({ theme }) => ({
 | 
					 | 
				
			||||||
    padding: theme.spacing(0, 0),
 | 
					 | 
				
			||||||
}));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export const StrategyExecution: VFC<IStrategyExecutionProps> = ({
 | 
					export const StrategyExecution: VFC<IStrategyExecutionProps> = ({
 | 
				
			||||||
    strategyResult,
 | 
					    strategyResult,
 | 
				
			||||||
    input,
 | 
					    input,
 | 
				
			||||||
@ -93,20 +89,15 @@ export const StrategyExecution: VFC<IStrategyExecutionProps> = ({
 | 
				
			|||||||
                    </Box>
 | 
					                    </Box>
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
            <StyledParamWrapper>
 | 
					 | 
				
			||||||
            <PlaygroundResultStrategyExecutionParameters
 | 
					            <PlaygroundResultStrategyExecutionParameters
 | 
				
			||||||
                parameters={parameters}
 | 
					                parameters={parameters}
 | 
				
			||||||
                constraints={constraints}
 | 
					                constraints={constraints}
 | 
				
			||||||
                input={input}
 | 
					                input={input}
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
                <StyledParamWrapper sx={{ pt: 2 }}>
 | 
					 | 
				
			||||||
            <CustomStrategyParams
 | 
					            <CustomStrategyParams
 | 
				
			||||||
                strategyName={strategyResult.name}
 | 
					                strategyName={strategyResult.name}
 | 
				
			||||||
                parameters={parameters}
 | 
					                parameters={parameters}
 | 
				
			||||||
                        constraints={constraints}
 | 
					 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
                </StyledParamWrapper>
 | 
					 | 
				
			||||||
            </StyledParamWrapper>
 | 
					 | 
				
			||||||
        </StyledStrategyExecutionWrapper>
 | 
					        </StyledStrategyExecutionWrapper>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -18,16 +18,16 @@ const StyledChipWrapper = styled(Box)(() => ({
 | 
				
			|||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const FeatureStatusCell = ({ feature }: IFeatureStatusCellProps) => {
 | 
					export const FeatureStatusCell = ({ feature }: IFeatureStatusCellProps) => {
 | 
				
			||||||
    const enabled = feature.isEnabled
 | 
					    const [enabled, label]: [boolean | 'unknown', string] = (() => {
 | 
				
			||||||
        ? true
 | 
					        if (feature?.isEnabled) {
 | 
				
			||||||
        : feature.strategies?.result === false
 | 
					            return [true, 'True'];
 | 
				
			||||||
        ? false
 | 
					        }
 | 
				
			||||||
        : 'unknown';
 | 
					        if (feature?.strategies?.result === false) {
 | 
				
			||||||
    const label = feature.isEnabled
 | 
					            return [false, 'False'];
 | 
				
			||||||
        ? 'True'
 | 
					        }
 | 
				
			||||||
        : feature.strategies?.result === false
 | 
					        return ['unknown', 'Unknown'];
 | 
				
			||||||
        ? 'False'
 | 
					    })();
 | 
				
			||||||
        : 'Unknown';
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <StyledCellBox>
 | 
					        <StyledCellBox>
 | 
				
			||||||
            <StyledChipWrapper data-loading>
 | 
					            <StyledChipWrapper data-loading>
 | 
				
			||||||
@ -35,7 +35,6 @@ export const FeatureStatusCell = ({ feature }: IFeatureStatusCellProps) => {
 | 
				
			|||||||
                    enabled={enabled}
 | 
					                    enabled={enabled}
 | 
				
			||||||
                    label={label}
 | 
					                    label={label}
 | 
				
			||||||
                    showIcon={enabled !== 'unknown'}
 | 
					                    showIcon={enabled !== 'unknown'}
 | 
				
			||||||
                    size={'medium'}
 | 
					 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            </StyledChipWrapper>
 | 
					            </StyledChipWrapper>
 | 
				
			||||||
        </StyledCellBox>
 | 
					        </StyledCellBox>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,9 @@
 | 
				
			|||||||
 | 
					import { VFC } from 'react';
 | 
				
			||||||
import { Chip, styled, useTheme } from '@mui/material';
 | 
					import { Chip, styled, useTheme } from '@mui/material';
 | 
				
			||||||
import { colors } from '../../../../../themes/colors';
 | 
					import { colors } from 'themes/colors';
 | 
				
			||||||
import { ConditionallyRender } from '../../../../common/ConditionallyRender/ConditionallyRender';
 | 
					import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
import React from 'react';
 | 
					import { ReactComponent as FeatureEnabledIcon } from 'assets/icons/isenabled-true.svg';
 | 
				
			||||||
import { ReactComponent as FeatureEnabledIcon } from '../../../../../assets/icons/isenabled-true.svg';
 | 
					import { ReactComponent as FeatureDisabledIcon } from 'assets/icons/isenabled-false.svg';
 | 
				
			||||||
import { ReactComponent as FeatureDisabledIcon } from '../../../../../assets/icons/isenabled-false.svg';
 | 
					 | 
				
			||||||
import { WarningOutlined } from '@mui/icons-material';
 | 
					import { WarningOutlined } from '@mui/icons-material';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IResultChipProps {
 | 
					interface IResultChipProps {
 | 
				
			||||||
@ -11,21 +11,18 @@ interface IResultChipProps {
 | 
				
			|||||||
    label: string;
 | 
					    label: string;
 | 
				
			||||||
    // Result icon - defaults to true
 | 
					    // Result icon - defaults to true
 | 
				
			||||||
    showIcon?: boolean;
 | 
					    showIcon?: boolean;
 | 
				
			||||||
    size?: 'default' | 'medium' | 'large';
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const StyledChip = styled(Chip)<{ width?: number }>(
 | 
					export const StyledChip = styled(Chip)(({ theme, icon }) => ({
 | 
				
			||||||
    ({ theme, width }) => ({
 | 
					    padding: theme.spacing(0, 1),
 | 
				
			||||||
        width: width ?? 60,
 | 
					 | 
				
			||||||
    height: 24,
 | 
					    height: 24,
 | 
				
			||||||
    borderRadius: theme.shape.borderRadius,
 | 
					    borderRadius: theme.shape.borderRadius,
 | 
				
			||||||
    fontWeight: theme.typography.fontWeightMedium,
 | 
					    fontWeight: theme.typography.fontWeightMedium,
 | 
				
			||||||
    ['& .MuiChip-label']: {
 | 
					    ['& .MuiChip-label']: {
 | 
				
			||||||
        padding: 0,
 | 
					        padding: 0,
 | 
				
			||||||
            paddingLeft: theme.spacing(0.5),
 | 
					        paddingLeft: Boolean(icon) ? theme.spacing(0.5) : 0,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    })
 | 
					}));
 | 
				
			||||||
);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const StyledFalseChip = styled(StyledChip)(({ theme }) => ({
 | 
					export const StyledFalseChip = styled(StyledChip)(({ theme }) => ({
 | 
				
			||||||
    border: `1px solid ${theme.palette.error.main}`,
 | 
					    border: `1px solid ${theme.palette.error.main}`,
 | 
				
			||||||
@ -60,12 +57,11 @@ export const StyledUnknownChip = styled(StyledChip)(({ theme }) => ({
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
}));
 | 
					}));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const PlaygroundResultChip = ({
 | 
					export const PlaygroundResultChip: VFC<IResultChipProps> = ({
 | 
				
			||||||
    enabled,
 | 
					    enabled,
 | 
				
			||||||
    label,
 | 
					    label,
 | 
				
			||||||
    showIcon = true,
 | 
					    showIcon = true,
 | 
				
			||||||
    size = 'default',
 | 
					}) => {
 | 
				
			||||||
}: IResultChipProps) => {
 | 
					 | 
				
			||||||
    const theme = useTheme();
 | 
					    const theme = useTheme();
 | 
				
			||||||
    const icon = (
 | 
					    const icon = (
 | 
				
			||||||
        <ConditionallyRender
 | 
					        <ConditionallyRender
 | 
				
			||||||
@ -91,10 +87,6 @@ export const PlaygroundResultChip = ({
 | 
				
			|||||||
        />
 | 
					        />
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let chipWidth = 60;
 | 
					 | 
				
			||||||
    if (size === 'medium') chipWidth = 72;
 | 
					 | 
				
			||||||
    if (size === 'large') chipWidth = 100;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <ConditionallyRender
 | 
					        <ConditionallyRender
 | 
				
			||||||
            condition={enabled === 'unknown' || enabled === 'unevaluated'}
 | 
					            condition={enabled === 'unknown' || enabled === 'unevaluated'}
 | 
				
			||||||
@ -102,7 +94,6 @@ export const PlaygroundResultChip = ({
 | 
				
			|||||||
                <StyledUnknownChip
 | 
					                <StyledUnknownChip
 | 
				
			||||||
                    icon={showIcon ? icon : undefined}
 | 
					                    icon={showIcon ? icon : undefined}
 | 
				
			||||||
                    label={label}
 | 
					                    label={label}
 | 
				
			||||||
                    width={chipWidth}
 | 
					 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            elseShow={
 | 
					            elseShow={
 | 
				
			||||||
@ -112,14 +103,12 @@ export const PlaygroundResultChip = ({
 | 
				
			|||||||
                        <StyledTrueChip
 | 
					                        <StyledTrueChip
 | 
				
			||||||
                            icon={showIcon ? icon : undefined}
 | 
					                            icon={showIcon ? icon : undefined}
 | 
				
			||||||
                            label={label}
 | 
					                            label={label}
 | 
				
			||||||
                            width={chipWidth}
 | 
					 | 
				
			||||||
                        />
 | 
					                        />
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    elseShow={
 | 
					                    elseShow={
 | 
				
			||||||
                        <StyledFalseChip
 | 
					                        <StyledFalseChip
 | 
				
			||||||
                            icon={showIcon ? icon : undefined}
 | 
					                            icon={showIcon ? icon : undefined}
 | 
				
			||||||
                            label={label}
 | 
					                            label={label}
 | 
				
			||||||
                            width={chipWidth}
 | 
					 | 
				
			||||||
                        />
 | 
					                        />
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
 | 
				
			|||||||
@ -47,10 +47,10 @@ export default createTheme({
 | 
				
			|||||||
        bold: 700,
 | 
					        bold: 700,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    shape: {
 | 
					    shape: {
 | 
				
			||||||
        borderRadius: '4px',
 | 
					        borderRadius: 4,
 | 
				
			||||||
        borderRadiusMedium: '8px',
 | 
					        borderRadiusMedium: 8,
 | 
				
			||||||
        borderRadiusLarge: '12px',
 | 
					        borderRadiusLarge: 12,
 | 
				
			||||||
        borderRadiusExtraLarge: '20px',
 | 
					        borderRadiusExtraLarge: 20,
 | 
				
			||||||
        tableRowHeight: 64,
 | 
					        tableRowHeight: 64,
 | 
				
			||||||
        tableRowHeightCompact: 56,
 | 
					        tableRowHeightCompact: 56,
 | 
				
			||||||
        tableRowHeightDense: 48,
 | 
					        tableRowHeightDense: 48,
 | 
				
			||||||
 | 
				
			|||||||
@ -120,9 +120,9 @@ declare module '@mui/material/styles' {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
declare module '@mui/system/createTheme/shape' {
 | 
					declare module '@mui/system/createTheme/shape' {
 | 
				
			||||||
    interface Shape {
 | 
					    interface Shape {
 | 
				
			||||||
        borderRadiusMedium: string;
 | 
					        borderRadiusMedium: number;
 | 
				
			||||||
        borderRadiusLarge: string;
 | 
					        borderRadiusLarge: number;
 | 
				
			||||||
        borderRadiusExtraLarge: string;
 | 
					        borderRadiusExtraLarge: number;
 | 
				
			||||||
        tableRowHeight: number;
 | 
					        tableRowHeight: number;
 | 
				
			||||||
        tableRowHeightCompact: number;
 | 
					        tableRowHeightCompact: number;
 | 
				
			||||||
        tableRowHeightDense: number;
 | 
					        tableRowHeightDense: number;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user