|
|
@@ -5,9 +5,10 @@ import {
|
|
|
|
EyeOutlined,
|
|
|
|
EyeOutlined,
|
|
|
|
HistoryOutlined,
|
|
|
|
HistoryOutlined,
|
|
|
|
SwapOutlined,
|
|
|
|
SwapOutlined,
|
|
|
|
EllipsisOutlined
|
|
|
|
EllipsisOutlined,
|
|
|
|
|
|
|
|
CopyOutlined
|
|
|
|
} from '@ant-design/icons'
|
|
|
|
} from '@ant-design/icons'
|
|
|
|
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
|
|
|
import { Button, Dropdown, message, Popconfirm, Tooltip } from 'antd'
|
|
|
|
import { FC } from 'react'
|
|
|
|
import { FC } from 'react'
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
import { useNavigate } from 'react-router-dom'
|
|
|
|
|
|
|
|
|
|
|
@@ -16,6 +17,8 @@ import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons
|
|
|
|
import './active-table-action-buttons.scss'
|
|
|
|
import './active-table-action-buttons.scss'
|
|
|
|
import CanEdit from '@components/CanEdit'
|
|
|
|
import CanEdit from '@components/CanEdit'
|
|
|
|
import { routePaths } from '@routes/routePaths.ts'
|
|
|
|
import { routePaths } from '@routes/routePaths.ts'
|
|
|
|
|
|
|
|
import configServiceApi from '@services/configService.ts'
|
|
|
|
|
|
|
|
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
|
|
|
|
|
|
|
|
|
|
|
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
({
|
|
|
|
({
|
|
|
@@ -27,10 +30,25 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
handleMarkConfigActive
|
|
|
|
handleMarkConfigActive
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
const navigate = useNavigate()
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
const [createUpdateConfig] = configServiceApi.useCreateUpdateConfigMutation()
|
|
|
|
|
|
|
|
|
|
|
|
const navigateToAllVersion = () => navigate(`${record.id}/all_versions`)
|
|
|
|
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 (
|
|
|
|
return (
|
|
|
|
<div className="dropdown">
|
|
|
|
<div className="dropdown">
|
|
|
|
<Tooltip key="1" title="Сравнение версий">
|
|
|
|
<Tooltip key="1" title="Сравнение версий">
|
|
|
@@ -43,6 +61,9 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
|
|
|
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
|
<CanEdit>
|
|
|
|
<CanEdit>
|
|
|
|
|
|
|
|
<Tooltip key="4" title="Копировать конфиг">
|
|
|
|
|
|
|
|
<Button icon={<CopyOutlined />} onClick={copyConfig} />
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
<Popconfirm
|
|
|
|
<Popconfirm
|
|
|
|
title="Вы действительно хотите удалить выбранный конфиг?"
|
|
|
|
title="Вы действительно хотите удалить выбранный конфиг?"
|
|
|
|
onConfirm={() => handleDeleteConfig(record)}
|
|
|
|
onConfirm={() => handleDeleteConfig(record)}
|
|
|
@@ -56,23 +77,33 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderDropDownActive = (record: any) => {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className="dropdown">
|
|
|
|
|
|
|
|
<Tooltip key="1" title="Сравнение версий">
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={() => handleShowCompareModal(record)}
|
|
|
|
|
|
|
|
icon={<SwapOutlined />}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<Tooltip key="2" title="Просмотр истории">
|
|
|
|
|
|
|
|
<Button onClick={navigateToAllVersion} icon={<HistoryOutlined />} />
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<CanEdit>
|
|
|
|
|
|
|
|
<Tooltip key="4" title="Копировать конфиг">
|
|
|
|
|
|
|
|
<Button icon={<CopyOutlined />} onClick={copyConfig} />
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
</CanEdit>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const renderAdditionalButtons = () => {
|
|
|
|
const renderAdditionalButtons = () => {
|
|
|
|
if (isActive) {
|
|
|
|
if (isActive) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Dropdown dropdownRender={() => renderDropDownActive(record)}>
|
|
|
|
<Tooltip key="1" title="Сравнение версий">
|
|
|
|
<Button icon={<EllipsisOutlined />} />
|
|
|
|
<Button
|
|
|
|
</Dropdown>
|
|
|
|
onClick={() => handleShowCompareModal(record)}
|
|
|
|
|
|
|
|
icon={<SwapOutlined />}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<Tooltip key="2" title="Просмотр истории">
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={navigateToAllVersion}
|
|
|
|
|
|
|
|
icon={<HistoryOutlined />}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -83,8 +114,8 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
|
|
|
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
|
</CanEdit>
|
|
|
|
</CanEdit>
|
|
|
|
<Dropdown dropdownRender={() => renderDropDown(record)}>
|
|
|
|
<Dropdown dropdownRender={() => renderDropDownNoActive(record)}>
|
|
|
|
<Button icon={<EllipsisOutlined />} />
|
|
|
|
<Button icon={<EllipsisOutlined />} />
|
|
|
|
</Dropdown>
|
|
|
|
</Dropdown>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
)
|
|
|
@@ -92,20 +123,20 @@ const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="active-configurations-table-actions-field">
|
|
|
|
<div className="active-configurations-table-actions-field">
|
|
|
|
<Button.Group className="button_group">
|
|
|
|
<Button.Group className="button_group">
|
|
|
|
<Tooltip title="Просмотр">
|
|
|
|
<Tooltip title="Просмотр">
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
onClick={() => handleShowConfig(record)}
|
|
|
|
onClick={() => handleShowConfig(record)}
|
|
|
|
icon={<EyeOutlined />}
|
|
|
|
icon={<EyeOutlined />}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
<CanEdit>
|
|
|
|
|
|
|
|
<Tooltip title="Редактировать">
|
|
|
|
|
|
|
|
<Button onClick={() => {
|
|
|
|
|
|
|
|
navigate(`/${record.moduleId}/${routePaths.configEditor}/${record.id}`, { state: record })
|
|
|
|
|
|
|
|
}} icon={<EditOutlined />} />
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
|
</CanEdit>
|
|
|
|
<CanEdit>
|
|
|
|
{renderAdditionalButtons()}
|
|
|
|
<Tooltip title="Редактировать">
|
|
|
|
|
|
|
|
<Button onClick={() => {
|
|
|
|
|
|
|
|
navigate(`/${record.moduleId}/${routePaths.configEditor}/${record.id}`, { state: record })
|
|
|
|
|
|
|
|
}} icon={<EditOutlined />} />
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
|
|
</CanEdit>
|
|
|
|
|
|
|
|
{renderAdditionalButtons()}
|
|
|
|
</Button.Group>
|
|
|
|
</Button.Group>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|