Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Hide the delete button on the agent page #2088 #2167

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions web/src/components/message-item/group-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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>
Expand All @@ -82,7 +88,7 @@ export const AssistantGroupButton = ({
);
};

interface UserGroupButtonProps extends IRemoveMessageById {
interface UserGroupButtonProps extends Partial<IRemoveMessageById> {
messageId: string;
content: string;
regenerateMessage(): void;
Expand Down Expand Up @@ -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>
);
};
4 changes: 2 additions & 2 deletions web/src/components/message-item/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const useSendFeedback = (messageId: string) => {

export const useRemoveMessage = (
messageId: string,
removeMessageById: IRemoveMessageById['removeMessageById'],
removeMessageById?: IRemoveMessageById['removeMessageById'],
) => {
const { deleteMessage, loading } = useDeleteMessage();

Expand All @@ -43,7 +43,7 @@ export const useRemoveMessage = (
if (pureId) {
const retcode = await deleteMessage(pureId);
if (retcode === 0) {
removeMessageById(messageId);
removeMessageById?.(messageId);
}
}
}, [deleteMessage, messageId, removeMessageById]);
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +33,7 @@ interface IProps extends IRemoveMessageById, IRegenerateMessage {
avatar?: string;
clickDocumentButton?: (documentId: string, chunk: IChunk) => void;
index: number;
showLikeButton?: boolean;
}

const MessageItem = ({
Expand All @@ -45,6 +46,7 @@ const MessageItem = ({
index,
removeMessageById,
regenerateMessage,
showLikeButton = true,
}: IProps) => {
const isAssistant = item.role === MessageType.Assistant;
const isUser = item.role === MessageType.User;
Expand Down Expand Up @@ -128,6 +130,7 @@ const MessageItem = ({
messageId={item.id}
content={item.content}
prompt={item.prompt}
showLikeButton={showLikeButton}
></AssistantGroupButton>
)
) : (
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/flow/chat/box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const FlowChatBox = () => {
)}
clickDocumentButton={clickDocumentButton}
index={i}
regenerateMessage={() => {}}
showLikeButton={false}
></MessageItem>
);
})}
Expand Down