From 0851d56c73f16139644766d8e612a968bff03144 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 7 May 2023 00:24:05 +0300 Subject: [PATCH] added reset cache button --- public/locales/en/translations.json | 5 +++ public/locales/ro/translations.json | 5 +++ src/components/common/PaperTitle.js | 27 ++++++++++++++++ src/components/common/index.js | 3 +- src/features/settings/SettingsContainer.js | 10 +++++- .../settings/system/ResetCacheComponent.js | 31 +++++++++++++++++++ .../settings/system/SystemContainer.js | 8 +++++ src/providers/UserPermissionsProvider.js | 8 +++-- src/utils/api.js | 1 + 9 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 src/components/common/PaperTitle.js create mode 100644 src/features/settings/system/ResetCacheComponent.js create mode 100644 src/features/settings/system/SystemContainer.js diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 339658b..d126e16 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -92,8 +92,13 @@ }, "Settings": { "Navigation": { + "System": "System", "Appearance": "Appearance", "Notifications": "Notifications" + }, + "Cache": { + "Title": "Cache settings", + "Reset": "Reset" } }, "About": { diff --git a/public/locales/ro/translations.json b/public/locales/ro/translations.json index a639495..a77107e 100644 --- a/public/locales/ro/translations.json +++ b/public/locales/ro/translations.json @@ -83,8 +83,13 @@ }, "Settings": { "Navigation": { + "System": "Sistem", "Appearance": "Aspect", "Notifications": "Notificări" + }, + "Cache": { + "Title": "Setări cache", + "Reset": "Resetați" } }, "About": { diff --git a/src/components/common/PaperTitle.js b/src/components/common/PaperTitle.js new file mode 100644 index 0000000..8f0313d --- /dev/null +++ b/src/components/common/PaperTitle.js @@ -0,0 +1,27 @@ +import React from "react"; +import PropTypes from "prop-types"; +import { Typography } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; + +const useStyles = makeStyles(theme => ({ + paper: { + margin: theme.spacing(1) + } +})); + +const PaperTitle = ({ text }) => { + const classes = useStyles(); + return ( +
+ + {text} + +
+ ); +}; + +PaperTitle.propTypes = { + text: PropTypes.string.isRequired +}; + +export default PaperTitle; diff --git a/src/components/common/index.js b/src/components/common/index.js index 4db22d3..bef3023 100644 --- a/src/components/common/index.js +++ b/src/components/common/index.js @@ -1,3 +1,4 @@ import DataLabel from "./DataLabel"; +import PaperTitle from "./PaperTitle"; -export { DataLabel }; +export { DataLabel, PaperTitle }; diff --git a/src/features/settings/SettingsContainer.js b/src/features/settings/SettingsContainer.js index 8e1ace8..153533b 100644 --- a/src/features/settings/SettingsContainer.js +++ b/src/features/settings/SettingsContainer.js @@ -1,18 +1,25 @@ import React, { useState, useMemo } from "react"; +import BubbleChartIcon from "@material-ui/icons/BubbleChart"; import BrushIcon from "@material-ui/icons/Brush"; import NotificationsIcon from "@material-ui/icons/Notifications"; import { useTranslation } from "react-i18next"; import PageTitle from "../../components/common/PageTitle"; import NavigationButtons from "../../components/common/NavigationButtons"; +import SystemContainer from "./system/SystemContainer"; import AppearanceContainer from "./appearance/AppearanceContainer"; import NotificationsContainer from "./notifications/NotificationsContainer"; const NavigationTabs = { + SYSTEM: "Settings.Navigation.System", APPEARANCE: "Settings.Navigation.Appearance", NOTIFICATIONS: "Settings.Navigation.Notifications" }; const tabs = [ + { + code: NavigationTabs.SYSTEM, + icon: BubbleChartIcon + }, { code: NavigationTabs.APPEARANCE, icon: BrushIcon @@ -24,7 +31,7 @@ const tabs = [ ]; const SettingsContainer = () => { - const [tab, setTab] = useState(NavigationTabs.APPEARANCE); + const [tab, setTab] = useState(NavigationTabs.SYSTEM); const { t } = useTranslation(); const navigationTabs = useMemo( @@ -40,6 +47,7 @@ const SettingsContainer = () => { } /> + {tab === NavigationTabs.SYSTEM && } {tab === NavigationTabs.APPEARANCE && } {tab === NavigationTabs.NOTIFICATIONS && } diff --git a/src/features/settings/system/ResetCacheComponent.js b/src/features/settings/system/ResetCacheComponent.js new file mode 100644 index 0000000..7f68eb5 --- /dev/null +++ b/src/features/settings/system/ResetCacheComponent.js @@ -0,0 +1,31 @@ +import React from "react"; +import { Paper, Button } from "@material-ui/core"; +import { makeStyles } from "@material-ui/core/styles"; +import { useTranslation } from "react-i18next"; +import { PaperTitle } from "../../../components/common"; + +const useStyles = makeStyles(theme => ({ + content: { + "& > *": { + margin: theme.spacing(1) + } + } +})); + +const ResetCacheComponent = () => { + const classes = useStyles(); + const { t } = useTranslation(); + + return ( + + +
+ +
+
+ ); +}; + +export default ResetCacheComponent; diff --git a/src/features/settings/system/SystemContainer.js b/src/features/settings/system/SystemContainer.js new file mode 100644 index 0000000..cd23fec --- /dev/null +++ b/src/features/settings/system/SystemContainer.js @@ -0,0 +1,8 @@ +import React from "react"; +import ResetCacheComponent from "./ResetCacheComponent"; + +const SystemContainer = () => { + return ; +}; + +export default SystemContainer; diff --git a/src/providers/UserPermissionsProvider.js b/src/providers/UserPermissionsProvider.js index 92dfe45..9d26a09 100644 --- a/src/providers/UserPermissionsProvider.js +++ b/src/providers/UserPermissionsProvider.js @@ -9,7 +9,8 @@ const permissionCodes = { VIEW_MACHINES: "VIEW_MACHINES", MANAGE_MACHINES: "MANAGE_MACHINES", OPERATE_MACHINES: "OPERATE_MACHINES", - GUEST_ACCESS: "GUEST_ACCESS" + GUEST_ACCESS: "GUEST_ACCESS", + SYSTEM_ADMINISTRATION: "SYSTEM_ADMINISTRATION" }; const initialState = { @@ -32,6 +33,8 @@ const getPermissionFlags = permissions => { permissions.includes(permissionCodes.OPERATE_MACHINES) ?? false; const guestAccess = permissions.includes(permissionCodes.GUEST_ACCESS) ?? false; + const sysAdmin = + permissions.includes(permissionCodes.SYSTEM_ADMINISTRATION) ?? false; const flags = { viewDashboard, @@ -40,7 +43,8 @@ const getPermissionFlags = permissions => { viewMachines, manageMachines, operateMachines, - guestAccess + guestAccess, + sysAdmin }; const isGuest = guestAccess === true; diff --git a/src/utils/api.js b/src/utils/api.js index 140db74..529c70c 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -11,6 +11,7 @@ const routes = { permissions: `${securityRoute}/permissions`, systemVersion: `${systemRoute}/version`, releaseNotes: `${systemRoute}/release-notes`, + resetCache: `${systemRoute}/reset-cache`, machines: `${networkRoute}/machines`, wakeMachine: `${powerActionsRoute}/wake`, pingMachine: `${powerActionsRoute}/ping`,