feat: Hide the upload button in the external agent's chat box #1880 (#1984)

### What problem does this PR solve?

feat: Hide the upload button in the external agent's chat box  #1880

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-08-16 18:50:48 +08:00
committed by GitHub
parent 4121636084
commit 8e75a23ad0
5 changed files with 37 additions and 8 deletions

View File

@ -1,3 +1,4 @@
import { SharedFrom } from '@/constants/chat';
import {
useCreateNextToken,
useFetchTokenList,
@ -71,9 +72,9 @@ export const useShowTokenEmptyError = () => {
return { showTokenEmptyError };
};
const getUrlWithToken = (token: string) => {
const getUrlWithToken = (token: string, from: string = 'chat') => {
const { protocol, host } = window.location;
return `${protocol}//${host}/chat/share?shared_id=${token}`;
return `${protocol}//${host}/chat/share?shared_id=${token}&from=${from}`;
};
const useFetchTokenListBeforeOtherStep = (dialogId: string, idKey: string) => {
@ -131,9 +132,18 @@ export const useShowEmbedModal = (dialogId: string, idKey: string) => {
export const usePreviewChat = (dialogId: string, idKey: string) => {
const { handleOperate } = useFetchTokenListBeforeOtherStep(dialogId, idKey);
const open = useCallback((t: string) => {
window.open(getUrlWithToken(t), '_blank');
}, []);
const open = useCallback(
(t: string) => {
window.open(
getUrlWithToken(
t,
idKey === 'canvasId' ? SharedFrom.Agent : SharedFrom.Chat,
),
'_blank',
);
},
[idKey],
);
const handlePreview = useCallback(async () => {
const token = await handleOperate();

View File

@ -66,6 +66,7 @@ interface IProps {
conversationId: string;
uploadUrl?: string;
isShared?: boolean;
showUploadIcon?: boolean;
}
const getBase64 = (file: FileType): Promise<string> =>
@ -85,6 +86,7 @@ const MessageInput = ({
sendLoading,
onInputChange,
conversationId,
showUploadIcon = true,
uploadUrl = '/v1/document/upload_and_parse',
}: IProps) => {
const { t } = useTranslate('chat');
@ -158,7 +160,7 @@ const MessageInput = ({
className={classNames({ [styles.inputWrapper]: fileList.length === 0 })}
suffix={
<Space>
{conversationId && (
{conversationId && showUploadIcon && (
<Upload
action={uploadUrl}
fileList={fileList}