From 17bda1a495f10fcd1d2fbc74659b2185ad65f53f Mon Sep 17 00:00:00 2001 From: veselovnk Date: Mon, 13 May 2024 19:40:24 +0300 Subject: [PATCH 01/19] MSP-3289 update profile layout --- src/pages/ProfilePage/index.tsx | 26 ++++++++++++++----------- src/pages/ProfilePage/profile-page.scss | 5 ++++- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/pages/ProfilePage/index.tsx b/src/pages/ProfilePage/index.tsx index 0ae9f02..aee9f2b 100644 --- a/src/pages/ProfilePage/index.tsx +++ b/src/pages/ProfilePage/index.tsx @@ -1,4 +1,4 @@ -import { Button, Descriptions } from 'antd' +import { Button, Descriptions, Popconfirm } from 'antd' import { useState } from 'react' import PermissionList from '@widgets/PermissionList' @@ -18,7 +18,7 @@ const ProfilePage = () => { const { logoutUser, isLoading } = useLogout() return ( -
+
setIsModalOpen(false)} open={isModalOpen} @@ -34,18 +34,22 @@ const ProfilePage = () => {
- + +
) } From f9559055beeb8c7f8e99239db8819e7e65569839 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 14 May 2024 12:58:05 +0300 Subject: [PATCH 11/19] MSP-3289 remove legacy plugin from vite --- vite.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 66a322f..6e5a124 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -44,6 +44,6 @@ export default defineConfig(({ mode }) => { '/api': env.PROXY_URL } }, - plugins: [react(), svgr(), legacy(), tsconfigPaths()] + plugins: [react(), svgr(), tsconfigPaths()] } }) From b9f6de696824950966e7e925e13ef8aac50140e7 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 14 May 2024 13:04:07 +0300 Subject: [PATCH 12/19] MSP-3289 update date format in project --- src/components/ActiveConfigurationsTable/index.tsx | 3 ++- src/components/CompareVersionModal/index.tsx | 3 ++- src/components/TokenContent/index.tsx | 7 +++---- src/constants/date.ts | 6 ++++++ src/pages/AllVersionsPage/index.tsx | 3 ++- src/pages/ConnectionsPage/index.tsx | 3 ++- src/pages/SecurityLogPage/index.tsx | 5 +++-- src/pages/SessionsPage/index.tsx | 8 ++++---- src/pages/UserEditor/index.tsx | 7 ++++--- src/pages/UsersPage/index.tsx | 4 +++- 10 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 src/constants/date.ts diff --git a/src/components/ActiveConfigurationsTable/index.tsx b/src/components/ActiveConfigurationsTable/index.tsx index 906cdf5..40e260f 100644 --- a/src/components/ActiveConfigurationsTable/index.tsx +++ b/src/components/ActiveConfigurationsTable/index.tsx @@ -16,6 +16,7 @@ import { ColumnsType } from 'antd/es/table' import './active-configurations-table.scss' import dayjs from 'dayjs' import CanEdit from '@components/CanEdit' +import { dateFormats } from '@constants/date.ts' const ActiveConfigurationsTable: FC = @@ -167,7 +168,7 @@ const ActiveConfigurationsTable: FC = key: 'updatedAt', align: 'center', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/components/CompareVersionModal/index.tsx b/src/components/CompareVersionModal/index.tsx index 177f6cb..e11dddb 100644 --- a/src/components/CompareVersionModal/index.tsx +++ b/src/components/CompareVersionModal/index.tsx @@ -19,6 +19,7 @@ import { VersionType } from '@type/version.type' import './compare-version-modal.scss' import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const Original = CodeMirrorMerge.Original @@ -52,7 +53,7 @@ const CompareVersionModal: FC = ({ title: 'Создано', dataIndex: 'createdAt', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index 498ef45..dbb2f7f 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -24,6 +24,7 @@ import tokensApi from '@services/tokensService.ts' import './tokens.scss' import CanEdit from '@components/CanEdit' +import { dateFormats } from '@constants/date.ts' const { FormSelect } = FormComponents const { EmptyData } = Layout @@ -120,8 +121,7 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'createdAt', key: 'createdAt', render: (record) => { - const FULL_DATE_FORMAT = 'DD-MM-YYYY/HH:mm' - const formatTime = dayjs(record.createdAt).format(FULL_DATE_FORMAT) + const formatTime = dayjs(record.createdAt).format(dateFormats.fullFormat) return
{formatTime}
} }, @@ -142,10 +142,9 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'expireTime', key: 'expireTime', render: (value, record) => { - const FULL_DATE_FORMAT = 'DD-MM-YYYY, HH:mm' const formatTime = dayjs(record.createdAt) .add(record.expireTime) - .format(FULL_DATE_FORMAT) + .format(dateFormats.fullFormat) return value > 0 ? {formatTime} : Никогда } diff --git a/src/constants/date.ts b/src/constants/date.ts new file mode 100644 index 0000000..9cc4087 --- /dev/null +++ b/src/constants/date.ts @@ -0,0 +1,6 @@ +type FormattersKey = 'fullFormat' + + +export const dateFormats:Record = { + fullFormat: 'DD.MM.YYYY HH:mm:ss' +} diff --git a/src/pages/AllVersionsPage/index.tsx b/src/pages/AllVersionsPage/index.tsx index 1e5f292..3a89b51 100644 --- a/src/pages/AllVersionsPage/index.tsx +++ b/src/pages/AllVersionsPage/index.tsx @@ -28,6 +28,7 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { VersionType } from '@type/version.type.ts' import './all-versions-page.scss' +import { dateFormats } from '@constants/date.ts' const AllVersionsPage = () => { @@ -157,7 +158,7 @@ const AllVersionsPage = () => { title: 'Создано', dataIndex: 'createdAt', render: (value: string) => { - return dayjs(value).format('HH:mm:ss DD.MM.YYYY') + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/ConnectionsPage/index.tsx b/src/pages/ConnectionsPage/index.tsx index 171ef05..81f9a8e 100644 --- a/src/pages/ConnectionsPage/index.tsx +++ b/src/pages/ConnectionsPage/index.tsx @@ -16,6 +16,7 @@ import { PermissionKeysType } from '@type/roles.type.ts' import './connections.scss' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' +import { dateFormats } from '@constants/date.ts' const Connections = () => { const { data: ConnectionsList = [], isLoading: isModulesLoading } = @@ -51,7 +52,7 @@ const Connections = () => { } const formatFullDate = (obj: string) => - dayjs(obj).format('YYYY-MM-DD, HH:mm:ss') + dayjs(obj).format(dateFormats.fullFormat) const keySelector = ({ address: { ip, port }, diff --git a/src/pages/SecurityLogPage/index.tsx b/src/pages/SecurityLogPage/index.tsx index d1b70c1..f48f057 100644 --- a/src/pages/SecurityLogPage/index.tsx +++ b/src/pages/SecurityLogPage/index.tsx @@ -16,6 +16,8 @@ import { LogType } from '@type/log.type' import { PermissionKeysType } from '@type/roles.type' import './security-log-page.scss' +import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const limit = 10 @@ -75,8 +77,7 @@ const SecurityLogPage = () => { dataIndex: 'createdAt', key: 'createdAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/SessionsPage/index.tsx b/src/pages/SessionsPage/index.tsx index 4825e49..1cb9e86 100644 --- a/src/pages/SessionsPage/index.tsx +++ b/src/pages/SessionsPage/index.tsx @@ -29,6 +29,8 @@ import { PermissionKeysType } from '@type/roles.type.ts' import { SessionType } from '@type/session.type' import './sessions-page.scss' +import dayjs from 'dayjs' +import { dateFormats } from '@constants/date.ts' const limit = 10 @@ -96,8 +98,7 @@ const SessionsPage = () => { dataIndex: 'createdAt', key: 'createdAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { @@ -105,8 +106,7 @@ const SessionsPage = () => { dataIndex: 'expiredAt', key: 'expiredAt', render: (value) => { - const date = new Date(value) - return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}` + return dayjs(value).format(dateFormats.fullFormat) } }, { diff --git a/src/pages/UserEditor/index.tsx b/src/pages/UserEditor/index.tsx index f7b3f4a..407e848 100644 --- a/src/pages/UserEditor/index.tsx +++ b/src/pages/UserEditor/index.tsx @@ -1,10 +1,12 @@ import { ArrowLeftOutlined, SaveOutlined } from '@ant-design/icons' import { Button, message, Spin } from 'antd' +import dayjs from 'dayjs' import { FormComponents } from 'isp-ui-kit' import { useEffect } from 'react' import { useForm } from 'react-hook-form' import { useLocation, useNavigate } from 'react-router-dom' +import { dateFormats } from '@constants/date.ts' import { ValidationRules } from '@constants/form/validationRules.ts' import { findExclusiveRole } from '@utils/roleUtils.ts' @@ -23,6 +25,7 @@ import { LabelItem } from 'isp-ui-kit/dist/FormComponents/formTypes' import './user-editor.scss' + const UserEditor = () => { const location = useLocation() const navigate = useNavigate() @@ -166,9 +169,7 @@ const UserEditor = () => { {state.lastSessionCreatedAt && ( <> Последняя сессия   - {new Date(state.lastSessionCreatedAt).toLocaleDateString()} -   - {new Date(state.lastSessionCreatedAt).toLocaleTimeString()} + {dayjs(state.lastSessionCreatedAt).format(dateFormats.fullFormat)} )} diff --git a/src/pages/UsersPage/index.tsx b/src/pages/UsersPage/index.tsx index 591e111..2c05acb 100644 --- a/src/pages/UsersPage/index.tsx +++ b/src/pages/UsersPage/index.tsx @@ -25,6 +25,8 @@ 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 } = @@ -124,7 +126,7 @@ const UsersPage = () => { dataIndex: 'lastSessionCreatedAt', key: 'lastSessionCreatedAt', render: (value: string) => - value ? new Date(value).toLocaleDateString() : '' + value ? dayjs(value).format(dateFormats.fullFormat) : '' }, { dataIndex: 'actions', From ab6e2dcb726a95653bee2615a5b120c965ba9e39 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 14 May 2024 13:05:47 +0300 Subject: [PATCH 13/19] MSP-3289 update user messages --- src/components/ApplicationsContent/index.tsx | 6 +++--- src/components/TokenContent/index.tsx | 4 ++-- src/pages/SessionsPage/index.tsx | 2 +- src/pages/UserEditor/index.tsx | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/ApplicationsContent/index.tsx b/src/components/ApplicationsContent/index.tsx index fb363cc..37fb126 100644 --- a/src/components/ApplicationsContent/index.tsx +++ b/src/components/ApplicationsContent/index.tsx @@ -104,7 +104,7 @@ const ApplicationsContent: FC = ({ ...showApplicationsModal, updateModal: false }) - message.info('Элемент сохранен') + message.success('Элемент сохранен') }) .catch(() => message.error('Ошибка обновления элемента')) } @@ -120,7 +120,7 @@ const ApplicationsContent: FC = ({ createApplicationService(newApplicationApp) .unwrap() - .then(message.info('Элемент сохранен')) + .then(message.success('Элемент сохранен')) .catch((e) => message.error(e)) setShowApplicationsModal({ ...showApplicationsModal, @@ -131,7 +131,7 @@ const ApplicationsContent: FC = ({ removeApplicationsService([id]) .unwrap() .then(() => message.success('Элемент удален')) - .catch(() => message.info('Ошибка удаления элемента')) + .catch(() => message.error('Ошибка удаления элемента')) const renderColumnItems = (item: ColumnItem) => { return ( diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index dbb2f7f..06921aa 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -77,7 +77,7 @@ const TokenContent = ({ id }: TokenPropTypes) => { .then(() => { setShowApplicationsModal(false) reset() - message.info('Элемент добавлен') + message.success('Элемент добавлен') }) .catch(() => { message.error('Ошибка добавления элемента') @@ -106,7 +106,7 @@ const TokenContent = ({ id }: TokenPropTypes) => { revokeToken(currentRemoveToken) .unwrap() .then(() => message.success('Элемент удален')) - .catch(() => message.info('Ошибка удаления элемента')) + .catch(() => message.error('Ошибка удаления элемента')) } const columns: ColumnsType = [ diff --git a/src/pages/SessionsPage/index.tsx b/src/pages/SessionsPage/index.tsx index 1cb9e86..74d9661 100644 --- a/src/pages/SessionsPage/index.tsx +++ b/src/pages/SessionsPage/index.tsx @@ -71,7 +71,7 @@ const SessionsPage = () => { revokeSession(id) .unwrap() .then(() => message.success('Сессия успешно завершена')) - .catch(() => message.info('Не удалось завершить сессию')) + .catch(() => message.error('Не удалось завершить сессию')) } if (isLoading || !data) { diff --git a/src/pages/UserEditor/index.tsx b/src/pages/UserEditor/index.tsx index 407e848..c4cd7df 100644 --- a/src/pages/UserEditor/index.tsx +++ b/src/pages/UserEditor/index.tsx @@ -78,7 +78,7 @@ const UserEditor = () => { const exclusiveRole = findExclusiveRole(roles, value.roles as number[]) if (exclusiveRole) { if (value.roles && value.roles.length > 1) { - message.info( + message.error( <> Роль: {exclusiveRole.name} несовместима с другими ролями From e063e3ca69e0d1cca70b238912c0298eeab4b641 Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 14 May 2024 13:07:02 +0300 Subject: [PATCH 14/19] MSP-3289 rename applicationsPage label --- src/components/Layout/layout.type.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Layout/layout.type.ts b/src/components/Layout/layout.type.ts index c8c00eb..ec02f84 100644 --- a/src/components/Layout/layout.type.ts +++ b/src/components/Layout/layout.type.ts @@ -20,7 +20,7 @@ export enum MenuItemLabelsType { profile = 'Профиль', modules = 'Модули', logout = 'Выход', - applications_group = 'Группа приложений' + applications_group = 'Группы приложений' } interface MenuItem { From 358531beade8596fdc2e019f65ec069ef1f8046e Mon Sep 17 00:00:00 2001 From: veselovnk Date: Tue, 14 May 2024 13:41:28 +0300 Subject: [PATCH 15/19] MSP-3289 update Token table layout --- src/components/TokenContent/index.tsx | 66 ++++++++++++++------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/components/TokenContent/index.tsx b/src/components/TokenContent/index.tsx index 06921aa..5e0603d 100644 --- a/src/components/TokenContent/index.tsx +++ b/src/components/TokenContent/index.tsx @@ -1,20 +1,22 @@ import { CopyOutlined, DeleteOutlined } from '@ant-design/icons' -import { Button, message, Popconfirm, Spin, Table } from 'antd' +import { Button, message, Popconfirm, Spin, Table, Tooltip } from 'antd' import { ColumnsType } from 'antd/es/table' import ClipboardJS from 'clipboard' import dayjs from 'dayjs' import 'dayjs/locale/ru' import duration from 'dayjs/plugin/duration' import relativeTime from 'dayjs/plugin/relativeTime' -import { Layout, FormComponents } from 'isp-ui-kit' +import { FormComponents, Layout } from 'isp-ui-kit' import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' +import { dateFormats } from '@constants/date.ts' import { ValidationRules } from '@constants/form/validationRules.ts' import Modal from '@widgets/Modal' -// import CanEdit from '@components/CanEdit' +import CanEdit from '@components/CanEdit' + import { ApplicationTokenType, NewApplicationTokenType @@ -22,9 +24,10 @@ import { import tokensApi from '@services/tokensService.ts' -import './tokens.scss' -import CanEdit from '@components/CanEdit' -import { dateFormats } from '@constants/date.ts' + + +import './tokens.scss'; + const { FormSelect } = FormComponents const { EmptyData } = Layout @@ -110,6 +113,11 @@ const TokenContent = ({ id }: TokenPropTypes) => { } const columns: ColumnsType = [ + { + title: 'ID', + dataIndex: 'appId', + key: 'appId' + }, { title: 'Токен', dataIndex: 'token', @@ -121,7 +129,9 @@ const TokenContent = ({ id }: TokenPropTypes) => { dataIndex: 'createdAt', key: 'createdAt', render: (record) => { - const formatTime = dayjs(record.createdAt).format(dateFormats.fullFormat) + const formatTime = dayjs(record.createdAt).format( + dateFormats.fullFormat + ) return
{formatTime}
} }, @@ -150,33 +160,24 @@ const TokenContent = ({ id }: TokenPropTypes) => { } }, { - title: 'Скопировать', + title: 'Действия', dataIndex: 'token', - key: 'copyToken', - align: 'center', - render: (record) => { + key: 'actions', + render: (value) => { return ( - - ) - } - }, - { - title: 'Отозвать', - dataIndex: 'appId', - key: 'recall', - align: 'center', - render: (_, record) => { - return ( - handleRevokeToken(record)} - > - - + + +