Skip to content

Commit

Permalink
fix: only show link to create segment if you have permission (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Oct 31, 2022
1 parent 9201f4f commit ce6d2e5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions frontend/src/component/segments/SegmentEmpty/SegmentEmpty.tsx
@@ -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}>
Expand All @@ -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>
);
};

0 comments on commit ce6d2e5

Please sign in to comment.