2024-06-06 13:58:58: merge [main:94936000280c72ce43ef30f2a36a36333115dd62];

This commit is contained in:
txix committed 2024-06-06 13:58:58 +03:00
1 parent e8dfc2e552
commit 031a92db3f
17 files changed
+171 -97

No files matched your search

+11
View File
@@ -1,3 +1,14 @@
## 0.11.5
- Обновлена библиотека isp-ui-kit
- Убраны лишние столбцы на странице токенов
- Исправлено поведение модального окна на странице Группы приложений
- Убран лишний скролл
- Различные улучшения дизайна страницы Приложений
- Убран Ховер в таблицах на экране Модули
- Улучшена ui-логика блокировки/разблокировки пользователя
- Добавлена обработка ошибок с существующими значения на экране "Пользователи", "Роли"
- Исправлена обработки ошибки 401 на экране логина
- Исправлено моргание страницы Модулей
## 0.11.4
- Правки для прода
## 0.11.3
+10 -10
View File
@@ -1,12 +1,12 @@
{
"name": "isp-admin-ui",
"version": "0.11.3",
"version": "0.11.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "isp-admin-ui",
"version": "0.11.3",
"version": "0.11.5",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.6",
"@codemirror/lang-json": "^6.0.1",
@@ -2934,9 +2934,9 @@
}
},
"node_modules/@lezer/javascript": {
"version": "1.4.14",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.14.tgz",
"integrity": "sha512-GEdUyspTRgc5dwIGebUk+f3BekvqEWVIYsIuAC3pA8e8wcikGwBZRWRa450L0s8noGWuULwnmi4yjxTnYz9PpA==",
"version": "1.4.16",
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.4.16.tgz",
"integrity": "sha512-84UXR3N7s11MPQHWgMnjb9571fr19MmXnr5zTv2XX0gHXXUvW3uPJ8GCjKrfTXmSdfktjRK0ayKklw+A13rk4g==",
"dependencies": {
"@lezer/common": "^1.2.0",
"@lezer/highlight": "^1.1.3",
@@ -7844,8 +7844,8 @@
}
},
"node_modules/isp-ui-kit": {
"version": "0.5.5",
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#e63795caeb38900e8ca4787eaf0ba6ea606d935c",
"version": "0.5.6",
"resolved": "git+ssh://git@github.com/txix-open/isp-ui-kit.git#894f639391c367af3909c8e5feb5873d25ff9132",
"license": "ISC",
"dependencies": {
"@codemirror/lang-javascript": "^6.2.1",
@@ -10812,9 +10812,9 @@
}
},
"node_modules/ua-parser-js": {
"version": "1.0.37",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz",
"integrity": "sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==",
"version": "1.0.38",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.38.tgz",
"integrity": "sha512-Aq5ppTOfvrCMgAPneW1HfWj66Xi7XL+/mIy996R1/CLS/rcyJQm6QZdsKrUeivDFQ+Oc9Wyuwor8Ze8peEoUoQ==",
"funding": [
{
"type": "opencollective",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "isp-admin-ui",
"private": true,
"version": "0.11.4",
"version": "0.11.5",
"type": "module",
"scripts": {
"start": "vite",
@@ -36,10 +36,6 @@
tr {
background: $blue-light;
}
.ant-table-cell-row-hover {
background: $blue-color-2 !important;
}
}
&__buttons {
@@ -207,6 +207,7 @@ const ActiveConfigurationsTable: FC<ActiveConfigurationsTablePropsType> =
</CanEdit>}
</div>
<Table
rowHoverable={false}
className={className}
rowKey={(record) => record.id}
pagination={false}
+14 -10
View File
@@ -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<ApplicationsContentPropTypes> = ({
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])
@@ -139,8 +141,8 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
const renderColumnItems = (item: ColumnItem<any>) => {
return (
<List.Item>
<Tooltip mouseEnterDelay={1} title={item.name}>
<List.Item.Meta title={item.name} />
<Tooltip mouseEnterDelay={1.3} title={item.name}>
<List.Item.Meta title={item.name} description={item.description} />
<div
className="link-btn"
onClick={(e) => {
@@ -148,7 +150,9 @@ const ApplicationsContent: FC<ApplicationsContentPropTypes> = ({
navigate(`/appAccess/${item.id}`)
}}
>
<LinkOutlined />
<Tooltip title="Доступы приложений">
<FileProtectOutlined />
</Tooltip>
</div>
</Tooltip>
</List.Item>
+2 -2
View File
@@ -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: <LockOutlined />
icon: <FileProtectOutlined />
},
{
label: 'Модули',
+4 -2
View File
@@ -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<RoleType> = {
externalGroup: '',
name: '',
@@ -46,6 +47,7 @@ const RolesContent = ({
const {
control,
formState: { isDirty },
setError,
getValues,
reset
} = useForm<RoleType>({
@@ -79,7 +81,7 @@ const RolesContent = ({
}
const formValue = getValues()
formValue.changeMessage = changeMessage
saveRole(formValue)
saveRole(formValue, setError)
setOpenModal(false)
}
@@ -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<RoleType | NewRoleType>
) => void
}
+12 -21
View File
@@ -113,11 +113,6 @@ const TokenContent = ({ id }: TokenPropTypes) => {
}
const columns: ColumnsType<ApplicationTokenType> = [
{
title: 'ID',
dataIndex: 'appId',
key: 'appId'
},
{
title: 'Токен',
dataIndex: 'token',
@@ -135,28 +130,24 @@ const TokenContent = ({ id }: TokenPropTypes) => {
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: 'Истекает',
dataIndex: 'expireTime',
key: 'expireTime',
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>
}
},
{
+9 -2
View File
@@ -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 {
+1
View File
@@ -4,6 +4,7 @@
margin:0;
padding:0;
box-sizing: border-box;
font-family: PT Sans, sans-serif;
}
.app{
+2 -2
View File
@@ -38,8 +38,8 @@ const LoginPage = () => {
}
const handleError = (err: AxiosError<MSPError>): void => {
const { response } = err
if (response && response.status === 401) {
const { response,status } = err
if (response && status === 401) {
setFormError(response.statusText, messages.loginError)
} else {
setFormError('serverError', messages.serverError)
+27 -6
View File
@@ -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<RoleType>
) => {
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<NewRoleType>
) => {
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('')
})
}
+19 -5
View File
@@ -52,7 +52,7 @@ const UserEditor = () => {
getValues,
setValue,
watch,
reset
setError
} = useForm<UserType>({
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 && (
<>
Последняя сессия &nbsp;
{dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)}
{dayjs(state.lastSessionCreatedAt).format(
dateFormats.fullFormat
)}
</>
)}
</span>
+43 -28
View File
@@ -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 ? <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) {
return <Spin />
}
@@ -100,7 +128,14 @@ const UsersPage = () => {
{
title: 'Email',
dataIndex: 'email',
key: 'email'
key: 'email',
render: (value, record) => {
if(record.blocked){
return <div>{value} <Tag color="red">Заблокирован</Tag></div>
}
return value
}
},
{
title: 'Роль',
@@ -126,37 +161,17 @@ const UsersPage = () => {
dataIndex: 'lastSessionCreatedAt',
key: 'lastSessionCreatedAt',
render: (value: string) =>
value ? dayjs(value).format(dateFormats.fullFormat) : ''
value ? dayjs(value).format(dateFormats.fullFormat) : ''
},
{
dataIndex: 'actions',
key: 'actions',
render: (_, record) => {
const blockTitle = record.blocked
? 'Вы действительно хотите разблокировать этого пользователя?'
: 'Вы действительно хотите заблокировать этого пользователя?'
return (
<div className="users-page__content__table__actions">
<CanEdit>
<Button.Group className="button_group">
<Popconfirm
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>
{renderBlockButton(record)}
<Tooltip key="EditOutlined" title="Редактировать пользователя">
<Button
data-cy={`users-page__content__table__actions__edit-btn ${record.id}`}
+9 -3
View File
@@ -4,10 +4,14 @@ import { lazy, Suspense } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom'
import LayoutComponent from '@components/Layout'
// Составная часть основной страницы, поэтому без lazy
import Configurations from '@pages/ConfigurationsPage'
import Connections from '@pages/ConnectionsPage'
import PrivateRoute from '@routes/PrivateRoute'
import { routePaths } from '@routes/routePaths.ts'
const { ErrorPage } = Layout
const LoginPage = lazy(() => import('@pages/LoginPage'))
@@ -19,9 +23,7 @@ const SessionsPage = lazy(() => import('@pages/SessionsPage'))
const SecurityLogPage = lazy(() => import('@pages/SecurityLogPage'))
const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
const ModulesPage = lazy(() => import('@pages/ModulesPage'))
const Connections = lazy(() => import('src/pages/ConnectionsPage'))
const ApplicationsPage = lazy(() => import('@pages/ApplicationsPage'))
const Configurations = lazy(() => import('src/pages/ConfigurationsPage'))
const AllVersionsPage = lazy(() => import('@pages/AllVersionsPage'))
const Routers = () => {
@@ -158,7 +160,11 @@ const Routers = () => {
<Route path=":id">
<Route
path={routePaths.configurations}
element={<Configurations />}
element={
<Suspense fallback={<Spin />}>
<Configurations />
</Suspense>
}
>
<Route
path={routePaths.allVersions}