mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-17 04:25:53 +08:00
### What problem does this PR solve? feat: Hide the delete button on the agent page #2088 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
a82f092dac
commit
667632ba00
@ -20,12 +20,14 @@ interface IProps {
|
||||
messageId: string;
|
||||
content: string;
|
||||
prompt?: string;
|
||||
showLikeButton: boolean;
|
||||
}
|
||||
|
||||
export const AssistantGroupButton = ({
|
||||
messageId,
|
||||
content,
|
||||
prompt,
|
||||
showLikeButton,
|
||||
}: IProps) => {
|
||||
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
||||
useSendFeedback(messageId);
|
||||
@ -51,12 +53,16 @@ export const AssistantGroupButton = ({
|
||||
<SoundOutlined />
|
||||
</Tooltip>
|
||||
</Radio.Button>
|
||||
<Radio.Button value="c" onClick={handleLike}>
|
||||
<LikeOutlined />
|
||||
</Radio.Button>
|
||||
<Radio.Button value="d" onClick={showModal}>
|
||||
<DislikeOutlined />
|
||||
</Radio.Button>
|
||||
{showLikeButton && (
|
||||
<>
|
||||
<Radio.Button value="c" onClick={handleLike}>
|
||||
<LikeOutlined />
|
||||
</Radio.Button>
|
||||
<Radio.Button value="d" onClick={showModal}>
|
||||
<DislikeOutlined />
|
||||
</Radio.Button>
|
||||
</>
|
||||
)}
|
||||
{prompt && (
|
||||
<Radio.Button value="e" onClick={showPromptModal}>
|
||||
<SvgIcon name={`prompt`} width={16}></SvgIcon>
|
||||
@ -82,7 +88,7 @@ export const AssistantGroupButton = ({
|
||||
);
|
||||
};
|
||||
|
||||
interface UserGroupButtonProps extends IRemoveMessageById {
|
||||
interface UserGroupButtonProps extends Partial<IRemoveMessageById> {
|
||||
messageId: string;
|
||||
content: string;
|
||||
regenerateMessage(): void;
|
||||
@ -116,11 +122,13 @@ export const UserGroupButton = ({
|
||||
<SyncOutlined spin={sendLoading} />
|
||||
</Tooltip>
|
||||
</Radio.Button>
|
||||
<Radio.Button value="c" onClick={onRemoveMessage} disabled={loading}>
|
||||
<Tooltip title={t('common.delete')}>
|
||||
<DeleteOutlined spin={loading} />
|
||||
</Tooltip>
|
||||
</Radio.Button>
|
||||
{removeMessageById && (
|
||||
<Radio.Button value="c" onClick={onRemoveMessage} disabled={loading}>
|
||||
<Tooltip title={t('common.delete')}>
|
||||
<DeleteOutlined spin={loading} />
|
||||
</Tooltip>
|
||||
</Radio.Button>
|
||||
)}
|
||||
</Radio.Group>
|
||||
);
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ export const useSendFeedback = (messageId: string) => {
|
||||
|
||||
export const useRemoveMessage = (
|
||||
messageId: string,
|
||||
removeMessageById: IRemoveMessageById['removeMessageById'],
|
||||
removeMessageById?: IRemoveMessageById['removeMessageById'],
|
||||
) => {
|
||||
const { deleteMessage, loading } = useDeleteMessage();
|
||||
|
||||
@ -43,7 +43,7 @@ export const useRemoveMessage = (
|
||||
if (pureId) {
|
||||
const retcode = await deleteMessage(pureId);
|
||||
if (retcode === 0) {
|
||||
removeMessageById(messageId);
|
||||
removeMessageById?.(messageId);
|
||||
}
|
||||
}
|
||||
}, [deleteMessage, messageId, removeMessageById]);
|
||||
|
@ -24,7 +24,7 @@ import styles from './index.less';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
interface IProps extends IRemoveMessageById, IRegenerateMessage {
|
||||
interface IProps extends Partial<IRemoveMessageById>, IRegenerateMessage {
|
||||
item: IMessage;
|
||||
reference: IReference;
|
||||
loading?: boolean;
|
||||
@ -33,6 +33,7 @@ interface IProps extends IRemoveMessageById, IRegenerateMessage {
|
||||
avatar?: string;
|
||||
clickDocumentButton?: (documentId: string, chunk: IChunk) => void;
|
||||
index: number;
|
||||
showLikeButton?: boolean;
|
||||
}
|
||||
|
||||
const MessageItem = ({
|
||||
@ -45,6 +46,7 @@ const MessageItem = ({
|
||||
index,
|
||||
removeMessageById,
|
||||
regenerateMessage,
|
||||
showLikeButton = true,
|
||||
}: IProps) => {
|
||||
const isAssistant = item.role === MessageType.Assistant;
|
||||
const isUser = item.role === MessageType.User;
|
||||
@ -128,6 +130,7 @@ const MessageItem = ({
|
||||
messageId={item.id}
|
||||
content={item.content}
|
||||
prompt={item.prompt}
|
||||
showLikeButton={showLikeButton}
|
||||
></AssistantGroupButton>
|
||||
)
|
||||
) : (
|
||||
|
@ -58,6 +58,8 @@ const FlowChatBox = () => {
|
||||
)}
|
||||
clickDocumentButton={clickDocumentButton}
|
||||
index={i}
|
||||
regenerateMessage={() => {}}
|
||||
showLikeButton={false}
|
||||
></MessageItem>
|
||||
);
|
||||
})}
|
||||
|
Loading…
x
Reference in New Issue
Block a user