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 { useStyles } from './AddFeatureVariant.styles';
|
||||||
import Input from 'component/common/Input/Input';
|
import Input from 'component/common/Input/Input';
|
||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
|
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||||
|
|
||||||
const payloadOptions = [
|
const payloadOptions = [
|
||||||
{ key: 'string', label: 'string' },
|
{ key: 'string', label: 'string' },
|
||||||
@ -64,6 +65,7 @@ export const AddVariant = ({
|
|||||||
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
||||||
const { feature } = useFeature(projectId, featureId);
|
const { feature } = useFeature(projectId, featureId);
|
||||||
const [variants, setVariants] = useState<IFeatureVariant[]>([]);
|
const [variants, setVariants] = useState<IFeatureVariant[]>([]);
|
||||||
|
const { context } = useUnleashContext();
|
||||||
|
|
||||||
const isValidJSON = (input: string): boolean => {
|
const isValidJSON = (input: string): boolean => {
|
||||||
try {
|
try {
|
||||||
@ -236,10 +238,13 @@ export const AddVariant = ({
|
|||||||
|
|
||||||
const onAddOverride = (e: React.SyntheticEvent) => {
|
const onAddOverride = (e: React.SyntheticEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (context.length > 0) {
|
||||||
setOverrides([
|
setOverrides([
|
||||||
...overrides,
|
...overrides,
|
||||||
...[{ contextName: 'userId', values: [] }],
|
...[{ contextName: context[0].name, values: [] }],
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isFixWeight = data.weightType === weightTypes.FIX;
|
const isFixWeight = data.weightType === weightTypes.FIX;
|
||||||
|
Loading…
Reference in New Issue
Block a user