mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
fix: make sure the override context name exists (#877)
This commit is contained in:
parent
9dd88b488f
commit
b5db7b8326
@ -25,6 +25,7 @@ import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect';
|
||||
import { useStyles } from './AddFeatureVariant.styles';
|
||||
import Input from 'component/common/Input/Input';
|
||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||
|
||||
const payloadOptions = [
|
||||
{ key: 'string', label: 'string' },
|
||||
@ -64,6 +65,7 @@ export const AddVariant = ({
|
||||
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
||||
const { feature } = useFeature(projectId, featureId);
|
||||
const [variants, setVariants] = useState<IFeatureVariant[]>([]);
|
||||
const { context } = useUnleashContext();
|
||||
|
||||
const isValidJSON = (input: string): boolean => {
|
||||
try {
|
||||
@ -236,10 +238,13 @@ export const AddVariant = ({
|
||||
|
||||
const onAddOverride = (e: React.SyntheticEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (context.length > 0) {
|
||||
setOverrides([
|
||||
...overrides,
|
||||
...[{ contextName: 'userId', values: [] }],
|
||||
...[{ contextName: context[0].name, values: [] }],
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
const isFixWeight = data.weightType === weightTypes.FIX;
|
||||
|
Loading…
Reference in New Issue
Block a user