mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-11 00:08:30 +01:00
refactor: fix override field selection (#925)
This commit is contained in:
parent
efe52cb1aa
commit
96ccc24b8b
@ -25,6 +25,7 @@ import Input from 'component/common/Input/Input';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||
import { HelpIcon } from 'component/common/HelpIcon/HelpIcon';
|
||||
import produce from 'immer';
|
||||
|
||||
const payloadOptions = [
|
||||
{ key: 'string', label: 'string' },
|
||||
@ -199,27 +200,18 @@ export const AddVariant = ({
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const updateOverrideType =
|
||||
(index: number, contextName: string) => (value: string) => {
|
||||
setOverrides(
|
||||
overrides.map((o, i) => {
|
||||
if (i === index) {
|
||||
// @ts-expect-error
|
||||
o[contextName] = value;
|
||||
}
|
||||
|
||||
return o;
|
||||
})
|
||||
);
|
||||
};
|
||||
const updateOverrideType = (index: number) => (value: string) => {
|
||||
setOverrides(
|
||||
produce(draft => {
|
||||
draft[index].contextName = value;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
const updateOverrideValues = (index: number, values: string[]) => {
|
||||
setOverrides(
|
||||
overrides.map((o, i) => {
|
||||
if (i === index) {
|
||||
o.values = values;
|
||||
}
|
||||
return o;
|
||||
produce(draft => {
|
||||
draft[index].values = values;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ export const OverrideConfig = ({
|
||||
classes={{
|
||||
root: classnames(commonStyles.fullWidth),
|
||||
}}
|
||||
onChange={updateOverrideType(i, o.contextName)}
|
||||
onChange={updateOverrideType(i)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid md={7} sm={7} xs={6} item>
|
||||
|
Loading…
Reference in New Issue
Block a user