Skip to content

Commit 4d88872

Browse files
committed
wrap create buttons in Language Overview with permission guards
1 parent a39ca9d commit 4d88872

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

src/components/posts/PostList.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ export const PostList = ({
3232
}: PostListProps) => {
3333
const { classes } = useStyles();
3434
const [createPostState, createPost] = useDialog();
35+
const canCreate = rest.data?.canCreate;
3536

3637
return (
3738
<div>
3839
<Grid container spacing={2} alignItems="center">
3940
<Grid item>
4041
<Typography variant="h3">Posts</Typography>
4142
</Grid>
42-
<Grid item>
43-
<Tooltip title="Add Post">
44-
<Fab color="error" onClick={createPost}>
45-
<Add />
46-
</Fab>
47-
</Tooltip>
48-
</Grid>
43+
{canCreate && (
44+
<Grid item>
45+
<Tooltip title="Add Post">
46+
<Fab color="error" onClick={createPost}>
47+
<Add />
48+
</Fab>
49+
</Tooltip>
50+
</Grid>
51+
)}
4952
</Grid>
5053
<List
5154
{...rest}

src/scenes/Languages/Detail/LanguageDetail.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,22 @@ export const LanguageDetail = () => {
236236
<Grid item>
237237
<Typography variant="h3">Locations</Typography>
238238
</Grid>
239-
<Grid item>
240-
<Tooltip title="Add location">
241-
<Fab
242-
color="error"
243-
aria-label="add location"
244-
className={
245-
locations?.canCreate === true
246-
? undefined
247-
: classes.hidden
248-
}
249-
onClick={addLocation}
250-
>
251-
<Add />
252-
</Fab>
253-
</Tooltip>
254-
</Grid>
239+
{locations?.canCreate && (
240+
<Grid item>
241+
<Tooltip title="Add location">
242+
<Fab
243+
color="error"
244+
aria-label="add location"
245+
className={
246+
locations.canCreate ? undefined : classes.hidden
247+
}
248+
onClick={addLocation}
249+
>
250+
<Add />
251+
</Fab>
252+
</Tooltip>
253+
</Grid>
254+
)}
255255
</Grid>
256256
{listOrPlaceholders(locations?.items, 3).map(
257257
(location, index) => (

0 commit comments

Comments
 (0)