From 17bfa710566b2fe43c74548365039a85137d2cfb Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:22:17 +0300 Subject: [PATCH 01/13] MSP-3391 update app font --- src/components/app.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/app.scss b/src/components/app.scss index 8947f80..025b2fd 100644 --- a/src/components/app.scss +++ b/src/components/app.scss @@ -4,6 +4,7 @@ margin:0; padding:0; box-sizing: border-box; + font-family: PT Sans, sans-serif; } .app{ From 2106d295c10c76527e900ef82aac373f1b0ff1da Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:24:06 +0300 Subject: [PATCH 02/13] MSP-3391 change appAccess page menu icon --- src/components/Layout/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 10f0f79..6656cd4 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -1,6 +1,6 @@ import { AppstoreAddOutlined, - LockOutlined, + FileProtectOutlined, ProductOutlined, ProfileOutlined } from '@ant-design/icons' @@ -81,7 +81,7 @@ const LayoutComponent = () => { label: 'Доступы приложений', key: 'appAccess', className: hideItem([PermissionKeysType.read]), - icon: + icon: }, { label: 'Модули', From 7179aa86cf76a7d59e32920167a45924f6b93ee2 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:25:27 +0300 Subject: [PATCH 03/13] MSP-3391 remove id, expireTime column form tokens table --- src/components/TokenContent/index.tsx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index fbfe515..601076a 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -113,11 +113,6 @@ const TokenContent = ({ id }: TokenPropTypes) => { } const columns: ColumnsType = [ - { - title: 'ID', - dataIndex: 'appId', - key: 'appId' - }, { title: 'Токен', dataIndex: 'token', @@ -135,18 +130,6 @@ const TokenContent = ({ id }: TokenPropTypes) => { return
{formatTime}
} }, - { - title: 'Срок действия', - dataIndex: 'expireTime', - key: 'expireTime', - render: (value) => { - const time = dayjs.duration(value).humanize() - if (value > 0) { - return
{time}
- } - return
Отсутствует
- } - }, { title: 'Истекает', dataIndex: 'expireTime', From 5484fe5aa04833dc9f77cd5c1f69d47e65f46cd2 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:25:40 +0300 Subject: [PATCH 04/13] MSP-3391 update expire label logic --- src/components/TokenContent/index.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index 601076a..6461118 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -135,11 +135,19 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'expireTime', key: 'expireTime', render: (value, record) => { - const formatTime = dayjs(record.createdAt) - .add(record.expireTime) - .format(dateFormats.fullFormat) - return value > 0 ? {formatTime} : Никогда + if (value === -1) { + return Никогда + } + + const dateNow = dayjs() + const expireTime = dayjs(record.createdAt).add(value) + if (expireTime.isBefore(dateNow)) { + return Просрочен + } + + const formatTime = expireTime.format(dateFormats.fullFormat) + return {formatTime} } }, { From e96ab883ebe298dd5c6416fcc525caecf08469e7 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:28:30 +0300 Subject: [PATCH 05/13] MSP-3391 fix tokenContent styles --- src/components/TokenContent/tokens.scss | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/TokenContent/tokens.scss b/src/components/TokenContent/tokens.scss index c837b6b..fbf7f3d 100644 --- a/src/components/TokenContent/tokens.scss +++ b/src/components/TokenContent/tokens.scss @@ -10,13 +10,20 @@ } &__wrap { - padding: $basic-padding*2 $basic-padding*3; - min-width: 700px; + padding: $basic-padding*1.25 $basic-padding*3; } &__header { display: flex; justify-content: space-between; + + h3 { + font-size: 19px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + font-weight: 500; + } } .copy-btn { From b88e6e79855c04f15ce257b14801990a8ebc091a Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:29:27 +0300 Subject: [PATCH 06/13] MSP-3391 change appAccess icon to application column item --- src/components/ApplicationsContent/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx index 2c84842..8bea8ec 100644 --- a/src/components/ApplicationsContent/index.tsx +++ b/src/components/ApplicationsContent/index.tsx @@ -139,8 +139,8 @@ const ApplicationsContent: FC = ({ const renderColumnItems = (item: ColumnItem) => { return ( - - + +
{ @@ -148,7 +148,9 @@ const ApplicationsContent: FC = ({ navigate(`/appAccess/${item.id}`) }} > - + + +
From a6c823087cafd28922bbe797658c9718883c6aaf Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:29:45 +0300 Subject: [PATCH 07/13] MSP-3391 remove delay for closing modal --- src/components/ApplicationsContent/index.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx index 8bea8ec..c061d49 100644 --- a/src/components/ApplicationsContent/index.tsx +++ b/src/components/ApplicationsContent/index.tsx @@ -1,4 +1,4 @@ -import { LinkOutlined } from '@ant-design/icons' +import { FileProtectOutlined } from '@ant-design/icons' import { List, message, Spin, Tooltip } from 'antd' import { Layout } from 'isp-ui-kit' import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type' @@ -120,12 +120,14 @@ const ApplicationsContent: FC = ({ createApplicationService(newApplicationApp) .unwrap() - .then(() => message.success('Элемент сохранен')) - .catch(() => message.error('Ошибка добавления элемента')).finally(()=> setShowApplicationsModal({ - ...showApplicationsModal, - addModal: false - })) - + .then(() => { + message.success('Элемент сохранен') + setShowApplicationsModal({ + ...showApplicationsModal, + addModal: false + }) + }) + .catch(() => message.error('Ошибка добавления элемента')) } const handleRemoveApplicationApp = (id: number) => removeApplicationsService([id]) From 6d95da4f2065c0800d1de5a66936ae3a3fc86448 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 13:38:57 +0300 Subject: [PATCH 08/13] MSP-3391 remove hover from configs table --- .../active-configurations-table.scss | 4 ---- src/components/ActiveConfigurationsTable/index.tsx | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/ActiveConfigurationsTable/active-configurations-table.scss b/src/components/ActiveConfigurationsTable/active-configurations-table.scss index abe6085..3c34169 100644 --- a/src/components/ActiveConfigurationsTable/active-configurations-table.scss +++ b/src/components/ActiveConfigurationsTable/active-configurations-table.scss @@ -36,10 +36,6 @@ tr { background: $blue-light; } - - .ant-table-cell-row-hover { - background: $blue-color-2 !important; - } } &__buttons { diff --git a/src/components/ActiveConfigurationsTable/index.tsx b/src/components/ActiveConfigurationsTable/index.tsx index 673abef..0920e17 100644 --- a/src/components/ActiveConfigurationsTable/index.tsx +++ b/src/components/ActiveConfigurationsTable/index.tsx @@ -207,6 +207,7 @@ const ActiveConfigurationsTable: FC = } record.id} pagination={false} From fecc74f6e01b0e7cbb09d2695715ab20095ccab8 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 15:38:41 +0300 Subject: [PATCH 09/13] MSP-3391 add error handler for roles and users --- src/components/RolesContent/index.tsx | 6 ++-- .../RolesContent/roles-content.type.ts | 7 +++- src/pages/RolesPage/index.tsx | 33 +++++++++++++++---- src/pages/UserEditor/index.tsx | 24 +++++++++++--- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/components/RolesContent/index.tsx b/src/components/RolesContent/index.tsx index b181427..dfa5403 100644 --- a/src/components/RolesContent/index.tsx +++ b/src/components/RolesContent/index.tsx @@ -1,4 +1,4 @@ -import { Divider, Table, message } from 'antd' +import { Divider, message, Table } from 'antd' import { ColumnsType } from 'antd/es/table' import { FormComponents } from 'isp-ui-kit' import { useEffect, useState } from 'react' @@ -19,6 +19,7 @@ import { PermissionKeysType, RoleType } from '@type/roles.type.ts' import './roles-content.scss' + const newRole: Partial = { externalGroup: '', name: '', @@ -46,6 +47,7 @@ const RolesContent = ({ const { control, formState: { isDirty }, + setError, getValues, reset } = useForm({ @@ -79,7 +81,7 @@ const RolesContent = ({ } const formValue = getValues() formValue.changeMessage = changeMessage - saveRole(formValue) + saveRole(formValue, setError) setOpenModal(false) } diff --git a/src/components/RolesContent/roles-content.type.ts b/src/components/RolesContent/roles-content.type.ts index 68835d2..8f4780d 100644 --- a/src/components/RolesContent/roles-content.type.ts +++ b/src/components/RolesContent/roles-content.type.ts @@ -1,3 +1,5 @@ +import { UseFormSetError } from 'react-hook-form' + import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts' export interface RolesContentPropsType { @@ -5,5 +7,8 @@ export interface RolesContentPropsType { title?: string immutable?: boolean permissions: PermissionType[] - saveRole: (formValue: RoleType | NewRoleType) => void + saveRole: ( + formValue: RoleType | NewRoleType, + setError: UseFormSetError + ) => void } diff --git a/src/pages/RolesPage/index.tsx b/src/pages/RolesPage/index.tsx index 5493f9c..547cb04 100644 --- a/src/pages/RolesPage/index.tsx +++ b/src/pages/RolesPage/index.tsx @@ -1,6 +1,7 @@ -import { List, Spin, message, Tooltip } from 'antd' +import { List, message, Spin, Tooltip } from 'antd' import { Layout } from 'isp-ui-kit' import { useEffect } from 'react' +import { UseFormSetError } from 'react-hook-form' import { createSearchParams, useLocation, @@ -24,6 +25,7 @@ import { NewRoleType, PermissionKeysType, RoleType } from '@type/roles.type.ts' import './roles-page.scss' + const { Column, EmptyData, NoData } = Layout const RolesPage = () => { @@ -89,25 +91,44 @@ const RolesPage = () => { const handeOnAddItem = () => setSelectedItemId('new') - const handleUpdateRole = (formValue: RoleType | NewRoleType) => { + const handleUpdateRole = ( + formValue: RoleType | NewRoleType, + setError: UseFormSetError + ) => { updateRole(formValue as RoleType) .unwrap() .then(() => { message.success('Элемент успешно добавлен').then() }) - .catch(() => message.error('Не удалось сохранить роль')) + .catch((error) => { + const { status } = error + if (status === 409) { + setError('name', { + message: 'Роль с таким названием уже существует' + }) + } + message.error('Не удалось сохранить роль') + }) } - const handleCreateRole = (formValue: NewRoleType) => { + const handleCreateRole = ( + formValue: NewRoleType, + setError: UseFormSetError + ) => { createRole(formValue) .unwrap() .then((res) => { message.success('Элемент успешно добавлен').then() setSelectedItemId(res.id.toString()) }) - .catch(() => { + .catch((error) => { + const { status } = error + if (status === 409) { + setError('name', { + message: 'Роль с таким названием уже существует' + }) + } message.error('Не удалось добавить роль').then() - setSelectedItemId('') }) } diff --git a/src/pages/UserEditor/index.tsx b/src/pages/UserEditor/index.tsx index 932d959..8e2bab1 100644 --- a/src/pages/UserEditor/index.tsx +++ b/src/pages/UserEditor/index.tsx @@ -52,7 +52,7 @@ const UserEditor = () => { getValues, setValue, watch, - reset + setError } = useForm({ defaultValues: isNew ? { @@ -108,7 +108,13 @@ const UserEditor = () => { message.success('Пользователь успешно создан') navigate(routePaths.users) }) - .catch(() => { + .catch((error) => { + const { status } = error + if (status === 409) { + setError('email', { + message: 'Пользователь с таким Email уже существует' + }) + } message.error('Произошла ошибка создания пользователя') }) } else { @@ -118,9 +124,15 @@ const UserEditor = () => { .unwrap() .then(() => { message.success('Пользователь успешно изменен') - reset({}, { keepValues: true }) + navigate(routePaths.users) }) - .catch(() => { + .catch((error) => { + const { status } = error + if (status === 409) { + setError('email', { + message: 'Пользователь с таким Email уже существует' + }) + } message.error('Произошла ошибка обновления пользователя') }) } @@ -169,7 +181,9 @@ const UserEditor = () => { {state.lastSessionCreatedAt && ( <> Последняя сессия   - {dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)} + {dayjs(state.lastSessionCreatedAt).format( + dateFormats.fullFormat + )} )} From 027058b8bbd7ac3fcff281f984b4205a5b888687 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 4 Jun 2024 15:52:38 +0300 Subject: [PATCH 10/13] MSP-3391 update blocking user ui logic --- src/pages/UsersPage/index.tsx | 71 +++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/src/pages/UsersPage/index.tsx b/src/pages/UsersPage/index.tsx index 2c05acb..ca1e268 100644 --- a/src/pages/UsersPage/index.tsx +++ b/src/pages/UsersPage/index.tsx @@ -2,14 +2,17 @@ import { DeleteOutlined, EditOutlined, LockOutlined, - UnlockOutlined, - PlusSquareOutlined + PlusSquareOutlined, + UnlockOutlined } from '@ant-design/icons' -import { Button, Popconfirm, Spin, Table, message, Tooltip } from 'antd' +import { Button, message, Popconfirm, Spin, Table, Tag, Tooltip } from 'antd' import { ColumnsType } from 'antd/es/table' +import dayjs from 'dayjs' import { useEffect } from 'react' import { useNavigate } from 'react-router-dom' +import { dateFormats } from '@constants/date.ts' + import CanEdit from '@components/CanEdit' import { getUserFullName } from '@utils/userUtils/getFullNameUtil.ts' @@ -25,8 +28,7 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { UserType } from '@type/user.type.ts' import './users-page.scss' -import dayjs from 'dayjs' -import { dateFormats } from '@constants/date.ts' + const UsersPage = () => { const { data: allUsers = [], isLoading: isUsersLoading } = @@ -76,6 +78,32 @@ const UsersPage = () => { .catch(() => message.error(<>{errorMessage})) } + const renderBlockButton = (userData: UserType) => { + const { blocked, id } = userData + + const popConfirmTitle = blocked + ? 'Вы действительно хотите разблокировать этого пользователя?' + : 'Вы действительно хотите заблокировать этого пользователя?' + + const tooltipTitle = blocked + ? 'Разблокировать пользователя' + : 'Заблокировать пользователя' + + const icon = blocked ? : + + return ( + handleBlockUser(id)}> + +