From 6163c28cdc72bd0ba4f3284fa49f960525d92353 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:42:03 +0700 Subject: [PATCH 1/6] MSP-3542 update PermissionKeysType --- src/type/roles.type.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/type/roles.type.ts b/src/type/roles.type.ts index 800d310..71634f1 100644 --- a/src/type/roles.type.ts +++ b/src/type/roles.type.ts @@ -1,6 +1,18 @@ export enum PermissionKeysType { read = 'read', // Просмотр страниц - write = 'write' // Редактирование страниц + write = 'write', // Редактирование страниц + user_view = 'user_view', // Просмотр списка пользователей + user_block = 'user_block', // Блокировка пользователя + user_create = 'user_create', // Создать пользователя + user_update = 'user_update', // Обновить пользователя + user_delete = 'user_delete', // Удаление пользователя + session_view = 'session_view', // Просмотр списка пользовательских сессий + session_revoke = 'session_revoke', // Отзыв сессии + role_view = 'role_view', // Просмотр экрана ролей + role_add = 'role_add', // Создание роли + role_update = 'role_update', // Обновление роли + role_delete = 'role_delete', // Удаление роли + security_log_view = 'security_log_view', // Просмотр журналов ИБ } export interface RoleType { From 5a5665e4872771c077a8c5d837ed0b5f232bafc8 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:44:11 +0700 Subject: [PATCH 2/6] MSP-3542 update permissions in Menu in Layout --- src/components/Layout/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index c856efa..f5ccc8c 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -95,28 +95,32 @@ const LayoutComponent = () => { { label: 'Пользователи и роли', key: 'sessionManagement', - className: hideItem([PermissionKeysType.read]), + className: hideItem([ + PermissionKeysType.user_view, + PermissionKeysType.session_view, + PermissionKeysType.role_view, + ]), icon: , children: [ { label: 'Пользователи', key: 'users', - className: hideItem(PermissionKeysType.read) + className: hideItem(PermissionKeysType.user_view), }, { label: 'Пользовательские сессии', key: 'sessions', - className: hideItem(PermissionKeysType.read) + className: hideItem(PermissionKeysType.session_view), }, { label: 'Просмотр журналов ИБ', key: 'securityLog', - className: hideItem(PermissionKeysType.read) + className: hideItem(PermissionKeysType.security_log_view), }, { label: 'Роли', key: 'roles', - className: hideItem(PermissionKeysType.read) + className: hideItem(PermissionKeysType.role_view), } ] } From 3b129d4c522ff09b6c33a4ae013e39a9bcdb0a37 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:45:30 +0700 Subject: [PATCH 3/6] MSP-3542 update permissions in UsersPage --- src/pages/UsersPage/index.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/UsersPage/index.tsx b/src/pages/UsersPage/index.tsx index ca1e268..71558a5 100644 --- a/src/pages/UsersPage/index.tsx +++ b/src/pages/UsersPage/index.tsx @@ -13,8 +13,6 @@ import { useNavigate } from 'react-router-dom' import { dateFormats } from '@constants/date.ts' -import CanEdit from '@components/CanEdit' - import { getUserFullName } from '@utils/userUtils/getFullNameUtil.ts' import useRole from '@hooks/useRole.tsx' @@ -42,8 +40,11 @@ const UsersPage = () => { const isLoading = isRolesLoading || isUsersLoading - const isPageAvailable = hasPermission(PermissionKeysType.read) - const hasCreateUserPermission = hasPermission(PermissionKeysType.write) + const isPageAvailable = hasPermission(PermissionKeysType.user_view) + const hasBlockUserPermission = hasPermission(PermissionKeysType.user_block) + const hasDeleteUserPermission = hasPermission(PermissionKeysType.user_delete) + const hasUpdateUserPermission = hasPermission(PermissionKeysType.user_update) + const hasCreateUserPermission = hasPermission(PermissionKeysType.user_create) useEffect(() => { if (!isPageAvailable) { @@ -169,9 +170,9 @@ const UsersPage = () => { render: (_, record) => { return (
- - {renderBlockButton(record)} + {hasBlockUserPermission && renderBlockButton(record)} + {hasUpdateUserPermission && (
) } From f27e0ff5a9d17187bd7b7e0d4e602abbb3d68588 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:46:02 +0700 Subject: [PATCH 4/6] MSP-3542 update permissions in SessionsPage and SecurityLogPage --- src/pages/SecurityLogPage/index.tsx | 2 +- src/pages/SessionsPage/index.tsx | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/SecurityLogPage/index.tsx b/src/pages/SecurityLogPage/index.tsx index f48f057..dc994d6 100644 --- a/src/pages/SecurityLogPage/index.tsx +++ b/src/pages/SecurityLogPage/index.tsx @@ -33,7 +33,7 @@ const SecurityLogPage = () => { const [currentPage, setCurrentPage] = useState(1) const isLoading = isUsersLoading || isLoadingLogs - const isPageAvailable = hasPermission(PermissionKeysType.read) + const isPageAvailable = hasPermission(PermissionKeysType.security_log_view) useEffect(() => { getAllLogs({ limit, offset: 0 }) diff --git a/src/pages/SessionsPage/index.tsx b/src/pages/SessionsPage/index.tsx index 74d9661..c967375 100644 --- a/src/pages/SessionsPage/index.tsx +++ b/src/pages/SessionsPage/index.tsx @@ -14,8 +14,6 @@ import { useNavigate } from 'react-router-dom' import { SessionStatusKeysType, sessionStatuses } from '@constants/statuses' -import CanEdit from '@components/CanEdit' - import { getUserFullName } from '@utils/userUtils/getFullNameUtil' import useRole from '@hooks/useRole' @@ -47,7 +45,8 @@ const SessionsPage = () => { const isLoading = isUsersLoading || isLoadingSession - const isPageAvailable = hasPermission(PermissionKeysType.read) + const isPageAvailable = hasPermission(PermissionKeysType.session_view) + const hasRevokePermission = hasPermission(PermissionKeysType.session_revoke) useEffect(() => { if (!isPageAvailable) { @@ -124,7 +123,7 @@ const SessionsPage = () => { } return ( <> - + {hasRevokePermission && ( handleRevokeSessions(record.id)} @@ -136,7 +135,7 @@ const SessionsPage = () => { /> - + )} ) } From 82cd6a5286b30ff9afd4503dc1dca67bcaac49f7 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:47:15 +0700 Subject: [PATCH 5/6] MSP-3542 update permissions in RolesPage and RolesContent --- src/components/RolesContent/index.tsx | 7 ++----- src/pages/RolesPage/index.tsx | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/RolesContent/index.tsx b/src/components/RolesContent/index.tsx index dfa5403..7c5824d 100644 --- a/src/components/RolesContent/index.tsx +++ b/src/components/RolesContent/index.tsx @@ -58,14 +58,12 @@ const RolesContent = ({ const { id: selectedItemId } = useParams() const [openModal, setOpenModal] = useState(false) - const isUpdateRole = hasPermission(PermissionKeysType.write) - const isCreateRole = hasPermission(PermissionKeysType.write) + const isUpdateRole = hasPermission(PermissionKeysType.role_update) + const isCreateRole = hasPermission(PermissionKeysType.role_add) const isSaveBtnAvailable = selectedItemId === 'new' ? isCreateRole : isUpdateRole - const isExternalGroup = hasPermission(PermissionKeysType.write) - useEffect(() => { if (!role) { reset(newRole) @@ -152,7 +150,6 @@ const RolesContent = ({ /> { const [updateRole] = roleApi.useUpdateRoleMutation() const [removeRole] = roleApi.useRemoveRoleMutation() - const isPageAvailable = hasPermission(PermissionKeysType.read) - const isAddRolePermissions = hasPermission(PermissionKeysType.write) - const isRemoveRolePermissions = hasPermission(PermissionKeysType.write) + const isPageAvailable = hasPermission(PermissionKeysType.role_view) + const isAddRolePermissions = hasPermission(PermissionKeysType.role_add) + const isRemoveRolePermissions = hasPermission(PermissionKeysType.role_delete) const isLoading = isPermissionLoading || isRolesLoading const isNew = selectedItemId === 'new' From ab551dc694b3ffbd4b8829ff681fb8c25b0c7ca6 Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Tue, 2 Jul 2024 09:56:43 +0700 Subject: [PATCH 6/6] MSP-3542 up version to 0.13.2 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c6825e..cce9f93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.13.2 +- Обновление пермишенов ## 0.13.1 - В LoginPage исправлен background для темной темы ## 0.13.0 diff --git a/package.json b/package.json index 38eefeb..6b8feef 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "isp-admin-ui", "private": true, - "version": "0.13.1", + "version": "0.13.2", "type": "module", "scripts": { "start": "vite",