Skip to content

Commit c904dcf

Browse files
authored
Merge pull request #298 from FlowiseAI/feature/File-Upload-Types
Feature/file upload types
2 parents 6a63d1e + c590e64 commit c904dcf

7 files changed

Lines changed: 18 additions & 7 deletions

File tree

dist/components/Bot.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/inputs/textInput/components/TextInput.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type TextInputProps = {
2020
autoFocus?: boolean;
2121
sendMessageSound?: boolean;
2222
sendSoundLocation?: string;
23+
fullFileUploadAllowedTypes?: string;
2324
enableInputHistory?: boolean;
2425
maxHistorySize?: number;
2526
};

dist/components/inputs/textInput/components/TextInput.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Bot.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
300300
// drag & drop
301301
const [isDragActive, setIsDragActive] = createSignal(false);
302302
const [uploadedFiles, setUploadedFiles] = createSignal<{ file: File; type: string }[]>([]);
303+
const [fullFileUploadAllowedTypes, setFullFileUploadAllowedTypes] = createSignal('*');
303304

304305
createMemo(() => {
305306
const customerId = (props.chatflowConfig?.vars as any)?.customerId;
@@ -535,14 +536,18 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
535536
}
536537

537538
if (data.followUpPrompts) {
539+
let followUpPrompts = data.followUpPrompts;
540+
if (typeof followUpPrompts === 'string') {
541+
followUpPrompts = JSON.parse(followUpPrompts);
542+
}
538543
setMessages((prevMessages) => {
539544
const allMessages = [...cloneDeep(prevMessages)];
540545
if (allMessages[allMessages.length - 1].type === 'userMessage') return allMessages;
541-
allMessages[allMessages.length - 1].followUpPrompts = data.followUpPrompts;
546+
allMessages[allMessages.length - 1].followUpPrompts = followUpPrompts;
542547
addChatMessage(allMessages);
543548
return allMessages;
544549
});
545-
setFollowUpPrompts(JSON.parse(data.followUpPrompts));
550+
setFollowUpPrompts(followUpPrompts);
546551
}
547552
};
548553

@@ -1036,6 +1041,9 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
10361041
}
10371042
if (chatbotConfig.fullFileUpload) {
10381043
setFullFileUpload(chatbotConfig.fullFileUpload.status);
1044+
if (chatbotConfig.fullFileUpload?.allowedUploadFileTypes) {
1045+
setFullFileUploadAllowedTypes(chatbotConfig.fullFileUpload?.allowedUploadFileTypes);
1046+
}
10391047
}
10401048
}
10411049

@@ -1613,6 +1621,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
16131621
onSubmit={handleSubmit}
16141622
uploadsConfig={uploadsConfig()}
16151623
isFullFileUpload={fullFileUpload()}
1624+
fullFileUploadAllowedTypes={fullFileUploadAllowedTypes()}
16161625
setPreviews={setPreviews}
16171626
onMicrophoneClicked={onMicrophoneClicked}
16181627
handleFileChange={handleFileChange}

src/components/inputs/textInput/components/TextInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type TextInputProps = {
2828
autoFocus?: boolean;
2929
sendMessageSound?: boolean;
3030
sendSoundLocation?: string;
31+
fullFileUploadAllowedTypes?: string;
3132
enableInputHistory?: boolean;
3233
maxHistorySize?: number;
3334
};
@@ -128,7 +129,7 @@ export const TextInput = (props: TextInputProps) => {
128129
};
129130

130131
const getFileType = () => {
131-
if (props.isFullFileUpload) return '*';
132+
if (props.isFullFileUpload) return props.fullFileUploadAllowedTypes === '' ? '*' : props.fullFileUploadAllowedTypes;
132133
if (props.uploadsConfig?.fileUploadSizeAndTypes?.length) {
133134
const allowedFileTypes = props.uploadsConfig?.fileUploadSizeAndTypes.map((allowed) => allowed.fileTypes).join(',');
134135
if (allowedFileTypes.includes('*')) return '*';

0 commit comments

Comments
 (0)