2024-05-13 10:51:12: merge [main:6f6359c4c01bf3e0cef37b14d6b016b7d5a1fa84];
This commit is contained in:
1 parent
2989c66a65
commit
739a9a3a4b
45 files changed
+4018
-309
No files matched your search
@@ -0,0 +1,108 @@
|
||||
import {
|
||||
AlertOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
EyeOutlined,
|
||||
HistoryOutlined,
|
||||
SwapOutlined
|
||||
} from '@ant-design/icons'
|
||||
import { Button, Dropdown, Popconfirm, Tooltip } from 'antd'
|
||||
import { FC } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { ActiveTableActionButtonsPropsType } from './active-table-action-buttons.type.ts'
|
||||
|
||||
import './active-table-action-buttons.scss'
|
||||
import CanEdit from '@components/CanEdit'
|
||||
|
||||
const ActiveTableActionButtons: FC<ActiveTableActionButtonsPropsType> =
|
||||
({
|
||||
isActive,
|
||||
record,
|
||||
handleShowCompareModal,
|
||||
handleShowConfig,
|
||||
handleDeleteConfig,
|
||||
handleMarkConfigActive
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const navigateToAllVersion = () => navigate(`${record.id}/all_versions`)
|
||||
|
||||
const renderDropDown = (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>
|
||||
<Popconfirm
|
||||
title="Вы действительно хотите удалить выбранный конфиг?"
|
||||
onConfirm={() => handleDeleteConfig(record)}
|
||||
>
|
||||
<Tooltip key="3" title="Удалить конфиг">
|
||||
<Button danger icon={<DeleteOutlined />} />
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
</CanEdit>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const renderAdditionalButtons = () => {
|
||||
if (isActive) {
|
||||
return (
|
||||
<>
|
||||
<Tooltip key="1" title="Сравнение версий">
|
||||
<Button
|
||||
onClick={() => handleShowCompareModal(record)}
|
||||
icon={<SwapOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip key="2" title="Просмотр истории">
|
||||
<Button
|
||||
onClick={navigateToAllVersion}
|
||||
icon={<HistoryOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<CanEdit>
|
||||
<Tooltip key="3" title="Сделать конфигурацию активной">
|
||||
<Button onClick={() => handleMarkConfigActive(record)} icon={<AlertOutlined />} />
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
<Dropdown dropdownRender={() => renderDropDown(record)}>
|
||||
<Button>...</Button>
|
||||
</Dropdown>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div className="active-configurations-table-actions-field">
|
||||
<Tooltip title="Просмотр конфигурации">
|
||||
<Button
|
||||
onClick={() => handleShowConfig(record)}
|
||||
icon={<EyeOutlined />}
|
||||
/>
|
||||
</Tooltip>
|
||||
<CanEdit>
|
||||
<Tooltip title="Редактировать конфигурацию">
|
||||
<Button icon={<EditOutlined />} />
|
||||
</Tooltip>
|
||||
</CanEdit>
|
||||
{renderAdditionalButtons()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActiveTableActionButtons
|
||||
Reference in new issue
Block a user