From 6b782f35384d3ae94b22f56eb84aef3e466afef8 Mon Sep 17 00:00:00 2001 From: txix Date: Wed, 19 Jun 2024 16:10:13 +0300 Subject: [PATCH] 2024-06-19 16:10:13: merge [main:3f6394bf5a6c0253eec09dc38c8e21bca2ac37c5]; --- CHANGELOG.md | 2 + package.json | 2 +- .../ActiveTableActionButtons/index.tsx | 95 ++++++++++++------- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81699ae..a65e4cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.12.2 +- Добавлена возможность копирования конфига ## 0.12.1 - Исправлен шрифт в редакторах кода - Исправлены перерисовки экрана "Модули" diff --git a/package.json b/package.json index 824c56c..ac4fdaf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "isp-admin-ui", "private": true, - "version": "0.12.1", + "version": "0.12.2", "type": "module", "scripts": { "start": "vite", diff --git a/src/widgets/ActiveTableActionButtons/index.tsx b/src/widgets/ActiveTableActionButtons/index.tsx index d797f76..b2fc0b3 100644 --- a/src/widgets/ActiveTableActionButtons/index.tsx +++ b/src/widgets/ActiveTableActionButtons/index.tsx @@ -5,9 +5,10 @@ import { EyeOutlined, HistoryOutlined, SwapOutlined, - EllipsisOutlined + EllipsisOutlined, + CopyOutlined } from '@ant-design/icons' -import { Button, Dropdown, Popconfirm, Tooltip } from 'antd' +import { Button, Dropdown, message, Popconfirm, Tooltip } from 'antd' import { FC } from 'react' import { useNavigate } from 'react-router-dom' @@ -16,6 +17,8 @@ import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons import './active-table-action-buttons.scss' import CanEdit from '@components/CanEdit' import { routePaths } from '@routes/routePaths.ts' +import configServiceApi from '@services/configService.ts' +import { ConfigType } from '@pages/ModulesPage/module.type.ts' const ActiveTableActionButtons: FC = ({ @@ -27,10 +30,25 @@ const ActiveTableActionButtons: FC = handleMarkConfigActive }) => { const navigate = useNavigate() + const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation() const navigateToAllVersion = () => navigate(`${record.id}/all_versions`) - const renderDropDown = (record: any) => { + const copyConfig = () => { + const newConfig = { + name: `${record.name} (copy)`, + moduleId: record.moduleId, + id: '', + version: 0, + data: record.data + } as ConfigType + createUpdateConfig(newConfig) + .unwrap() + .then(() => message.success('Конфиг успешно скопирован')) + .catch(() => message.error('Не удалось скопировать конфиг')) + } + + const renderDropDownNoActive = (record: any) => { return (
@@ -43,6 +61,9 @@ const ActiveTableActionButtons: FC =
+ ) + } + const renderAdditionalButtons = () => { if (isActive) { return ( - <> - -