balibabu
commited on
Commit
·
0086f8a
1
Parent(s):
eedc75d
feat: Hide the delete button on the agent page #2088 (#2167)
Browse files### 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)
web/src/components/message-item/group-button.tsx
CHANGED
@@ -20,12 +20,14 @@ interface IProps {
|
|
20 |
messageId: string;
|
21 |
content: string;
|
22 |
prompt?: string;
|
|
|
23 |
}
|
24 |
|
25 |
export const AssistantGroupButton = ({
|
26 |
messageId,
|
27 |
content,
|
28 |
prompt,
|
|
|
29 |
}: IProps) => {
|
30 |
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
31 |
useSendFeedback(messageId);
|
@@ -51,12 +53,16 @@ export const AssistantGroupButton = ({
|
|
51 |
<SoundOutlined />
|
52 |
</Tooltip>
|
53 |
</Radio.Button>
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
{prompt && (
|
61 |
<Radio.Button value="e" onClick={showPromptModal}>
|
62 |
<SvgIcon name={`prompt`} width={16}></SvgIcon>
|
@@ -82,7 +88,7 @@ export const AssistantGroupButton = ({
|
|
82 |
);
|
83 |
};
|
84 |
|
85 |
-
interface UserGroupButtonProps extends IRemoveMessageById {
|
86 |
messageId: string;
|
87 |
content: string;
|
88 |
regenerateMessage(): void;
|
@@ -116,11 +122,13 @@ export const UserGroupButton = ({
|
|
116 |
<SyncOutlined spin={sendLoading} />
|
117 |
</Tooltip>
|
118 |
</Radio.Button>
|
119 |
-
|
120 |
-
<
|
121 |
-
<
|
122 |
-
|
123 |
-
|
|
|
|
|
124 |
</Radio.Group>
|
125 |
);
|
126 |
};
|
|
|
20 |
messageId: string;
|
21 |
content: string;
|
22 |
prompt?: string;
|
23 |
+
showLikeButton: boolean;
|
24 |
}
|
25 |
|
26 |
export const AssistantGroupButton = ({
|
27 |
messageId,
|
28 |
content,
|
29 |
prompt,
|
30 |
+
showLikeButton,
|
31 |
}: IProps) => {
|
32 |
const { visible, hideModal, showModal, onFeedbackOk, loading } =
|
33 |
useSendFeedback(messageId);
|
|
|
53 |
<SoundOutlined />
|
54 |
</Tooltip>
|
55 |
</Radio.Button>
|
56 |
+
{showLikeButton && (
|
57 |
+
<>
|
58 |
+
<Radio.Button value="c" onClick={handleLike}>
|
59 |
+
<LikeOutlined />
|
60 |
+
</Radio.Button>
|
61 |
+
<Radio.Button value="d" onClick={showModal}>
|
62 |
+
<DislikeOutlined />
|
63 |
+
</Radio.Button>
|
64 |
+
</>
|
65 |
+
)}
|
66 |
{prompt && (
|
67 |
<Radio.Button value="e" onClick={showPromptModal}>
|
68 |
<SvgIcon name={`prompt`} width={16}></SvgIcon>
|
|
|
88 |
);
|
89 |
};
|
90 |
|
91 |
+
interface UserGroupButtonProps extends Partial<IRemoveMessageById> {
|
92 |
messageId: string;
|
93 |
content: string;
|
94 |
regenerateMessage(): void;
|
|
|
122 |
<SyncOutlined spin={sendLoading} />
|
123 |
</Tooltip>
|
124 |
</Radio.Button>
|
125 |
+
{removeMessageById && (
|
126 |
+
<Radio.Button value="c" onClick={onRemoveMessage} disabled={loading}>
|
127 |
+
<Tooltip title={t('common.delete')}>
|
128 |
+
<DeleteOutlined spin={loading} />
|
129 |
+
</Tooltip>
|
130 |
+
</Radio.Button>
|
131 |
+
)}
|
132 |
</Radio.Group>
|
133 |
);
|
134 |
};
|
web/src/components/message-item/hooks.ts
CHANGED
@@ -34,7 +34,7 @@ export const useSendFeedback = (messageId: string) => {
|
|
34 |
|
35 |
export const useRemoveMessage = (
|
36 |
messageId: string,
|
37 |
-
removeMessageById
|
38 |
) => {
|
39 |
const { deleteMessage, loading } = useDeleteMessage();
|
40 |
|
@@ -43,7 +43,7 @@ export const useRemoveMessage = (
|
|
43 |
if (pureId) {
|
44 |
const retcode = await deleteMessage(pureId);
|
45 |
if (retcode === 0) {
|
46 |
-
removeMessageById(messageId);
|
47 |
}
|
48 |
}
|
49 |
}, [deleteMessage, messageId, removeMessageById]);
|
|
|
34 |
|
35 |
export const useRemoveMessage = (
|
36 |
messageId: string,
|
37 |
+
removeMessageById?: IRemoveMessageById['removeMessageById'],
|
38 |
) => {
|
39 |
const { deleteMessage, loading } = useDeleteMessage();
|
40 |
|
|
|
43 |
if (pureId) {
|
44 |
const retcode = await deleteMessage(pureId);
|
45 |
if (retcode === 0) {
|
46 |
+
removeMessageById?.(messageId);
|
47 |
}
|
48 |
}
|
49 |
}, [deleteMessage, messageId, removeMessageById]);
|
web/src/components/message-item/index.tsx
CHANGED
@@ -24,7 +24,7 @@ import styles from './index.less';
|
|
24 |
|
25 |
const { Text } = Typography;
|
26 |
|
27 |
-
interface IProps extends IRemoveMessageById
|
28 |
item: IMessage;
|
29 |
reference: IReference;
|
30 |
loading?: boolean;
|
@@ -33,6 +33,7 @@ interface IProps extends IRemoveMessageById, IRegenerateMessage {
|
|
33 |
avatar?: string;
|
34 |
clickDocumentButton?: (documentId: string, chunk: IChunk) => void;
|
35 |
index: number;
|
|
|
36 |
}
|
37 |
|
38 |
const MessageItem = ({
|
@@ -45,6 +46,7 @@ const MessageItem = ({
|
|
45 |
index,
|
46 |
removeMessageById,
|
47 |
regenerateMessage,
|
|
|
48 |
}: IProps) => {
|
49 |
const isAssistant = item.role === MessageType.Assistant;
|
50 |
const isUser = item.role === MessageType.User;
|
@@ -128,6 +130,7 @@ const MessageItem = ({
|
|
128 |
messageId={item.id}
|
129 |
content={item.content}
|
130 |
prompt={item.prompt}
|
|
|
131 |
></AssistantGroupButton>
|
132 |
)
|
133 |
) : (
|
|
|
24 |
|
25 |
const { Text } = Typography;
|
26 |
|
27 |
+
interface IProps extends Partial<IRemoveMessageById>, IRegenerateMessage {
|
28 |
item: IMessage;
|
29 |
reference: IReference;
|
30 |
loading?: boolean;
|
|
|
33 |
avatar?: string;
|
34 |
clickDocumentButton?: (documentId: string, chunk: IChunk) => void;
|
35 |
index: number;
|
36 |
+
showLikeButton?: boolean;
|
37 |
}
|
38 |
|
39 |
const MessageItem = ({
|
|
|
46 |
index,
|
47 |
removeMessageById,
|
48 |
regenerateMessage,
|
49 |
+
showLikeButton = true,
|
50 |
}: IProps) => {
|
51 |
const isAssistant = item.role === MessageType.Assistant;
|
52 |
const isUser = item.role === MessageType.User;
|
|
|
130 |
messageId={item.id}
|
131 |
content={item.content}
|
132 |
prompt={item.prompt}
|
133 |
+
showLikeButton={showLikeButton}
|
134 |
></AssistantGroupButton>
|
135 |
)
|
136 |
) : (
|
web/src/pages/flow/chat/box.tsx
CHANGED
@@ -58,6 +58,8 @@ const FlowChatBox = () => {
|
|
58 |
)}
|
59 |
clickDocumentButton={clickDocumentButton}
|
60 |
index={i}
|
|
|
|
|
61 |
></MessageItem>
|
62 |
);
|
63 |
})}
|
|
|
58 |
)}
|
59 |
clickDocumentButton={clickDocumentButton}
|
60 |
index={i}
|
61 |
+
regenerateMessage={() => {}}
|
62 |
+
showLikeButton={false}
|
63 |
></MessageItem>
|
64 |
);
|
65 |
})}
|