mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: add chunkText to messageText to distinguish table rows and when parsing, the delete and other buttons are set to disabled. (#130)
* feat: when parsing, the delete and other buttons are set to disabled. * feat: add chunkText to messageText to distinguish table rows
This commit is contained in:
@ -0,0 +1,3 @@
|
|||||||
|
.iconButton {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
@ -3,6 +3,9 @@ import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
|||||||
import { DeleteOutlined, EditOutlined, ToolOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, EditOutlined, ToolOutlined } from '@ant-design/icons';
|
||||||
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
|
||||||
import { useDispatch } from 'umi';
|
import { useDispatch } from 'umi';
|
||||||
|
import { isParserRunning } from '../utils';
|
||||||
|
|
||||||
|
import styles from './index.less';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
knowledgeBaseId: string;
|
knowledgeBaseId: string;
|
||||||
@ -17,6 +20,7 @@ const ParsingActionCell = ({
|
|||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const documentId = record.id;
|
const documentId = record.id;
|
||||||
|
const isRunning = isParserRunning(record.run);
|
||||||
|
|
||||||
const removeDocument = () => {
|
const removeDocument = () => {
|
||||||
dispatch({
|
dispatch({
|
||||||
@ -29,7 +33,9 @@ const ParsingActionCell = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onRmDocument = () => {
|
const onRmDocument = () => {
|
||||||
|
if (!isRunning) {
|
||||||
showDeleteConfirm({ onOk: removeDocument });
|
showDeleteConfirm({ onOk: removeDocument });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setCurrentRecord = () => {
|
const setCurrentRecord = () => {
|
||||||
@ -49,11 +55,13 @@ const ParsingActionCell = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const showRenameModal = () => {
|
const showRenameModal = () => {
|
||||||
|
if (!isRunning) {
|
||||||
setCurrentRecord();
|
setCurrentRecord();
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'kFModel/setIsShowRenameModal',
|
type: 'kFModel/setIsShowRenameModal',
|
||||||
payload: true,
|
payload: true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const chunkItems: MenuProps['items'] = [
|
const chunkItems: MenuProps['items'] = [
|
||||||
@ -70,14 +78,38 @@ const ParsingActionCell = ({
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Space size={'middle'}>
|
<Space size={0}>
|
||||||
<Dropdown menu={{ items: chunkItems }} trigger={['click']}>
|
<Dropdown
|
||||||
<ToolOutlined size={20} onClick={setDocumentAndParserId} />
|
menu={{ items: chunkItems }}
|
||||||
|
trigger={['click']}
|
||||||
|
disabled={isRunning}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
onClick={setDocumentAndParserId}
|
||||||
|
className={styles.iconButton}
|
||||||
|
>
|
||||||
|
<ToolOutlined size={20} />
|
||||||
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Tooltip title="Rename">
|
<Tooltip title="Rename">
|
||||||
<EditOutlined size={20} onClick={showRenameModal} />
|
<Button
|
||||||
|
type="text"
|
||||||
|
disabled={isRunning}
|
||||||
|
onClick={showRenameModal}
|
||||||
|
className={styles.iconButton}
|
||||||
|
>
|
||||||
|
<EditOutlined size={20} />
|
||||||
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<DeleteOutlined size={20} onClick={onRmDocument} />
|
<Button
|
||||||
|
type="text"
|
||||||
|
disabled={isRunning}
|
||||||
|
onClick={onRmDocument}
|
||||||
|
className={styles.iconButton}
|
||||||
|
>
|
||||||
|
<DeleteOutlined size={20} />
|
||||||
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
|
|||||||
import reactStringReplace from 'react-string-replace';
|
import reactStringReplace from 'react-string-replace';
|
||||||
import { useDispatch } from 'umi';
|
import { useDispatch } from 'umi';
|
||||||
import { RunningStatus, RunningStatusMap } from '../constant';
|
import { RunningStatus, RunningStatusMap } from '../constant';
|
||||||
|
import { isParserRunning } from '../utils';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const iconMap = {
|
const iconMap = {
|
||||||
@ -77,7 +78,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
|
|||||||
const text = record.run;
|
const text = record.run;
|
||||||
const runningStatus = RunningStatusMap[text];
|
const runningStatus = RunningStatusMap[text];
|
||||||
|
|
||||||
const isRunning = text === RunningStatus.RUNNING;
|
const isRunning = isParserRunning(text);
|
||||||
|
|
||||||
const OperationIcon = iconMap[text];
|
const OperationIcon = iconMap[text];
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
import { RunningStatus } from './constant';
|
||||||
|
|
||||||
|
export const isParserRunning = (text: RunningStatus) => {
|
||||||
|
const isRunning = text === RunningStatus.RUNNING;
|
||||||
|
return isRunning;
|
||||||
|
};
|
||||||
@ -25,6 +25,7 @@
|
|||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
}
|
}
|
||||||
.messageText {
|
.messageText {
|
||||||
|
.chunkText();
|
||||||
padding: 0 14px;
|
padding: 0 14px;
|
||||||
background-color: rgba(249, 250, 251, 1);
|
background-color: rgba(249, 250, 251, 1);
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
|||||||
@ -262,12 +262,12 @@ const ChatContainer = () => {
|
|||||||
if (!loading) {
|
if (!loading) {
|
||||||
setValue('');
|
setValue('');
|
||||||
addNewestConversation(value);
|
addNewestConversation(value);
|
||||||
sendMessage(value);
|
sendMessage(value.trim());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
const handleInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
const value = e.target.value.trim();
|
const value = e.target.value;
|
||||||
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
const nextValue = value.replaceAll('\\n', '\n').replaceAll('\\t', '\t');
|
||||||
setValue(nextValue);
|
setValue(nextValue);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user