2024-07-04 19:18:02 +08:00
|
|
|
import { useTranslate } from '@/hooks/commonHooks';
|
2024-07-05 16:59:04 +08:00
|
|
|
import { Card, Divider, Flex, Layout, Tooltip } from 'antd';
|
2024-04-28 19:03:54 +08:00
|
|
|
import classNames from 'classnames';
|
2024-07-04 19:18:02 +08:00
|
|
|
import lowerFirst from 'lodash/lowerFirst';
|
2024-07-05 19:08:00 +08:00
|
|
|
import React from 'react';
|
2024-07-05 16:59:04 +08:00
|
|
|
import { Operator, componentMenuList } from '../constant';
|
2024-04-28 19:03:54 +08:00
|
|
|
import { useHandleDrag } from '../hooks';
|
2024-06-11 18:01:19 +08:00
|
|
|
import OperatorIcon from '../operator-icon';
|
2024-04-28 19:03:54 +08:00
|
|
|
import styles from './index.less';
|
|
|
|
|
|
|
|
|
|
const { Sider } = Layout;
|
|
|
|
|
|
2024-05-23 18:53:04 +08:00
|
|
|
interface IProps {
|
|
|
|
|
setCollapsed: (width: boolean) => void;
|
|
|
|
|
collapsed: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FlowSide = ({ setCollapsed, collapsed }: IProps) => {
|
|
|
|
|
const { handleDragStart } = useHandleDrag();
|
2024-07-04 19:18:02 +08:00
|
|
|
const { t } = useTranslate('flow');
|
2024-04-28 19:03:54 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Sider
|
|
|
|
|
collapsible
|
|
|
|
|
collapsed={collapsed}
|
|
|
|
|
collapsedWidth={0}
|
|
|
|
|
theme={'light'}
|
|
|
|
|
onCollapse={(value) => setCollapsed(value)}
|
|
|
|
|
>
|
|
|
|
|
<Flex vertical gap={10} className={styles.siderContent}>
|
2024-06-12 17:38:41 +08:00
|
|
|
{componentMenuList.map((x) => {
|
2024-06-11 18:01:19 +08:00
|
|
|
return (
|
2024-07-05 19:08:00 +08:00
|
|
|
<React.Fragment key={x.name}>
|
2024-07-05 16:59:04 +08:00
|
|
|
{x.name === Operator.DuckDuckGo && (
|
|
|
|
|
<Divider
|
|
|
|
|
style={{
|
|
|
|
|
marginTop: 10,
|
|
|
|
|
marginBottom: 10,
|
|
|
|
|
padding: 0,
|
|
|
|
|
borderBlockColor: '#b4afaf',
|
|
|
|
|
borderStyle: 'dotted',
|
|
|
|
|
}}
|
|
|
|
|
></Divider>
|
|
|
|
|
)}
|
|
|
|
|
<Card
|
|
|
|
|
key={x.name}
|
|
|
|
|
hoverable
|
|
|
|
|
draggable
|
|
|
|
|
className={classNames(styles.operatorCard)}
|
|
|
|
|
onDragStart={handleDragStart(x.name)}
|
|
|
|
|
>
|
|
|
|
|
<Flex align="center" gap={15}>
|
2024-06-11 18:01:19 +08:00
|
|
|
<OperatorIcon name={x.name}></OperatorIcon>
|
|
|
|
|
<section>
|
2024-07-04 19:18:02 +08:00
|
|
|
<Tooltip title={t(`${lowerFirst(x.name)}Description`)}>
|
|
|
|
|
<b>{x.name}</b>
|
|
|
|
|
</Tooltip>
|
2024-06-11 18:01:19 +08:00
|
|
|
</section>
|
2024-07-05 16:59:04 +08:00
|
|
|
</Flex>
|
|
|
|
|
</Card>
|
2024-07-05 19:08:00 +08:00
|
|
|
</React.Fragment>
|
2024-06-11 18:01:19 +08:00
|
|
|
);
|
|
|
|
|
})}
|
2024-04-28 19:03:54 +08:00
|
|
|
</Flex>
|
|
|
|
|
</Sider>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-23 18:53:04 +08:00
|
|
|
export default FlowSide;
|