import React from 'react'; import { Rollout, Payload } from './Helpers'; import { Input, Button, Icon } from 'UI'; import { observer } from 'mobx-react-lite'; import { useStore } from 'App/mstore'; import cn from 'classnames'; const alphabet = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ]; function Multivariant({ readonly }: { readonly?: boolean }) { const { featureFlagsStore } = useStore(); const avg = React.useMemo(() => { return Math.floor(100 / featureFlagsStore.currentFflag!.variants.length); }, [featureFlagsStore.currentFflag!.variants.length]); return (
Users who meet release conditions will be server variant's key based on specific distribution.
Variant
Key
Description
{readonly ? null : (
Distribute Equally
)}
{featureFlagsStore.currentFflag!.variants.map((variant, ind) => { return (
{alphabet[ind] || ind + 1}
{readonly ? ( {variant.value} ) : ( ) => { if (e.target.value?.length > 25) return; variant.setKey(e.target.value); }} /> )}
{readonly ? (
{variant.description}
) : ( ) => variant.setDescription(e.target.value) } /> )}
{readonly ? ( {variant.payload} ) : ( ) => variant.setPayload(e.target.value) } /> )}
{readonly ? (
{variant.rolloutPercentage}
) : ( <> ) => { if (e.target.value === '') variant.setRollout(0); variant.setRollout(parseInt(e.target.value.replace(/\D/g, ''), 10)); }} />
featureFlagsStore.currentFflag!.variants.length === 1 ? null : featureFlagsStore.currentFflag!.removeVariant(variant.index) } >
)}
); })}
{readonly ? null : (
{featureFlagsStore.currentFflag!.variants.length < 10 ? ( ) : null} {featureFlagsStore.currentFflag!.isRedDistribution ? (
Total distribution is less than 100%.
) : null}
)}
); } export default observer(Multivariant);