Skip to content

Commit 6deace2

Browse files
committed
Address Karthik feedback
1 parent dd11e98 commit 6deace2

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/module/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,17 @@ export const BasicDemo: FunctionComponent = () => {
138138
}, 1000);
139139
})
140140
.catch((error: DOMException) => {
141+
setShowAlert(true);
141142
setError(`Failed to read file: ${error.message}`);
142143
});
143144
};
144145

146+
const handleAttachRejected = () => {
147+
setFile(undefined);
148+
setShowAlert(true);
149+
setError('This demo only supports file extensions .txt, .json, .yaml, and .yaml. Please try a different file.');
150+
};
151+
145152
const handleFileDrop = (event: DropEvent, data: File[]) => {
146153
handleFile(data);
147154
};
@@ -227,6 +234,7 @@ export const BasicDemo: FunctionComponent = () => {
227234
'application/json': ['.json'],
228235
'application/yaml': ['.yaml', '.yml']
229236
}}
237+
onAttachRejected={handleAttachRejected}
230238
>
231239
<ChatbotContent>
232240
<MessageBox>
@@ -254,7 +262,17 @@ export const BasicDemo: FunctionComponent = () => {
254262
<FileDetailsLabel fileName={file.name} isLoading={isLoadingFile} onClose={onClose} />
255263
</div>
256264
)}
257-
<MessageBar onSendMessage={handleSend} hasAttachButton handleAttach={handleAttach} />
265+
<MessageBar
266+
onSendMessage={handleSend}
267+
hasAttachButton
268+
handleAttach={handleAttach}
269+
allowedFileTypes={{
270+
'text/plain': ['.txt'],
271+
'application/json': ['.json'],
272+
'application/yaml': ['.yaml', '.yml']
273+
}}
274+
onAttachRejected={handleAttachRejected}
275+
/>
258276
<ChatbotFootnote label="ChatBot uses AI. Check for mistakes." />
259277
</ChatbotFooter>
260278
</FileDropZone>

packages/module/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export const AttachmentMenuDemo: FunctionComponent = () => {
127127
// Attachments
128128
// --------------------------------------------------------------------------
129129
const handleFileDrop = (event: DropEvent, data: File[]) => {
130+
setIsOpen(false);
130131
setFile(data[0]);
131132
setIsLoadingFile(true);
132133
setTimeout(() => {

0 commit comments

Comments
 (0)