Files
ragflow_python/web/src/pages/flow/canvas/node/dropdown.tsx
balibabu 957cd55e4a feat: deleting a node does not require a confirmation box to pop up #918 (#1380)
### What problem does this PR solve?

feat: deleting a node does not require a confirmation box to pop up #918

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2024-07-04 19:32:47 +08:00

50 lines
1.2 KiB
TypeScript

import OperateDropdown from '@/components/operate-dropdown';
import { CopyOutlined } from '@ant-design/icons';
import { Flex, MenuProps } from 'antd';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import useGraphStore from '../../store';
interface IProps {
id: string;
}
const NodeDropdown = ({ id }: IProps) => {
const { t } = useTranslation();
const deleteNodeById = useGraphStore((store) => store.deleteNodeById);
const duplicateNodeById = useGraphStore((store) => store.duplicateNode);
const deleteNode = useCallback(() => {
deleteNodeById(id);
}, [id, deleteNodeById]);
const duplicateNode = useCallback(() => {
duplicateNodeById(id);
}, [id, duplicateNodeById]);
const items: MenuProps['items'] = [
{
key: '2',
onClick: duplicateNode,
label: (
<Flex justify={'space-between'}>
{t('common.copy')}
<CopyOutlined />
</Flex>
),
},
];
return (
<OperateDropdown
iconFontSize={14}
height={14}
deleteItem={deleteNode}
items={items}
needsDeletionValidation={false}
></OperateDropdown>
);
};
export default NodeDropdown;