aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-01-31 15:25:18 -0800
committerAnton Tananaev <anton@traccar.org>2023-01-31 15:25:18 -0800
commit21991edfc7c67bd3e27998f06473d211b6685c6c (patch)
treecfbabd7c4d61691ffb3f3d8d3a9eaa917e6b282b
parentdcb1fa21441cb292fd66253a97b083e5d47604e5 (diff)
downloadtrackermap-web-21991edfc7c67bd3e27998f06473d211b6685c6c.tar.gz
trackermap-web-21991edfc7c67bd3e27998f06473d211b6685c6c.tar.bz2
trackermap-web-21991edfc7c67bd3e27998f06473d211b6685c6c.zip
Handle readonly cases
-rw-r--r--modern/src/main/MainToolbar.js2
-rw-r--r--modern/src/reports/components/ReportFilter.js9
-rw-r--r--modern/src/reports/components/ReportsMenu.js39
3 files changed, 31 insertions, 19 deletions
diff --git a/modern/src/main/MainToolbar.js b/modern/src/main/MainToolbar.js
index caba2410..b029529c 100644
--- a/modern/src/main/MainToolbar.js
+++ b/modern/src/main/MainToolbar.js
@@ -167,7 +167,7 @@ const MainToolbar = ({
</div>
</Popover>
<IconButton edge="end" onClick={() => navigate('/settings/device')} disabled={deviceReadonly}>
- <Tooltip open={Object.keys(devices).length === 0} title={t('deviceRegisterFirst')} arrow>
+ <Tooltip open={!deviceReadonly && Object.keys(devices).length === 0} title={t('deviceRegisterFirst')} arrow>
<AddIcon />
</Tooltip>
</IconButton>
diff --git a/modern/src/reports/components/ReportFilter.js b/modern/src/reports/components/ReportFilter.js
index 6ffb56d9..de86b7af 100644
--- a/modern/src/reports/components/ReportFilter.js
+++ b/modern/src/reports/components/ReportFilter.js
@@ -9,12 +9,15 @@ import useReportStyles from '../common/useReportStyles';
import { reportsActions } from '../../store';
import SplitButton from '../../common/components/SplitButton';
import SelectField from '../../common/components/SelectField';
+import { useRestriction } from '../../common/util/permissions';
const ReportFilter = ({ children, handleSubmit, handleSchedule, showOnly, ignoreDevice, multiDevice, includeGroups }) => {
const classes = useReportStyles();
const dispatch = useDispatch();
const t = useTranslation();
+ const readonly = useRestriction('readonly');
+
const devices = useSelector((state) => state.devices.items);
const groups = useSelector((state) => state.groups.items);
const selectedDeviceId = useSelector((state) => state.devices.selectedId);
@@ -208,7 +211,11 @@ const ReportFilter = ({ children, handleSubmit, handleSchedule, showOnly, ignore
onClick={handleClick}
selected={button}
setSelected={(value) => dispatch(reportsActions.updateButton(value))}
- options={{
+ options={readonly ? {
+ json: t('reportShow'),
+ export: t('reportExport'),
+ mail: t('reportEmail'),
+ } : {
json: t('reportShow'),
export: t('reportExport'),
mail: t('reportEmail'),
diff --git a/modern/src/reports/components/ReportsMenu.js b/modern/src/reports/components/ReportsMenu.js
index 3616f828..a31c3afe 100644
--- a/modern/src/reports/components/ReportsMenu.js
+++ b/modern/src/reports/components/ReportsMenu.js
@@ -13,7 +13,7 @@ import RouteIcon from '@mui/icons-material/Route';
import EventRepeatIcon from '@mui/icons-material/EventRepeat';
import { Link, useLocation } from 'react-router-dom';
import { useTranslation } from '../../common/components/LocalizationProvider';
-import { useAdministrator } from '../../common/util/permissions';
+import { useAdministrator, useRestriction } from '../../common/util/permissions';
const MenuItem = ({
title, link, icon, selected,
@@ -29,6 +29,7 @@ const ReportsMenu = () => {
const location = useLocation();
const admin = useAdministrator();
+ const readonly = useRestriction('readonly');
return (
<>
@@ -75,22 +76,26 @@ const ReportsMenu = () => {
icon={<RouteIcon />}
/>
</List>
- <Divider />
- <List>
- <MenuItem
- title={t('reportScheduled')}
- link="/reports/scheduled"
- icon={<EventRepeatIcon />}
- />
- {admin && (
- <MenuItem
- title={t('statisticsTitle')}
- link="/reports/statistics"
- icon={<BarChartIcon />}
- selected={location.pathname === '/reports/statistics'}
- />
- )}
- </List>
+ {(admin || !readonly) && (
+ <>
+ <Divider />
+ <List>
+ <MenuItem
+ title={t('reportScheduled')}
+ link="/reports/scheduled"
+ icon={<EventRepeatIcon />}
+ />
+ {admin && (
+ <MenuItem
+ title={t('statisticsTitle')}
+ link="/reports/statistics"
+ icon={<BarChartIcon />}
+ selected={location.pathname === '/reports/statistics'}
+ />
+ )}
+ </List>
+ </>
+ )}
</>
);
};