aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/ComputedAttributesPage.js
diff options
context:
space:
mode:
authorAshutosh Bishnoi <mail2bishnoi@gmail.com>2021-01-07 17:06:20 +0530
committerAshutosh Bishnoi <mail2bishnoi@gmail.com>2021-01-07 17:06:20 +0530
commite3ead466abdb03c5f1eb5d3979ad286d38ac95cb (patch)
treecdad1611572a9da78c79f41894f32294136fbf92 /modern/src/settings/ComputedAttributesPage.js
parenta87f06b4cb10014b431e0a3ea8d6ba1da5a02fc1 (diff)
downloadtrackermap-web-e3ead466abdb03c5f1eb5d3979ad286d38ac95cb.tar.gz
trackermap-web-e3ead466abdb03c5f1eb5d3979ad286d38ac95cb.tar.bz2
trackermap-web-e3ead466abdb03c5f1eb5d3979ad286d38ac95cb.zip
Hiding add computed attribute button for non admin users
Diffstat (limited to 'modern/src/settings/ComputedAttributesPage.js')
-rw-r--r--modern/src/settings/ComputedAttributesPage.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/modern/src/settings/ComputedAttributesPage.js b/modern/src/settings/ComputedAttributesPage.js
index 53d1172c..dde6b237 100644
--- a/modern/src/settings/ComputedAttributesPage.js
+++ b/modern/src/settings/ComputedAttributesPage.js
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import MainToolbar from '../MainToolbar';
import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, makeStyles, IconButton } from '@material-ui/core';
import MoreVertIcon from '@material-ui/icons/MoreVert';
+import { useSelector } from 'react-redux';
import t from '../common/localization';
import { useEffectAsync } from '../reactHelper';
import EditCollectionView from '../EditCollectionView';
@@ -17,6 +18,7 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => {
const classes = useStyles();
const [items, setItems] = useState([]);
+ const adminEnabled = useSelector(state => state.session.user && state.session.user.administrator);
useEffectAsync(async () => {
const response = await fetch('/api/attributes/computed');
@@ -30,7 +32,7 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => {
<Table>
<TableHead>
<TableRow>
- <TableCell className={classes.columnAction} />
+ {adminEnabled && (<TableCell className={classes.columnAction} />)}
<TableCell>{t('sharedDescription')}</TableCell>
<TableCell>{t('sharedAttribute')}</TableCell>
<TableCell>{t('sharedExpression')}</TableCell>
@@ -40,11 +42,15 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => {
<TableBody>
{items.map((item) => (
<TableRow key={item.id}>
- <TableCell className={classes.columnAction} padding="none">
- <IconButton onClick={(event) => onMenuClick(event.currentTarget, item.id)}>
- <MoreVertIcon />
- </IconButton>
- </TableCell>
+ {adminEnabled &&
+ (
+ <TableCell className={classes.columnAction} padding="none">
+ <IconButton onClick={(event) => onMenuClick(event.currentTarget, item.id)}>
+ <MoreVertIcon />
+ </IconButton>
+ </TableCell>
+ )
+ }
<TableCell>{item.description}</TableCell>
<TableCell>{item.attribute}</TableCell>
<TableCell>{item.expression}</TableCell>