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

fix: trimming strategy parameters (#2044)

This commit is contained in:
Tymoteusz Czech 2022-09-06 10:10:10 +02:00 committed by GitHub
parent 18fc5eebd2
commit 03ddb0ad74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,10 @@ export const StrategyParameter = ({
updateParameter(name, event.target.value);
};
const onChangeString = (event: React.ChangeEvent<HTMLInputElement>) => {
updateParameter(name, parseParameterString(event.target.value));
};
const onChangePercentage = (event: Event, next: number | number[]) => {
updateParameter(name, next.toString());
};
@ -46,6 +50,10 @@ export const StrategyParameter = ({
updateParameter(name, String(checked));
};
const onSetListConfig = (field: string, value: string) => {
updateParameter(field, parseParameterStrings(value).join(','));
};
if (type === 'percentage') {
return (
<div>
@ -69,7 +77,7 @@ export const StrategyParameter = ({
name={name}
list={parseParameterStrings(parameters[name])}
disabled={!editable}
setConfig={updateParameter}
setConfig={onSetListConfig}
errors={errors}
/>
<InputCaption text={description} />
@ -131,7 +139,7 @@ export const StrategyParameter = ({
helperText={error}
name={name}
label={label}
onChange={onChange}
onChange={onChangeString}
value={parseParameterString(parameters[name])}
/>
<InputCaption text={description} />