NotAllowed component

master
Tudor Stanciu 2023-04-18 02:46:21 +03:00
parent 4dff02b87f
commit 2b6751335f
5 changed files with 50 additions and 1 deletions

View File

@ -9,4 +9,6 @@ Add in settings:
- reset cache - reset cache
- ping interval - ping interval
- notifications - notifications
- test notification mechanism - test notification mechanism
- permissions
- permissions hierarchy

View File

@ -36,6 +36,12 @@
"Label": "Login", "Label": "Login",
"IncorrectCredentials": "Incorrect credentials." "IncorrectCredentials": "Incorrect credentials."
}, },
"Announcements": {
"NotAllowed": {
"Title": "It seems that you do not have sufficient rights to view this page.",
"Message": "For more details, please contact an administrator."
}
},
"Dashboard": { "Dashboard": {
"Announcements": { "Announcements": {
"Guest": { "Guest": {

View File

@ -27,6 +27,12 @@
"Label": "Autentificare", "Label": "Autentificare",
"IncorrectCredentials": "Credențiale incorecte." "IncorrectCredentials": "Credențiale incorecte."
}, },
"Announcements": {
"NotAllowed": {
"Title": "Se pare că nu aveți suficiente drepturi pentru a vizualiza această pagină.",
"Message": "Pentru mai multe detalii, vă rugăm să contactați un administrator."
}
},
"Dashboard": { "Dashboard": {
"Announcements": { "Announcements": {
"Guest": { "Guest": {

View File

@ -0,0 +1,29 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Alert, AlertTitle } from "@material-ui/lab";
import { useTranslation } from "react-i18next";
const useStyles = makeStyles(theme => ({
alert: {
width: "100%",
"& > * + *": {
marginTop: theme.spacing(1)
}
}
}));
const NotAllowed = () => {
const classes = useStyles();
const { t } = useTranslation();
return (
<div className={classes.alert}>
<Alert variant="outlined" severity="error">
<AlertTitle>{t("Announcements.NotAllowed.Title")}</AlertTitle>
{t("Announcements.NotAllowed.Message")}
</Alert>
</div>
);
};
export default NotAllowed;

View File

@ -1,8 +1,14 @@
import React from "react"; import React from "react";
import MachinesContainer from "../../machines/components/MachinesContainer"; import MachinesContainer from "../../machines/components/MachinesContainer";
import NetworkStateProvider from "../state/NetworkStateProvider"; import NetworkStateProvider from "../state/NetworkStateProvider";
import { usePermissions } from "../../../hooks";
import NotAllowed from "../../../components/common/NotAllowed";
const NetworkContainer = () => { const NetworkContainer = () => {
const { viewMachines } = usePermissions();
if (!viewMachines) return <NotAllowed />;
return ( return (
<NetworkStateProvider> <NetworkStateProvider>
<MachinesContainer /> <MachinesContainer />