From ec472217acc89cad892315107a8b2b492f96139b Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 13 Sep 2023 21:18:01 +0200 Subject: [PATCH] added permission check --- src/Components/AppRoutes/index.js | 4 +++- src/Components/SideMenu/index.js | 8 ++++++-- src/Pages/AdminArea/Manage/index.js | 22 +++++++++++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index d055d1a..c2344b7 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -223,7 +223,9 @@ export default function AppRoutes() { Constants.PERMISSIONS.ADMIN_AREA.MANAGE .CHECK_WHICH_CATEGORIES_ARE_AVAILABLE, Constants.PERMISSIONS.ADMIN_AREA.MANAGE - .ADD_LOG_MANAGER_SERVER_CONNECTION + .ADD_LOG_MANAGER_SERVER_CONNECTION, + Constants.PERMISSIONS.ADMIN_AREA.MANAGE + .REMOVE_LOG_MANAGER_SERVER_CONNECTION ) && ( { - return [ + let columns = [ { title: t("adminArea.manage.logManagers.column.displayName"), dataIndex: "displayName", @@ -76,7 +76,16 @@ function LogManagerServersTable({ t, webSocketContext, appContext }) { dataIndex: "createdAt", key: "createdAt", }, - { + ]; + + if ( + hasPermission( + appContext.userPermissions, + Constants.PERMISSIONS.ADMIN_AREA.MANAGE + .REMOVE_LOG_MANAGER_SERVER_CONNECTION + ) + ) { + columns.push({ title: t("adminArea.manage.logManagers.column.action"), dataIndex: "action", key: "action", @@ -101,8 +110,10 @@ function LogManagerServersTable({ t, webSocketContext, appContext }) { ), - }, - ]; + }); + } + + return columns; }; const getTableItems = () => { @@ -146,7 +157,8 @@ function LogManagerServersTable({ t, webSocketContext, appContext }) { {hasPermission( appContext.userPermissions, - Constants.PERMISSIONS.ALL_USERS.CREATE_NEW_USER + Constants.PERMISSIONS.ADMIN_AREA.MANAGE + .ADD_LOG_MANAGER_SERVER_CONNECTION ) && (