2022-05-02 15:52:41 +02:00
|
|
|
import { Alert } from '@mui/material';
|
2022-04-07 14:47:24 +02:00
|
|
|
import { useStyles } from 'component/segments/SegmentDocs/SegmentDocs.styles';
|
2022-06-02 10:58:55 +02:00
|
|
|
import { useSegmentLimits } from 'hooks/api/getters/useSegmentLimits/useSegmentLimits';
|
2022-04-07 14:47:24 +02:00
|
|
|
|
|
|
|
export const SegmentDocsWarning = () => {
|
2022-05-02 15:52:41 +02:00
|
|
|
const { classes: styles } = useStyles();
|
2022-04-07 14:47:24 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Alert severity="warning">
|
|
|
|
<p className={styles.paragraph}>
|
|
|
|
Segments is an experimental feature available to select users.
|
|
|
|
</p>
|
|
|
|
<p className={styles.paragraph}>
|
|
|
|
This feature is currently in development. Future versions may
|
|
|
|
require to update your SDKs.
|
|
|
|
</p>
|
|
|
|
<p className={styles.paragraph}>
|
|
|
|
<SegmentDocsLink />
|
|
|
|
</p>
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SegmentDocsValuesWarning = () => {
|
2022-06-02 10:58:55 +02:00
|
|
|
const { segmentValuesLimit } = useSegmentLimits();
|
|
|
|
|
|
|
|
if (typeof segmentValuesLimit === 'undefined') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-04-07 14:47:24 +02:00
|
|
|
return (
|
|
|
|
<Alert severity="warning">
|
|
|
|
Segments is an experimental feature available to select users.
|
2022-06-02 10:58:55 +02:00
|
|
|
Currently, segments are limited to at most {segmentValuesLimit}{' '}
|
2022-04-07 14:47:24 +02:00
|
|
|
values. <SegmentLimitsLink />
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SegmentDocsValuesError = (props: { values: number }) => {
|
2022-06-02 10:58:55 +02:00
|
|
|
const { segmentValuesLimit } = useSegmentLimits();
|
|
|
|
|
|
|
|
if (typeof segmentValuesLimit === 'undefined') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-04-07 14:47:24 +02:00
|
|
|
return (
|
|
|
|
<Alert severity="error">
|
2022-06-02 10:58:55 +02:00
|
|
|
Segments are limited to at most {segmentValuesLimit} values. This
|
2022-04-07 14:47:24 +02:00
|
|
|
segment currently has {props.values}{' '}
|
|
|
|
{props.values === 1 ? 'value' : 'values'}.
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const SegmentDocsStrategyWarning = () => {
|
2022-06-02 10:58:55 +02:00
|
|
|
const { strategySegmentsLimit } = useSegmentLimits();
|
|
|
|
|
|
|
|
if (typeof strategySegmentsLimit === 'undefined') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-04-07 14:47:24 +02:00
|
|
|
return (
|
|
|
|
<Alert severity="warning">
|
2022-06-02 10:58:55 +02:00
|
|
|
Strategies are limited to {strategySegmentsLimit} segments.{' '}
|
2022-04-07 14:47:24 +02:00
|
|
|
<SegmentLimitsLink />
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const SegmentDocsLink = () => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<a
|
|
|
|
href={segmentsDocsLink}
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
style={{ color: 'inherit' }}
|
|
|
|
>
|
|
|
|
Read more about segments in the documentation
|
|
|
|
</a>
|
|
|
|
.
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const SegmentLimitsLink = () => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
Please{' '}
|
|
|
|
<a
|
|
|
|
href="https://slack.unleash.run"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
|
|
|
style={{ color: 'inherit' }}
|
|
|
|
>
|
|
|
|
get in touch
|
|
|
|
</a>{' '}
|
|
|
|
if you would like this limit increased.
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const segmentsDocsLink = 'https://docs.getunleash.io/reference/segments';
|