Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions frontend/src/component/segments/SegmentEmpty/SegmentEmpty.tsx
Original file line number Diff line number Diff line change
@@ -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>
);
};