2024-06-27 14:43:06 +03:00
|
|
|
|
import { Handle, Position } from 'reactflow';
|
|
|
|
|
|
2024-07-24 18:11:28 +03:00
|
|
|
|
import { IconRSForm } from '@/components/Icons';
|
2024-07-26 00:33:22 +03:00
|
|
|
|
import TooltipOperation from '@/components/info/TooltipOperation';
|
2024-06-27 14:43:06 +03:00
|
|
|
|
import MiniButton from '@/components/ui/MiniButton.tsx';
|
2024-07-24 18:11:28 +03:00
|
|
|
|
import Overlay from '@/components/ui/Overlay';
|
2024-07-26 17:30:37 +03:00
|
|
|
|
import { OssNodeInternal } from '@/models/miscellaneous';
|
2024-07-26 00:33:22 +03:00
|
|
|
|
import { prefixes } from '@/utils/constants';
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
|
|
|
|
import { useOssEdit } from '../OssEditContext';
|
|
|
|
|
|
2024-07-26 17:30:37 +03:00
|
|
|
|
function OperationNode(node: OssNodeInternal) {
|
2024-06-27 14:43:06 +03:00
|
|
|
|
const controller = useOssEdit();
|
|
|
|
|
|
2024-07-26 17:30:37 +03:00
|
|
|
|
const hasFile = !!node.data.operation.result;
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
2024-07-24 18:11:28 +03:00
|
|
|
|
const handleOpenSchema = () => {
|
2024-07-26 17:30:37 +03:00
|
|
|
|
controller.openOperationSchema(Number(node.id));
|
2024-06-27 14:43:06 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-07-23 23:03:58 +03:00
|
|
|
|
<Handle type='source' position={Position.Bottom} />
|
2024-07-24 18:11:28 +03:00
|
|
|
|
|
|
|
|
|
<Overlay position='top-[-0.2rem] right-[-0.2rem]' className='cc-icons'>
|
|
|
|
|
<MiniButton
|
|
|
|
|
icon={<IconRSForm className={hasFile ? 'clr-text-green' : 'clr-text-red'} size='0.75rem' />}
|
|
|
|
|
noHover
|
|
|
|
|
title='Связанная КС'
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleOpenSchema();
|
|
|
|
|
}}
|
|
|
|
|
disabled={!hasFile}
|
|
|
|
|
/>
|
|
|
|
|
</Overlay>
|
2024-07-26 00:33:22 +03:00
|
|
|
|
|
2024-07-26 17:30:37 +03:00
|
|
|
|
<div id={`${prefixes.operation_list}${node.id}`} className='flex-grow text-center text-sm'>
|
|
|
|
|
{node.data.label}
|
2024-07-26 21:08:31 +03:00
|
|
|
|
{controller.showTooltip && !node.dragging ? (
|
|
|
|
|
<TooltipOperation anchor={`#${prefixes.operation_list}${node.id}`} node={node} />
|
|
|
|
|
) : null}
|
2024-07-26 00:33:22 +03:00
|
|
|
|
</div>
|
2024-06-27 14:43:06 +03:00
|
|
|
|
|
2024-07-23 23:03:58 +03:00
|
|
|
|
<Handle type='target' position={Position.Top} id='left' style={{ left: 40 }} />
|
|
|
|
|
<Handle type='target' position={Position.Top} id='right' style={{ right: 40, left: 'auto' }} />
|
2024-06-27 14:43:06 +03:00
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default OperationNode;
|