mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-12 01:17:04 +02:00
feat: pointer to strategy variants (#4440)
This commit is contained in:
parent
32954e8168
commit
b927ef8b70
@ -4,12 +4,21 @@ export const StrategyVariantsUpgradeAlert = () => {
|
|||||||
return (
|
return (
|
||||||
<Alert severity="warning" sx={{ mb: 3 }}>
|
<Alert severity="warning" sx={{ mb: 3 }}>
|
||||||
Remember to update your Unleash client! Strategy variants require
|
Remember to update your Unleash client! Strategy variants require
|
||||||
new SDK versions. <DocsLink />.
|
new SDK versions. <DocsSdkSupportLink />.
|
||||||
</Alert>
|
</Alert>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DocsLink = () => {
|
export const StrategyVariantsPreferredAlert = () => {
|
||||||
|
return (
|
||||||
|
<Alert severity="warning" sx={{ mb: 4 }}>
|
||||||
|
If you want advanced targeting capabilities you should use{' '}
|
||||||
|
<b>variants inside strategies</b>. <DocsLink />
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const DocsSdkSupportLink = () => {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href="https://docs.getunleash.io/reference/feature-strategy-variants#client-sdk-support"
|
href="https://docs.getunleash.io/reference/feature-strategy-variants#client-sdk-support"
|
||||||
@ -20,3 +29,15 @@ const DocsLink = () => {
|
|||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const DocsLink = () => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href="https://docs.getunleash.io/reference/feature-strategy-variants"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
Read more
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
import { Alert, styled } from '@mui/material';
|
||||||
|
import { FC } from 'react';
|
||||||
|
|
||||||
|
const StyledAlert = styled(Alert)(({ theme }) => ({
|
||||||
|
marginBottom: theme.spacing(2),
|
||||||
|
'& code': {
|
||||||
|
fontWeight: theme.fontWeight.bold,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
export const VariantInfoAlert: FC<{ mode: 'feature' | 'strategy' }> = ({
|
||||||
|
mode,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<StyledAlert severity="info">
|
||||||
|
Variant allows you to return a variant object if the{' '}
|
||||||
|
{mode === 'feature'
|
||||||
|
? 'feature toggle is considered enabled '
|
||||||
|
: 'this strategy is active '}
|
||||||
|
for the current request. When using variants you should use the{' '}
|
||||||
|
<code>getVariant()</code> method in the Client SDK.
|
||||||
|
</StyledAlert>
|
||||||
|
);
|
||||||
|
};
|
@ -324,7 +324,7 @@ export const EnvironmentVariantsModal = ({
|
|||||||
<FormTemplate
|
<FormTemplate
|
||||||
modal
|
modal
|
||||||
title=""
|
title=""
|
||||||
description="Variants allows you to return a variant object if the feature toggle is considered enabled for the current request."
|
description="Variants allow you to return a variant object if the feature toggle is considered enabled for the current request."
|
||||||
documentationLink="https://docs.getunleash.io/reference/feature-toggle-variants"
|
documentationLink="https://docs.getunleash.io/reference/feature-toggle-variants"
|
||||||
documentationLinkLabel="Feature toggle variants documentation"
|
documentationLinkLabel="Feature toggle variants documentation"
|
||||||
formatApiCode={formatApiCode}
|
formatApiCode={formatApiCode}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as jsonpatch from 'fast-json-patch';
|
import * as jsonpatch from 'fast-json-patch';
|
||||||
|
|
||||||
import { Alert, styled, useMediaQuery, useTheme } from '@mui/material';
|
import { styled, useMediaQuery, useTheme } from '@mui/material';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { PageContent } from 'component/common/PageContent/PageContent';
|
import { PageContent } from 'component/common/PageContent/PageContent';
|
||||||
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
||||||
@ -27,13 +27,9 @@ import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
|||||||
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
||||||
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
|
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton';
|
||||||
import { Edit } from '@mui/icons-material';
|
import { Edit } from '@mui/icons-material';
|
||||||
|
import { VariantInfoAlert } from 'component/common/VariantInfoAlert/VariantInfoAlert';
|
||||||
const StyledAlert = styled(Alert)(({ theme }) => ({
|
import { StrategyVariantsPreferredAlert } from 'component/common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
|
||||||
marginBottom: theme.spacing(4),
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
'& code': {
|
|
||||||
fontWeight: theme.fontWeight.bold,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledButtonContainer = styled('div')(({ theme }) => ({
|
const StyledButtonContainer = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -41,6 +37,7 @@ const StyledButtonContainer = styled('div')(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const FeatureEnvironmentVariants = () => {
|
export const FeatureEnvironmentVariants = () => {
|
||||||
|
const { uiConfig } = useUiConfig();
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
|
||||||
@ -269,12 +266,12 @@ export const FeatureEnvironmentVariants = () => {
|
|||||||
</PageHeader>
|
</PageHeader>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<StyledAlert severity="info">
|
<VariantInfoAlert mode="feature" />
|
||||||
Variants allows you to return a variant object if the feature
|
<ConditionallyRender
|
||||||
toggle is considered enabled for the current request. When using
|
condition={Boolean(uiConfig?.flags?.strategyVariant)}
|
||||||
variants you should use the <code>getVariant()</code> method in
|
show={<StrategyVariantsPreferredAlert />}
|
||||||
the Client SDK.
|
/>
|
||||||
</StyledAlert>
|
|
||||||
{environments.map(environment => {
|
{environments.map(environment => {
|
||||||
const otherEnvsWithVariants = environments.filter(
|
const otherEnvsWithVariants = environments.filter(
|
||||||
({ name, variants }) =>
|
({ name, variants }) =>
|
||||||
|
@ -12,6 +12,7 @@ import SplitPreviewSlider from './SplitPreviewSlider/SplitPreviewSlider';
|
|||||||
import { HelpIcon } from '../../common/HelpIcon/HelpIcon';
|
import { HelpIcon } from '../../common/HelpIcon/HelpIcon';
|
||||||
import { StrategyVariantsUpgradeAlert } from '../../common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
|
import { StrategyVariantsUpgradeAlert } from '../../common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
import { VariantInfoAlert } from '../../common/VariantInfoAlert/VariantInfoAlert';
|
||||||
|
|
||||||
const StyledVariantForms = styled('div')({
|
const StyledVariantForms = styled('div')({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -119,6 +120,7 @@ export const StrategyVariants: FC<{
|
|||||||
/>
|
/>
|
||||||
</Typography>
|
</Typography>
|
||||||
<StyledVariantForms>
|
<StyledVariantForms>
|
||||||
|
<VariantInfoAlert mode="strategy" />
|
||||||
<StrategyVariantsUpgradeAlert />
|
<StrategyVariantsUpgradeAlert />
|
||||||
{variantsEdit.map((variant, i) => (
|
{variantsEdit.map((variant, i) => (
|
||||||
<VariantForm
|
<VariantForm
|
||||||
|
Loading…
Reference in New Issue
Block a user