2024-06-06 13:58:58: merge [main:94936000280c72ce43ef30f2a36a36333115dd62];
This commit is contained in:
1 parent
e8dfc2e552
commit
031a92db3f
17 files changed
+171
-97
No files matched your search
@@ -1,3 +1,14 @@
|
|||||||
|
## 0.11.5
|
||||||
|
- Обновлена библиотека isp-ui-kit
|
||||||
|
- Убраны лишние столбцы на странице токенов
|
||||||
|
- Исправлено поведение модального окна на странице Группы приложений
|
||||||
|
- Убран лишний скролл
|
||||||
|
- Различные улучшения дизайна страницы Приложений
|
||||||
|
- Убран Ховер в таблицах на экране Модули
|
||||||
|
- Улучшена ui-логика блокировки/разблокировки пользователя
|
||||||
|
- Добавлена обработка ошибок с существующими значения на экране "Пользователи", "Роли"
|
||||||
|
- Исправлена обработки ошибки 401 на экране логина
|
||||||
|
- Исправлено моргание страницы Модулей
|
||||||
## 0.11.4
|
## 0.11.4
|
||||||
- Правки для прода
|
- Правки для прода
|
||||||
## 0.11.3
|
## 0.11.3
|
||||||
|
|||||||
Generated
+10
-10
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"version": "0.11.3",
|
"version": "0.11.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"version": "0.11.3",
|
"version": "0.11.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
||||||
"@codemirror/lang-json": "^6.0.1",
|
"@codemirror/lang-json": "^6.0.1",
|
||||||
@@ -2934,9 +2934,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@lezer/javascript": {
|
"node_modules/@lezer/javascript": {
|
||||||
"version": "1.4.14",
|
"version": "1.4.16",
|
||||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.14.tgz",
|
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.16.tgz",
|
||||||
"integrity": "sha512-GEdUyspTRgc5dwIGebUk+f3BekvqEWVIYsIuAC3pA8e8wcikGwBZRWRa450L0s8noGWuULwnmi4yjxTnYz9PpA==",
|
"integrity": "sha512-84UXR3N7s11MPQHWgMnjb9571fr19MmXnr5zTv2XX0gHXXUvW3uPJ8GCjKrfTXmSdfktjRK0ayKklw+A13rk4g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lezer/common": "^1.2.0",
|
"@lezer/common": "^1.2.0",
|
||||||
"@lezer/highlight": "^1.1.3",
|
"@lezer/highlight": "^1.1.3",
|
||||||
@@ -7844,8 +7844,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/isp-ui-kit": {
|
"node_modules/isp-ui-kit": {
|
||||||
"version": "0.5.5",
|
"version": "0.5.6",
|
||||||
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#e63795caeb38900e8ca4787eaf0ba6ea606d935c",
|
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#894f639391c367af3909c8e5feb5873d25ff9132",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@codemirror/lang-javascript": "^6.2.1",
|
"@codemirror/lang-javascript": "^6.2.1",
|
||||||
@@ -10812,9 +10812,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ua-parser-js": {
|
"node_modules/ua-parser-js": {
|
||||||
"version": "1.0.37",
|
"version": "1.0.38",
|
||||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz",
|
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.38.tgz",
|
||||||
"integrity": "sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==",
|
"integrity": "sha512-Aq5ppTOfvrCMgAPneW1HfWj66Xi7XL+/mIy996R1/CLS/rcyJQm6QZdsKrUeivDFQ+Oc9Wyuwor8Ze8peEoUoQ==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "isp-admin-ui",
|
"name": "isp-admin-ui",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.11.4",
|
"version": "0.11.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|||||||
@@ -36,10 +36,6 @@
|
|||||||
tr {
|
tr {
|
||||||
background: $blue-light;
|
background: $blue-light;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ant-table-cell-row-hover {
|
|
||||||
background: $blue-color-2 !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__buttons {
|
&__buttons {
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
|
|||||||
</CanEdit>}
|
</CanEdit>}
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
|
rowHoverable={false}
|
||||||
className={className}
|
className={className}
|
||||||
rowKey={(record) => record.id}
|
rowKey={(record) => record.id}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { LinkOutlined } from '@ant-design/icons'
|
import { FileProtectOutlined } from '@ant-design/icons'
|
||||||
import { List, message, Spin, Tooltip } from 'antd'
|
import { List, message, Spin, Tooltip } from 'antd'
|
||||||
import { Layout } from 'isp-ui-kit'
|
import { Layout } from 'isp-ui-kit'
|
||||||
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
import { ColumnItem } from 'isp-ui-kit/dist/Layout/Column/column.type'
|
||||||
@@ -120,12 +120,14 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
|||||||
|
|
||||||
createApplicationService(newApplicationApp)
|
createApplicationService(newApplicationApp)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.then(() => message.success('Элемент сохранен'))
|
.then(() => {
|
||||||
.catch(() => message.error('Ошибка добавления элемента')).finally(()=> setShowApplicationsModal({
|
message.success('Элемент сохранен')
|
||||||
...showApplicationsModal,
|
setShowApplicationsModal({
|
||||||
addModal: false
|
...showApplicationsModal,
|
||||||
}))
|
addModal: false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => message.error('Ошибка добавления элемента'))
|
||||||
}
|
}
|
||||||
const handleRemoveApplicationApp = (id: number) =>
|
const handleRemoveApplicationApp = (id: number) =>
|
||||||
removeApplicationsService([id])
|
removeApplicationsService([id])
|
||||||
@@ -139,8 +141,8 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
|||||||
const renderColumnItems = (item: ColumnItem<any>) => {
|
const renderColumnItems = (item: ColumnItem<any>) => {
|
||||||
return (
|
return (
|
||||||
<List.Item>
|
<List.Item>
|
||||||
<Tooltip mouseEnterDelay={1} title={item.name}>
|
<Tooltip mouseEnterDelay={1.3} title={item.name}>
|
||||||
<List.Item.Meta title={item.name} />
|
<List.Item.Meta title={item.name} description={item.description} />
|
||||||
<div
|
<div
|
||||||
className="link-btn"
|
className="link-btn"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -148,7 +150,9 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
|
|||||||
navigate(`/appAccess/${item.id}`)
|
navigate(`/appAccess/${item.id}`)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LinkOutlined />
|
<Tooltip title="Доступы приложений">
|
||||||
|
<FileProtectOutlined />
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</List.Item>
|
</List.Item>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
AppstoreAddOutlined,
|
AppstoreAddOutlined,
|
||||||
LockOutlined,
|
FileProtectOutlined,
|
||||||
ProductOutlined,
|
ProductOutlined,
|
||||||
ProfileOutlined
|
ProfileOutlined
|
||||||
} from '@ant-design/icons'
|
} from '@ant-design/icons'
|
||||||
@@ -81,7 +81,7 @@ const LayoutComponent = () => {
|
|||||||
label: 'Доступы приложений',
|
label: 'Доступы приложений',
|
||||||
key: 'appAccess',
|
key: 'appAccess',
|
||||||
className: hideItem([PermissionKeysType.read]),
|
className: hideItem([PermissionKeysType.read]),
|
||||||
icon: <LockOutlined />
|
icon: <FileProtectOutlined />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Модули',
|
label: 'Модули',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Divider, Table, message } from 'antd'
|
import { Divider, message, Table } from 'antd'
|
||||||
import { ColumnsType } from 'antd/es/table'
|
import { ColumnsType } from 'antd/es/table'
|
||||||
import { FormComponents } from 'isp-ui-kit'
|
import { FormComponents } from 'isp-ui-kit'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
@@ -19,6 +19,7 @@ import { PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
|||||||
|
|
||||||
import './roles-content.scss'
|
import './roles-content.scss'
|
||||||
|
|
||||||
|
|
||||||
const newRole: Partial<RoleType> = {
|
const newRole: Partial<RoleType> = {
|
||||||
externalGroup: '',
|
externalGroup: '',
|
||||||
name: '',
|
name: '',
|
||||||
@@ -46,6 +47,7 @@ const RolesContent = ({
|
|||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
formState: { isDirty },
|
formState: { isDirty },
|
||||||
|
setError,
|
||||||
getValues,
|
getValues,
|
||||||
reset
|
reset
|
||||||
} = useForm<RoleType>({
|
} = useForm<RoleType>({
|
||||||
@@ -79,7 +81,7 @@ const RolesContent = ({
|
|||||||
}
|
}
|
||||||
const formValue = getValues()
|
const formValue = getValues()
|
||||||
formValue.changeMessage = changeMessage
|
formValue.changeMessage = changeMessage
|
||||||
saveRole(formValue)
|
saveRole(formValue, setError)
|
||||||
setOpenModal(false)
|
setOpenModal(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { UseFormSetError } from 'react-hook-form'
|
||||||
|
|
||||||
import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts'
|
import { NewRoleType, PermissionType, RoleType } from '@type/roles.type.ts'
|
||||||
|
|
||||||
export interface RolesContentPropsType {
|
export interface RolesContentPropsType {
|
||||||
@@ -5,5 +7,8 @@ export interface RolesContentPropsType {
|
|||||||
title?: string
|
title?: string
|
||||||
immutable?: boolean
|
immutable?: boolean
|
||||||
permissions: PermissionType[]
|
permissions: PermissionType[]
|
||||||
saveRole: (formValue: RoleType | NewRoleType) => void
|
saveRole: (
|
||||||
|
formValue: RoleType | NewRoleType,
|
||||||
|
setError: UseFormSetError<RoleType | NewRoleType>
|
||||||
|
) => void
|
||||||
}
|
}
|
||||||
@@ -113,11 +113,6 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnsType<ApplicationTokenType> = [
|
const columns: ColumnsType<ApplicationTokenType> = [
|
||||||
{
|
|
||||||
title: 'ID',
|
|
||||||
dataIndex: 'appId',
|
|
||||||
key: 'appId'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Токен',
|
title: 'Токен',
|
||||||
dataIndex: 'token',
|
dataIndex: 'token',
|
||||||
@@ -135,28 +130,24 @@ const TokenContent = ({ id }: TokenPropTypes) => {
|
|||||||
return <div>{formatTime}</div>
|
return <div>{formatTime}</div>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: 'Срок действия',
|
|
||||||
dataIndex: 'expireTime',
|
|
||||||
key: 'expireTime',
|
|
||||||
render: (value) => {
|
|
||||||
const time = dayjs.duration(value).humanize()
|
|
||||||
if (value > 0) {
|
|
||||||
return <div>{time}</div>
|
|
||||||
}
|
|
||||||
return <div>Отсутствует</div>
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: 'Истекает',
|
title: 'Истекает',
|
||||||
dataIndex: 'expireTime',
|
dataIndex: 'expireTime',
|
||||||
key: 'expireTime',
|
key: 'expireTime',
|
||||||
render: (value, record) => {
|
render: (value, record) => {
|
||||||
const formatTime = dayjs(record.createdAt)
|
|
||||||
.add(record.expireTime)
|
|
||||||
.format(dateFormats.fullFormat)
|
|
||||||
|
|
||||||
return value > 0 ? <span>{formatTime}</span> : <span> Никогда </span>
|
if (value === -1) {
|
||||||
|
return <span>Никогда</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
const dateNow = dayjs()
|
||||||
|
const expireTime = dayjs(record.createdAt).add(value)
|
||||||
|
if (expireTime.isBefore(dateNow)) {
|
||||||
|
return <span>Просрочен</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatTime = expireTime.format(dateFormats.fullFormat)
|
||||||
|
return <span>{formatTime}</span>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,13 +10,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__wrap {
|
&__wrap {
|
||||||
padding: $basic-padding*2 $basic-padding*3;
|
padding: $basic-padding*1.25 $basic-padding*3;
|
||||||
min-width: 700px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__header {
|
&__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 19px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.copy-btn {
|
.copy-btn {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
margin:0;
|
margin:0;
|
||||||
padding:0;
|
padding:0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
font-family: PT Sans, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app{
|
.app{
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ const LoginPage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleError = (err: AxiosError<MSPError>): void => {
|
const handleError = (err: AxiosError<MSPError>): void => {
|
||||||
const { response } = err
|
const { response,status } = err
|
||||||
if (response && response.status === 401) {
|
if (response && status === 401) {
|
||||||
setFormError(response.statusText, messages.loginError)
|
setFormError(response.statusText, messages.loginError)
|
||||||
} else {
|
} else {
|
||||||
setFormError('serverError', messages.serverError)
|
setFormError('serverError', messages.serverError)
|
||||||
|
|||||||
@@ -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 { Layout } from 'isp-ui-kit'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
import { UseFormSetError } from 'react-hook-form'
|
||||||
import {
|
import {
|
||||||
createSearchParams,
|
createSearchParams,
|
||||||
useLocation,
|
useLocation,
|
||||||
@@ -24,6 +25,7 @@ import { NewRoleType, PermissionKeysType, RoleType } from '@type/roles.type.ts'
|
|||||||
|
|
||||||
import './roles-page.scss'
|
import './roles-page.scss'
|
||||||
|
|
||||||
|
|
||||||
const { Column, EmptyData, NoData } = Layout
|
const { Column, EmptyData, NoData } = Layout
|
||||||
|
|
||||||
const RolesPage = () => {
|
const RolesPage = () => {
|
||||||
@@ -89,25 +91,44 @@ const RolesPage = () => {
|
|||||||
|
|
||||||
const handeOnAddItem = () => setSelectedItemId('new')
|
const handeOnAddItem = () => setSelectedItemId('new')
|
||||||
|
|
||||||
const handleUpdateRole = (formValue: RoleType | NewRoleType) => {
|
const handleUpdateRole = (
|
||||||
|
formValue: RoleType | NewRoleType,
|
||||||
|
setError: UseFormSetError<RoleType>
|
||||||
|
) => {
|
||||||
updateRole(formValue as RoleType)
|
updateRole(formValue as RoleType)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
message.success('Элемент успешно добавлен').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<NewRoleType>
|
||||||
|
) => {
|
||||||
createRole(formValue)
|
createRole(formValue)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
message.success('Элемент успешно добавлен').then()
|
message.success('Элемент успешно добавлен').then()
|
||||||
setSelectedItemId(res.id.toString())
|
setSelectedItemId(res.id.toString())
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
|
const { status } = error
|
||||||
|
if (status === 409) {
|
||||||
|
setError('name', {
|
||||||
|
message: 'Роль с таким названием уже существует'
|
||||||
|
})
|
||||||
|
}
|
||||||
message.error('Не удалось добавить роль').then()
|
message.error('Не удалось добавить роль').then()
|
||||||
setSelectedItemId('')
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const UserEditor = () => {
|
|||||||
getValues,
|
getValues,
|
||||||
setValue,
|
setValue,
|
||||||
watch,
|
watch,
|
||||||
reset
|
setError
|
||||||
} = useForm<UserType>({
|
} = useForm<UserType>({
|
||||||
defaultValues: isNew
|
defaultValues: isNew
|
||||||
? {
|
? {
|
||||||
@@ -108,7 +108,13 @@ const UserEditor = () => {
|
|||||||
message.success('Пользователь успешно создан')
|
message.success('Пользователь успешно создан')
|
||||||
navigate(routePaths.users)
|
navigate(routePaths.users)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
|
const { status } = error
|
||||||
|
if (status === 409) {
|
||||||
|
setError('email', {
|
||||||
|
message: 'Пользователь с таким Email уже существует'
|
||||||
|
})
|
||||||
|
}
|
||||||
message.error('Произошла ошибка создания пользователя')
|
message.error('Произошла ошибка создания пользователя')
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -118,9 +124,15 @@ const UserEditor = () => {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
message.success('Пользователь успешно изменен')
|
message.success('Пользователь успешно изменен')
|
||||||
reset({}, { keepValues: true })
|
navigate(routePaths.users)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
|
const { status } = error
|
||||||
|
if (status === 409) {
|
||||||
|
setError('email', {
|
||||||
|
message: 'Пользователь с таким Email уже существует'
|
||||||
|
})
|
||||||
|
}
|
||||||
message.error('Произошла ошибка обновления пользователя')
|
message.error('Произошла ошибка обновления пользователя')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -169,7 +181,9 @@ const UserEditor = () => {
|
|||||||
{state.lastSessionCreatedAt && (
|
{state.lastSessionCreatedAt && (
|
||||||
<>
|
<>
|
||||||
Последняя сессия
|
Последняя сессия
|
||||||
{dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)}
|
{dayjs(state.lastSessionCreatedAt).format(
|
||||||
|
dateFormats.fullFormat
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ import {
|
|||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
LockOutlined,
|
LockOutlined,
|
||||||
UnlockOutlined,
|
PlusSquareOutlined,
|
||||||
PlusSquareOutlined
|
UnlockOutlined
|
||||||
} from '@ant-design/icons'
|
} 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 { ColumnsType } from 'antd/es/table'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
|
|
||||||
|
import { dateFormats } from '@constants/date.ts'
|
||||||
|
|
||||||
import CanEdit from '@components/CanEdit'
|
import CanEdit from '@components/CanEdit'
|
||||||
|
|
||||||
import { getUserFullName } from '@utils/userUtils/getFullNameUtil.ts'
|
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 { UserType } from '@type/user.type.ts'
|
||||||
|
|
||||||
import './users-page.scss'
|
import './users-page.scss'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { dateFormats } from '@constants/date.ts'
|
|
||||||
|
|
||||||
const UsersPage = () => {
|
const UsersPage = () => {
|
||||||
const { data: allUsers = [], isLoading: isUsersLoading } =
|
const { data: allUsers = [], isLoading: isUsersLoading } =
|
||||||
@@ -76,6 +78,32 @@ const UsersPage = () => {
|
|||||||
.catch(() => message.error(<>{errorMessage}</>))
|
.catch(() => message.error(<>{errorMessage}</>))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const renderBlockButton = (userData: UserType) => {
|
||||||
|
const { blocked, id } = userData
|
||||||
|
|
||||||
|
const popConfirmTitle = blocked
|
||||||
|
? 'Вы действительно хотите разблокировать этого пользователя?'
|
||||||
|
: 'Вы действительно хотите заблокировать этого пользователя?'
|
||||||
|
|
||||||
|
const tooltipTitle = blocked
|
||||||
|
? 'Разблокировать пользователя'
|
||||||
|
: 'Заблокировать пользователя'
|
||||||
|
|
||||||
|
const icon = blocked ? <UnlockOutlined /> : <LockOutlined />
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popconfirm title={popConfirmTitle} onConfirm={() => handleBlockUser(id)}>
|
||||||
|
<Tooltip key="LockOutlined" title={tooltipTitle}>
|
||||||
|
<Button
|
||||||
|
data-cy={`users-page__content__table__actions__lock-btn ${id}`}
|
||||||
|
className="users-page__content__table__actions__lock-btn"
|
||||||
|
icon={icon}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</Popconfirm>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <Spin />
|
return <Spin />
|
||||||
}
|
}
|
||||||
@@ -100,7 +128,14 @@ const UsersPage = () => {
|
|||||||
{
|
{
|
||||||
title: 'Email',
|
title: 'Email',
|
||||||
dataIndex: 'email',
|
dataIndex: 'email',
|
||||||
key: 'email'
|
key: 'email',
|
||||||
|
render: (value, record) => {
|
||||||
|
if(record.blocked){
|
||||||
|
return <div>{value} <Tag color="red">Заблокирован</Tag></div>
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Роль',
|
title: 'Роль',
|
||||||
@@ -126,37 +161,17 @@ const UsersPage = () => {
|
|||||||
dataIndex: 'lastSessionCreatedAt',
|
dataIndex: 'lastSessionCreatedAt',
|
||||||
key: 'lastSessionCreatedAt',
|
key: 'lastSessionCreatedAt',
|
||||||
render: (value: string) =>
|
render: (value: string) =>
|
||||||
value ? dayjs(value).format(dateFormats.fullFormat) : ''
|
value ? dayjs(value).format(dateFormats.fullFormat) : ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dataIndex: 'actions',
|
dataIndex: 'actions',
|
||||||
key: 'actions',
|
key: 'actions',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const blockTitle = record.blocked
|
|
||||||
? 'Вы действительно хотите разблокировать этого пользователя?'
|
|
||||||
: 'Вы действительно хотите заблокировать этого пользователя?'
|
|
||||||
return (
|
return (
|
||||||
<div className="users-page__content__table__actions">
|
<div className="users-page__content__table__actions">
|
||||||
<CanEdit>
|
<CanEdit>
|
||||||
<Button.Group className="button_group">
|
<Button.Group className="button_group">
|
||||||
<Popconfirm
|
{renderBlockButton(record)}
|
||||||
title={blockTitle}
|
|
||||||
onConfirm={() => handleBlockUser(record.id)}
|
|
||||||
>
|
|
||||||
<Tooltip
|
|
||||||
key="LockOutlined"
|
|
||||||
title="Заблокировать пользователя"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
data-cy={`users-page__content__table__actions__lock-btn ${record.id}`}
|
|
||||||
className="users-page__content__table__actions__lock-btn"
|
|
||||||
danger={record.blocked}
|
|
||||||
icon={
|
|
||||||
record.blocked ? <LockOutlined /> : <UnlockOutlined />
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
</Popconfirm>
|
|
||||||
<Tooltip key="EditOutlined" title="Редактировать пользователя">
|
<Tooltip key="EditOutlined" title="Редактировать пользователя">
|
||||||
<Button
|
<Button
|
||||||
data-cy={`users-page__content__table__actions__edit-btn ${record.id}`}
|
data-cy={`users-page__content__table__actions__edit-btn ${record.id}`}
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import { lazy, Suspense } from 'react'
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom'
|
import { Navigate, Route, Routes } from 'react-router-dom'
|
||||||
|
|
||||||
import LayoutComponent from '@components/Layout'
|
import LayoutComponent from '@components/Layout'
|
||||||
|
// Составная часть основной страницы, поэтому без lazy
|
||||||
|
import Configurations from '@pages/ConfigurationsPage'
|
||||||
|
import Connections from '@pages/ConnectionsPage'
|
||||||
|
|
||||||
import PrivateRoute from '@routes/PrivateRoute'
|
import PrivateRoute from '@routes/PrivateRoute'
|
||||||
import { routePaths } from '@routes/routePaths.ts'
|
import { routePaths } from '@routes/routePaths.ts'
|
||||||
|
|
||||||
|
|
||||||
const { ErrorPage } = Layout
|
const { ErrorPage } = Layout
|
||||||
|
|
||||||
const LoginPage = lazy(() => import('@pages/LoginPage'))
|
const LoginPage = lazy(() => import('@pages/LoginPage'))
|
||||||
@@ -19,9 +23,7 @@ const SessionsPage = lazy(() => import('@pages/SessionsPage'))
|
|||||||
const SecurityLogPage = lazy(() => import('@pages/SecurityLogPage'))
|
const SecurityLogPage = lazy(() => import('@pages/SecurityLogPage'))
|
||||||
const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
|
const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
|
||||||
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
|
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
|
||||||
const Connections = lazy(() => import('src/pages/ConnectionsPage'))
|
|
||||||
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
|
||||||
const Configurations = lazy(() => import('src/pages/ConfigurationsPage'))
|
|
||||||
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
|
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
|
||||||
|
|
||||||
const Routers = () => {
|
const Routers = () => {
|
||||||
@@ -158,7 +160,11 @@ const Routers = () => {
|
|||||||
<Route path=":id">
|
<Route path=":id">
|
||||||
<Route
|
<Route
|
||||||
path={routePaths.configurations}
|
path={routePaths.configurations}
|
||||||
element={<Configurations />}
|
element={
|
||||||
|
<Suspense fallback={<Spin />}>
|
||||||
|
<Configurations />
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Route
|
<Route
|
||||||
path={routePaths.allVersions}
|
path={routePaths.allVersions}
|
||||||
|
|||||||
Reference in new issue
Block a user