MSP-3203 create ActiveTableActionsButtons
This commit is contained in:
1 parent
4aeed36266
commit
0192278241
3 files changed
+130
No files matched your search
@@ -0,0 +1,12 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
|
||||
.active-configurations-table-actions-field {
|
||||
display: flex;
|
||||
gap: $basic-margin;
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
display: flex;
|
||||
gap: $basic-margin;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { ConfigType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
export interface ActiveTableActionButtonsPropsType {
|
||||
isActive: boolean
|
||||
record: ConfigType
|
||||
handleShowConfig: (record: ConfigType) => void
|
||||
handleShowCompareModal: (record: ConfigType) => void
|
||||
handleDeleteConfig: (record: ConfigType) => void
|
||||
handleMarkConfigActive: (record: ConfigType) => void
|
||||
}
|
||||
@@ -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