import { AlertOutlined, DeleteOutlined, FormOutlined, EyeOutlined, HistoryOutlined, SwapOutlined, EllipsisOutlined, CopyOutlined } from '@ant-design/icons' import { Button, Dropdown, message, Popconfirm, Tooltip } from 'antd' import { FC } from 'react' import { useNavigate } from 'react-router-dom' import CanEdit from '@components/CanEdit' import { ConfigType } from '@pages/ModulesPage/module.type.ts' import configServiceApi from '@services/configService.ts' import { routePaths } from '@routes/routePaths.ts' import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons.type.ts' import './active-table-action-buttons.scss' const ActiveTableActionButtons: FC = ({ isActive, record, handleShowCompareModal, handleShowConfig, handleDeleteConfig, handleMarkConfigActive }) => { const navigate = useNavigate() const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation() const navigateToAllVersion = () => navigate(`${record.id}/all_versions`) 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 (
) } const renderDropDownActive = (record: any) => { return (
) } const renderAdditionalButtons = () => { if (isActive) { return ( renderDropDownActive(record)}>