diff --git a/private/Notes.txt b/private/Notes.txt index fef1e3e..d470bf8 100644 --- a/private/Notes.txt +++ b/private/Notes.txt @@ -9,4 +9,6 @@ Add in settings: - reset cache - ping interval - notifications -- test notification mechanism \ No newline at end of file +- test notification mechanism +- permissions +- permissions hierarchy \ No newline at end of file diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 1d75782..339658b 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -36,6 +36,12 @@ "Label": "Login", "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": { "Announcements": { "Guest": { diff --git a/public/locales/ro/translations.json b/public/locales/ro/translations.json index 1825983..a639495 100644 --- a/public/locales/ro/translations.json +++ b/public/locales/ro/translations.json @@ -27,6 +27,12 @@ "Label": "Autentificare", "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": { "Announcements": { "Guest": { diff --git a/src/components/common/NotAllowed.js b/src/components/common/NotAllowed.js new file mode 100644 index 0000000..363c420 --- /dev/null +++ b/src/components/common/NotAllowed.js @@ -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 ( +
+ + {t("Announcements.NotAllowed.Title")} + {t("Announcements.NotAllowed.Message")} + +
+ ); +}; + +export default NotAllowed; diff --git a/src/features/network/components/NetworkContainer.js b/src/features/network/components/NetworkContainer.js index 38d03ee..5c32a8a 100644 --- a/src/features/network/components/NetworkContainer.js +++ b/src/features/network/components/NetworkContainer.js @@ -1,8 +1,14 @@ import React from "react"; import MachinesContainer from "../../machines/components/MachinesContainer"; import NetworkStateProvider from "../state/NetworkStateProvider"; +import { usePermissions } from "../../../hooks"; +import NotAllowed from "../../../components/common/NotAllowed"; const NetworkContainer = () => { + const { viewMachines } = usePermissions(); + + if (!viewMachines) return ; + return (