mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
fix formatting - prettier
This commit is contained in:
parent
e432ae45e0
commit
d013475538
@ -7,7 +7,6 @@ import {
|
|||||||
PlaygroundStrategySchema,
|
PlaygroundStrategySchema,
|
||||||
} from 'hooks/api/actions/usePlayground/playground.model';
|
} from 'hooks/api/actions/usePlayground/playground.model';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import React from 'react';
|
|
||||||
import { PlaygroundResultConstraintExecution } from './PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution';
|
import { PlaygroundResultConstraintExecution } from './PlaygroundResultConstraintExecution/PlaygroundResultConstraintExecution';
|
||||||
import { PlaygroundResultSegmentExecution } from './PlaygroundResultSegmentExecution/PlaygroundResultSegmentExecution';
|
import { PlaygroundResultSegmentExecution } from './PlaygroundResultSegmentExecution/PlaygroundResultSegmentExecution';
|
||||||
import { PlaygroundResultStrategyExecutionParameters } from './PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters';
|
import { PlaygroundResultStrategyExecutionParameters } from './PlaygroundResultStrategyExecutionParameters/PlaygroundResultStrategyExecutionParameters';
|
||||||
|
@ -4,12 +4,14 @@ import {
|
|||||||
parseParameterStrings,
|
parseParameterStrings,
|
||||||
} from 'utils/parseParameter';
|
} from 'utils/parseParameter';
|
||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import { PlaygroundParameterItem } from '../PlaygroundParamteterItem/PlaygroundParameterItem';
|
import { PlaygroundConstraintItem } from '../PlaygroundConstraintItem/PlaygroundConstraintItem';
|
||||||
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 { Chip } from '@mui/material';
|
||||||
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle';
|
import PercentageCircle from 'component/common/PercentageCircle/PercentageCircle';
|
||||||
|
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
||||||
import { PlaygroundConstraintSchema } from 'hooks/api/actions/usePlayground/playground.model';
|
import { PlaygroundConstraintSchema } from 'hooks/api/actions/usePlayground/playground.model';
|
||||||
|
import { useStyles } from '../PlaygroundResultStrategyExecution.styles';
|
||||||
import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies';
|
import { useStrategies } from 'hooks/api/getters/useStrategies/useStrategies';
|
||||||
|
|
||||||
interface PlaygroundResultStrategyExecutionCustomStrategyProps {
|
interface PlaygroundResultStrategyExecutionCustomStrategyProps {
|
||||||
@ -23,16 +25,15 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
|
|||||||
constraints,
|
constraints,
|
||||||
parameters,
|
parameters,
|
||||||
}: PlaygroundResultStrategyExecutionCustomStrategyProps) => {
|
}: PlaygroundResultStrategyExecutionCustomStrategyProps) => {
|
||||||
|
const { classes: styles } = useStyles();
|
||||||
const { strategies } = useStrategies();
|
const { strategies } = useStrategies();
|
||||||
|
|
||||||
const definition = strategies.find(strategyDefinition => {
|
const definition = strategies.find(strategyDefinition => {
|
||||||
return strategyDefinition.name === strategyName;
|
return strategyDefinition.name === strategyName;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!definition?.editable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderCustomStrategyParameters = () => {
|
const renderCustomStrategyParameters = () => {
|
||||||
|
if (!definition?.editable) return null;
|
||||||
return definition?.parameters.map((param: any, index: number) => {
|
return definition?.parameters.map((param: any, index: number) => {
|
||||||
const notLastItem = index !== definition?.parameters?.length - 1;
|
const notLastItem = index !== definition?.parameters?.length - 1;
|
||||||
switch (param?.type) {
|
switch (param?.type) {
|
||||||
@ -42,7 +43,7 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Fragment key={param?.name}>
|
<Fragment key={param?.name}>
|
||||||
<PlaygroundParameterItem
|
<PlaygroundConstraintItem
|
||||||
value={values}
|
value={values}
|
||||||
text={param.name}
|
text={param.name}
|
||||||
/>
|
/>
|
||||||
@ -80,54 +81,93 @@ export const PlaygroundResultStrategyExecutionCustomStrategyParams = ({
|
|||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
const bool = Boolean(parameters[param?.name]);
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={param?.name}>
|
<Fragment key={param.name}>
|
||||||
<PlaygroundParameterItem
|
<p key={param.name}>
|
||||||
value={bool ? ['True'] : []}
|
<StringTruncator
|
||||||
text={param.name}
|
maxLength={15}
|
||||||
showReason={!bool}
|
maxWidth="150"
|
||||||
input={bool ? bool : 'no value'}
|
text={param.name}
|
||||||
/>
|
/>{' '}
|
||||||
|
{parameters[param.name]}
|
||||||
|
</p>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={notLastItem}
|
condition={
|
||||||
show={<StrategySeparator text="AND" />}
|
typeof parameters[param.name] !==
|
||||||
|
'undefined'
|
||||||
|
}
|
||||||
|
show={
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={notLastItem}
|
||||||
|
show={<StrategySeparator text="AND" />}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
case 'string':
|
case 'string':
|
||||||
const value =
|
const value = parseParameterString(parameters[param.name]);
|
||||||
parseParameterString(parameters[param.name]) ??
|
|
||||||
'no value';
|
|
||||||
return (
|
return (
|
||||||
<Fragment key={param?.name}>
|
<ConditionallyRender
|
||||||
<PlaygroundParameterItem
|
condition={
|
||||||
value={value !== '' ? [value] : []}
|
typeof parameters[param.name] !== 'undefined'
|
||||||
text={param.name}
|
}
|
||||||
showReason={value === ''}
|
key={param.name}
|
||||||
input={value !== '' ? value : 'no value'}
|
show={
|
||||||
/>
|
<>
|
||||||
<ConditionallyRender
|
<p className={styles.valueContainer}>
|
||||||
condition={notLastItem}
|
<StringTruncator
|
||||||
show={<StrategySeparator text="AND" />}
|
maxWidth="150"
|
||||||
/>
|
maxLength={15}
|
||||||
</Fragment>
|
text={param.name}
|
||||||
|
/>
|
||||||
|
<span className={styles.valueSeparator}>
|
||||||
|
is set to
|
||||||
|
</span>
|
||||||
|
<StringTruncator
|
||||||
|
maxWidth="300"
|
||||||
|
text={value}
|
||||||
|
maxLength={50}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={notLastItem}
|
||||||
|
show={<StrategySeparator text="AND" />}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
case 'number':
|
case 'number':
|
||||||
const number = parseParameterNumber(parameters[param.name]);
|
const number = parseParameterNumber(parameters[param.name]);
|
||||||
return (
|
return (
|
||||||
<Fragment key={param?.name}>
|
<ConditionallyRender
|
||||||
<PlaygroundParameterItem
|
condition={number !== undefined}
|
||||||
value={Boolean(number) ? [number] : []}
|
key={param.name}
|
||||||
text={param.name}
|
show={
|
||||||
showReason={Boolean(number)}
|
<>
|
||||||
input={Boolean(number) ? number : 'no value'}
|
<p className={styles.valueContainer}>
|
||||||
/>
|
<StringTruncator
|
||||||
<ConditionallyRender
|
maxLength={15}
|
||||||
condition={notLastItem}
|
maxWidth="150"
|
||||||
show={<StrategySeparator text="AND" />}
|
text={param.name}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
<span className={styles.valueSeparator}>
|
||||||
|
is set to
|
||||||
|
</span>
|
||||||
|
<StringTruncator
|
||||||
|
maxWidth="300"
|
||||||
|
text={String(number)}
|
||||||
|
maxLength={50}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
<ConditionallyRender
|
||||||
|
condition={notLastItem}
|
||||||
|
show={<StrategySeparator text="AND" />}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
case 'default':
|
case 'default':
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user