1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: only show link to create segment if you have permission (#2291)

This commit is contained in:
Nuno Góis 2022-10-31 08:45:31 +00:00 committed by GitHub
parent 9201f4f08f
commit ce6d2e56bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
import { Typography } from '@mui/material';
import { useStyles } from 'component/segments/SegmentEmpty/SegmentEmpty.styles';
import { Link } from 'react-router-dom';
import { CREATE_SEGMENT } from 'component/providers/AccessProvider/permissions';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import AccessContext from 'contexts/AccessContext';
import { useContext } from 'react';
export const SegmentEmpty = () => {
const { classes } = useStyles();
const { hasAccess } = useContext(AccessContext);
return (
<div className={classes.empty}>
@ -13,9 +18,14 @@ export const SegmentEmpty = () => {
your feature. The segment is often a collection of constraints
and can be reused.
</p>
<Link to="/segments/create" className={classes.paramButton}>
Create your first segment
</Link>
<ConditionallyRender
condition={hasAccess(CREATE_SEGMENT)}
show={
<Link to="/segments/create" className={classes.paramButton}>
Create your first segment
</Link>
}
/>
</div>
);
};