@patternfly/chatbot 2.2.0-prerelease.27 → 2.2.0-prerelease.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +3 -3
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/cjs/ChatbotFooter/ChatbotFootnote.d.ts +1 -1
- package/dist/cjs/ChatbotFooter/ChatbotFootnote.js +1 -1
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +3 -3
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +2 -2
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +19 -11
- package/dist/cjs/Message/Message.d.ts +3 -0
- package/dist/cjs/Message/Message.js +3 -2
- package/dist/cjs/ResponseActions/ResponseActions.test.js +2 -2
- package/dist/css/main.css +3 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +3 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +3 -3
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +1 -1
- package/dist/esm/ChatbotFooter/ChatbotFootnote.d.ts +1 -1
- package/dist/esm/ChatbotFooter/ChatbotFootnote.js +1 -1
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +3 -3
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +2 -2
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +19 -11
- package/dist/esm/Message/Message.d.ts +3 -0
- package/dist/esm/Message/Message.js +3 -2
- package/dist/esm/ResponseActions/ResponseActions.test.js +2 -2
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentError.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +19 -6
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDropZone.tsx +2 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithAttachment.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomResponseActions.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithResponseActions.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +2 -2
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotFootnote.tsx +4 -4
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotWelcomeInteraction.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotWelcomePrompt.tsx +7 -7
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +10 -10
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +10 -10
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx +1 -1
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +3 -3
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +4 -4
- package/src/ChatbotFooter/ChatbotFootnote.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx +2 -2
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx +3 -3
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx +26 -18
- package/src/ChatbotWelcomePrompt/__snapshots__/ChatbotWelcomePrompt.test.tsx.snap +2 -2
- package/src/Message/Message.tsx +8 -1
- package/src/MessageBar/MessageBar.scss +3 -3
- package/src/ResponseActions/ResponseActions.test.tsx +4 -2
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx
CHANGED
@@ -31,7 +31,7 @@ export const MessageWithQuickResponsesExample: React.FunctionComponent = () => (
|
|
31
31
|
name="Bot"
|
32
32
|
role="bot"
|
33
33
|
avatar={patternflyAvatar}
|
34
|
-
content="Welcome back! How can I help?"
|
34
|
+
content="Welcome back, User! How can I help you today?"
|
35
35
|
quickResponses={[
|
36
36
|
{ id: '1', content: 'Help me with an access issue', onClick: () => alert('Clicked id 1') },
|
37
37
|
{ id: '2', content: 'Show my critical vulnerabilities', onClick: () => alert('Clicked id 2') },
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickStart.tsx
CHANGED
@@ -11,7 +11,7 @@ export const MessageWithQuickStartExample: React.FunctionComponent = () => (
|
|
11
11
|
name="Bot"
|
12
12
|
role="bot"
|
13
13
|
avatar={patternflyAvatar}
|
14
|
-
content="
|
14
|
+
content="Follow this quick guide to install the Pipelines Operator."
|
15
15
|
quickStarts={{
|
16
16
|
quickStart: explorePipelinesQuickStart as QuickStart,
|
17
17
|
onSelectQuickStart: (id) => alert(id)
|
@@ -21,7 +21,7 @@ export const MessageWithQuickStartExample: React.FunctionComponent = () => (
|
|
21
21
|
name="Bot"
|
22
22
|
role="bot"
|
23
23
|
avatar={patternflyAvatar}
|
24
|
-
content="
|
24
|
+
content="This quick start tile includes prerequisites and a default icon."
|
25
25
|
quickStarts={{
|
26
26
|
quickStart: monitorSampleAppQuickStart,
|
27
27
|
onSelectQuickStart: (id) => alert(id)
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithResponseActions.tsx
CHANGED
@@ -8,7 +8,7 @@ export const ResponseActionExample: React.FunctionComponent = () => (
|
|
8
8
|
name="Bot"
|
9
9
|
role="bot"
|
10
10
|
avatar={patternflyAvatar}
|
11
|
-
content="
|
11
|
+
content="I updated your account with those settings. You're ready to set up your first dashboard!"
|
12
12
|
actions={{
|
13
13
|
// eslint-disable-next-line no-console
|
14
14
|
positive: { onClick: () => console.log('Good response') },
|
@@ -145,14 +145,14 @@ _Italic text, formatted with single underscores_
|
|
145
145
|
<Message
|
146
146
|
name="User"
|
147
147
|
role="user"
|
148
|
-
content="
|
148
|
+
content="This is a user message with an updated timestamp."
|
149
149
|
timestamp="1 hour ago"
|
150
150
|
avatar={userAvatar}
|
151
151
|
/>
|
152
152
|
<Message
|
153
153
|
name="User"
|
154
154
|
role="user"
|
155
|
-
content="
|
155
|
+
content="This is a user message with `avatarProps` set to add a border."
|
156
156
|
avatar={userAvatar}
|
157
157
|
avatarProps={{ isBordered: true }}
|
158
158
|
/>
|
@@ -5,20 +5,20 @@ export const FootnoteDemo: React.FunctionComponent = () => (
|
|
5
5
|
<ChatbotFootnote
|
6
6
|
label="ChatBot uses AI. Check for mistakes."
|
7
7
|
popover={{
|
8
|
-
title: 'Verify
|
9
|
-
description: `While ChatBot strives for accuracy,
|
8
|
+
title: 'Verify information',
|
9
|
+
description: `While ChatBot strives for accuracy, AI is experimental and can make mistakes. We cannot guarantee that all information provided by ChatBot is up to date or without error. You should always verify responses using reliable sources, especially for crucial information and decision making.`,
|
10
10
|
bannerImage: {
|
11
11
|
src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
|
12
12
|
alt: 'Example image for footnote popover'
|
13
13
|
},
|
14
14
|
cta: {
|
15
|
-
label: '
|
15
|
+
label: 'Dismiss',
|
16
16
|
onClick: () => {
|
17
17
|
alert('Do something!');
|
18
18
|
}
|
19
19
|
},
|
20
20
|
link: {
|
21
|
-
label: '
|
21
|
+
label: 'View AI policy',
|
22
22
|
url: 'https://www.redhat.com/'
|
23
23
|
}
|
24
24
|
}}
|
package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotWelcomeInteraction.tsx
CHANGED
@@ -116,7 +116,7 @@ export const ChatbotWelcomeInteractionDemo: React.FunctionComponent = () => {
|
|
116
116
|
so that users of assistive devices receive sufficient context */}
|
117
117
|
<MessageBox announcement={announcement} position={position}>
|
118
118
|
{messages.length === 0 && (
|
119
|
-
<ChatbotWelcomePrompt title="
|
119
|
+
<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />
|
120
120
|
)}
|
121
121
|
{/* This code block enables scrolling to the top of the last message.
|
122
122
|
You can instead choose to move the div with scrollToBottomRef on it below
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
|
3
3
|
import ChatbotWelcomePrompt from '@patternfly/chatbot/dist/dynamic/ChatbotWelcomePrompt';
|
4
|
-
import Checkbox from '@patternfly/react-core';
|
4
|
+
import { Checkbox } from '@patternfly/react-core';
|
5
5
|
|
6
6
|
export const ChatbotWelcomePromptExample: React.FunctionComponent = () => {
|
7
7
|
const [showWelcomePrompts, setShowWelcomePrompts] = React.useState(true);
|
8
8
|
|
9
9
|
const welcomePrompts = [
|
10
10
|
{
|
11
|
-
title: '
|
12
|
-
message: '
|
11
|
+
title: 'Set up account',
|
12
|
+
message: 'Choose the necessary settings and preferences for your account.'
|
13
13
|
},
|
14
14
|
{
|
15
|
-
title: '
|
16
|
-
message: '
|
15
|
+
title: 'Troubleshoot issue',
|
16
|
+
message: 'Find documentation and instructions to resolve your issue.'
|
17
17
|
}
|
18
18
|
];
|
19
19
|
|
@@ -29,8 +29,8 @@ export const ChatbotWelcomePromptExample: React.FunctionComponent = () => {
|
|
29
29
|
id="showWelcomePrompts"
|
30
30
|
/>
|
31
31
|
<ChatbotWelcomePrompt
|
32
|
-
title="
|
33
|
-
description="How
|
32
|
+
title="Hi, ChatBot User!"
|
33
|
+
description="How can I help you today?"
|
34
34
|
{...(showWelcomePrompts && { prompts: welcomePrompts })}
|
35
35
|
/>
|
36
36
|
</>
|
@@ -36,20 +36,20 @@ import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
|
36
36
|
const footnoteProps = {
|
37
37
|
label: 'ChatBot uses AI. Check for mistakes.',
|
38
38
|
popover: {
|
39
|
-
title: 'Verify
|
40
|
-
description: `While ChatBot strives for accuracy,
|
39
|
+
title: 'Verify information',
|
40
|
+
description: `While ChatBot strives for accuracy, AI is experimental and can make mistakes. We cannot guarantee that all information provided by ChatBot is up to date or without error. You should always verify responses using reliable sources, especially for crucial information and decision making.`,
|
41
41
|
bannerImage: {
|
42
42
|
src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
|
43
43
|
alt: 'Example image for footnote popover'
|
44
44
|
},
|
45
45
|
cta: {
|
46
|
-
label: '
|
46
|
+
label: 'Dismiss',
|
47
47
|
onClick: () => {
|
48
48
|
alert('Do something!');
|
49
49
|
}
|
50
50
|
},
|
51
51
|
link: {
|
52
|
-
label: '
|
52
|
+
label: 'View AI policy',
|
53
53
|
url: 'https://www.redhat.com/'
|
54
54
|
}
|
55
55
|
}
|
@@ -129,12 +129,12 @@ const initialMessages: MessageProps[] = [
|
|
129
129
|
|
130
130
|
const welcomePrompts = [
|
131
131
|
{
|
132
|
-
title: '
|
133
|
-
message: '
|
132
|
+
title: 'Set up account',
|
133
|
+
message: 'Choose the necessary settings and preferences for your account.'
|
134
134
|
},
|
135
135
|
{
|
136
|
-
title: '
|
137
|
-
message: '
|
136
|
+
title: 'Troubleshoot issue',
|
137
|
+
message: 'Find documentation and instructions to resolve your issue.'
|
138
138
|
}
|
139
139
|
];
|
140
140
|
|
@@ -436,8 +436,8 @@ export const ChatbotDemo: React.FunctionComponent = () => {
|
|
436
436
|
so that users of assistive devices receive sufficient context */}
|
437
437
|
<MessageBox announcement={announcement}>
|
438
438
|
<ChatbotWelcomePrompt
|
439
|
-
title="
|
440
|
-
description="How
|
439
|
+
title="Hi, ChatBot User!"
|
440
|
+
description="How can I help you today?"
|
441
441
|
prompts={welcomePrompts}
|
442
442
|
/>
|
443
443
|
{/* This code block enables scrolling to the top of the last message.
|
@@ -231,7 +231,7 @@ export const BasicDemo: React.FunctionComponent = () => {
|
|
231
231
|
{error}
|
232
232
|
</ChatbotAlert>
|
233
233
|
)}
|
234
|
-
<ChatbotWelcomePrompt title="
|
234
|
+
<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />
|
235
235
|
{messages.map((message) => (
|
236
236
|
<Message key={message.name} {...message} />
|
237
237
|
))}
|
@@ -232,7 +232,7 @@ export const AttachmentMenuDemo: React.FunctionComponent = () => {
|
|
232
232
|
{error}
|
233
233
|
</ChatbotAlert>
|
234
234
|
)}
|
235
|
-
<ChatbotWelcomePrompt title="
|
235
|
+
<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />
|
236
236
|
{messages.map((message) => (
|
237
237
|
<Message key={message.name} {...message} />
|
238
238
|
))}
|
@@ -44,20 +44,20 @@ import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
|
44
44
|
const footnoteProps = {
|
45
45
|
label: 'ChatBot uses AI. Check for mistakes.',
|
46
46
|
popover: {
|
47
|
-
title: 'Verify
|
48
|
-
description: `While ChatBot strives for accuracy,
|
47
|
+
title: 'Verify information',
|
48
|
+
description: `While ChatBot strives for accuracy, AI is experimental and can make mistakes. We cannot guarantee that all information provided by ChatBot is up to date or without error. You should always verify responses using reliable sources, especially for crucial information and decision making.`,
|
49
49
|
bannerImage: {
|
50
50
|
src: 'https://cdn.dribbble.com/userupload/10651749/file/original-8a07b8e39d9e8bf002358c66fce1223e.gif',
|
51
51
|
alt: 'Example image for footnote popover'
|
52
52
|
},
|
53
53
|
cta: {
|
54
|
-
label: '
|
54
|
+
label: 'Dismiss',
|
55
55
|
onClick: () => {
|
56
56
|
alert('Do something!');
|
57
57
|
}
|
58
58
|
},
|
59
59
|
link: {
|
60
|
-
label: '
|
60
|
+
label: 'View AI policy',
|
61
61
|
url: 'https://www.redhat.com/'
|
62
62
|
}
|
63
63
|
}
|
@@ -137,12 +137,12 @@ const initialMessages: MessageProps[] = [
|
|
137
137
|
|
138
138
|
const welcomePrompts = [
|
139
139
|
{
|
140
|
-
title: '
|
141
|
-
message: '
|
140
|
+
title: 'Set up account',
|
141
|
+
message: 'Choose the necessary settings and preferences for your account.'
|
142
142
|
},
|
143
143
|
{
|
144
|
-
title: '
|
145
|
-
message: '
|
144
|
+
title: 'Troubleshoot issue',
|
145
|
+
message: 'Find documentation and instructions to resolve your issue.'
|
146
146
|
}
|
147
147
|
];
|
148
148
|
|
@@ -400,8 +400,8 @@ export const EmbeddedChatbotDemo: React.FunctionComponent = () => {
|
|
400
400
|
so that users of assistive devices receive sufficient context */}
|
401
401
|
<MessageBox announcement={announcement}>
|
402
402
|
<ChatbotWelcomePrompt
|
403
|
-
title="
|
404
|
-
description="How
|
403
|
+
title="Hi, ChatBot User!"
|
404
|
+
description="How can I help you today?"
|
405
405
|
prompts={welcomePrompts}
|
406
406
|
/>
|
407
407
|
{/* This code block enables scrolling to the top of the last message.
|
package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedComparisonChatbot.tsx
CHANGED
@@ -117,7 +117,7 @@ export const CompareChild = ({ name, input, hasNewInput, setIsSendButtonDisabled
|
|
117
117
|
</ChatbotHeader>
|
118
118
|
<ChatbotContent>
|
119
119
|
<MessageBox ariaLabel={`Scrollable message log for ${name}`} announcement={announcement}>
|
120
|
-
<ChatbotWelcomePrompt title="
|
120
|
+
<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />
|
121
121
|
{messages.map((message) => (
|
122
122
|
<Message key={message.id} {...message} />
|
123
123
|
))}
|
@@ -9,11 +9,11 @@ import { MenuToggleElement, Tooltip, MenuToggle, Dropdown, DropdownProps } from
|
|
9
9
|
import EllipsisIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
10
10
|
|
11
11
|
export interface ChatbotConversationHistoryDropdownProps extends Omit<DropdownProps, 'toggle'> {
|
12
|
-
/** Dropdown items rendered in conversation
|
12
|
+
/** Dropdown items rendered in conversation settings dropdown */
|
13
13
|
menuItems: React.ReactNode;
|
14
|
-
/** Optional classname applied to conversation
|
14
|
+
/** Optional classname applied to conversation settings dropdown */
|
15
15
|
menuClassName?: string;
|
16
|
-
/** Tooltip content and aria-label applied to conversation
|
16
|
+
/** Tooltip content and aria-label applied to conversation settings dropdown */
|
17
17
|
label?: string;
|
18
18
|
/** Callback for when user selects item. */
|
19
19
|
onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
|
@@ -48,11 +48,11 @@ export interface Conversation {
|
|
48
48
|
noIcon?: boolean;
|
49
49
|
/** Conversation */
|
50
50
|
text: string;
|
51
|
-
/** Dropdown items rendered in conversation
|
51
|
+
/** Dropdown items rendered in conversation settings dropdown */
|
52
52
|
menuItems?: React.ReactNode;
|
53
|
-
/** Optional classname applied to conversation
|
53
|
+
/** Optional classname applied to conversation settings dropdown */
|
54
54
|
menuClassName?: string;
|
55
|
-
/** Tooltip content and aria-label applied to conversation
|
55
|
+
/** Tooltip content and aria-label applied to conversation settings dropdown */
|
56
56
|
label?: string;
|
57
57
|
/** Callback for when user selects item. */
|
58
58
|
onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
|
@@ -124,7 +124,7 @@ export const ChatbotConversationHistoryNav: React.FunctionComponent<ChatbotConve
|
|
124
124
|
newChatButtonText = 'New chat',
|
125
125
|
drawerContent,
|
126
126
|
onNewChat,
|
127
|
-
searchInputPlaceholder = 'Search...',
|
127
|
+
searchInputPlaceholder = 'Search previous conversations...',
|
128
128
|
searchInputAriaLabel = 'Filter menu items',
|
129
129
|
handleTextInputChange,
|
130
130
|
displayMode,
|
@@ -32,7 +32,7 @@ export interface ChatbotFootnotePopover {
|
|
32
32
|
bannerImage?: ChatbotFootnotePopoverBannerImage;
|
33
33
|
/** Optional CTA button that can be used to trigger an action and close the popover */
|
34
34
|
cta?: ChatbotFootnotePopoverCTA;
|
35
|
-
/** Optional link that can be used to show
|
35
|
+
/** Optional link that can be used to show an external link like **View AI policy** */
|
36
36
|
link?: ChatbotFootnotePopoverLink;
|
37
37
|
/** Props for PF Popover */
|
38
38
|
popoverProps?: PopoverProps;
|
@@ -87,7 +87,7 @@ export const ChatbotFootnote: React.FunctionComponent<ChatbotFootnoteProps> = ({
|
|
87
87
|
popover.cta?.onClick();
|
88
88
|
}}
|
89
89
|
>
|
90
|
-
{popover.cta?.label || '
|
90
|
+
{popover.cta?.label || 'Dismiss'}
|
91
91
|
</Button>
|
92
92
|
)}
|
93
93
|
{popover?.link && (
|
@@ -15,7 +15,7 @@ describe('ChatbotHeaderSelectorDropdown', () => {
|
|
15
15
|
it('should render ChatbotHeaderSelectorDropdown', () => {
|
16
16
|
render(<ChatbotHeaderSelectorDropdown value="Option 1">{dropdownItems}</ChatbotHeaderSelectorDropdown>);
|
17
17
|
|
18
|
-
expect(screen.getByRole('button', { name:
|
18
|
+
expect(screen.getByRole('button', { name: /Select model/i })).toBeTruthy();
|
19
19
|
});
|
20
20
|
|
21
21
|
it('should call onselect handler when a dropdown item is clicked', async () => {
|
@@ -27,7 +27,7 @@ describe('ChatbotHeaderSelectorDropdown', () => {
|
|
27
27
|
);
|
28
28
|
|
29
29
|
act(() => {
|
30
|
-
fireEvent.click(screen.getByRole('button', { name:
|
30
|
+
fireEvent.click(screen.getByRole('button', { name: /Select model/i }));
|
31
31
|
});
|
32
32
|
|
33
33
|
await waitFor(() => {
|
@@ -23,12 +23,12 @@ export const ChatbotHeaderSelectorDropdown: React.FunctionComponent<ChatbotHeade
|
|
23
23
|
children,
|
24
24
|
onSelect,
|
25
25
|
tooltipProps,
|
26
|
-
tooltipContent = '
|
26
|
+
tooltipContent = 'Select model',
|
27
27
|
menuToggleAriaLabel,
|
28
28
|
...props
|
29
29
|
}: ChatbotHeaderSelectorDropdownProps) => {
|
30
30
|
const [isOptionsMenuOpen, setIsOptionsMenuOpen] = React.useState(false);
|
31
|
-
const [defaultAriaLabel, setDefaultAriaLabel] = React.useState('
|
31
|
+
const [defaultAriaLabel, setDefaultAriaLabel] = React.useState('Select model');
|
32
32
|
|
33
33
|
const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
|
34
34
|
<Tooltip
|
@@ -57,7 +57,7 @@ export const ChatbotHeaderSelectorDropdown: React.FunctionComponent<ChatbotHeade
|
|
57
57
|
isOpen={isOptionsMenuOpen}
|
58
58
|
onSelect={(e, value) => {
|
59
59
|
onSelect && onSelect(e, value);
|
60
|
-
setDefaultAriaLabel(`
|
60
|
+
setDefaultAriaLabel(`Select model: ${value}`);
|
61
61
|
setIsOptionsMenuOpen(false);
|
62
62
|
}}
|
63
63
|
onOpenChange={(isOpen) => setIsOptionsMenuOpen(isOpen)}
|
@@ -7,53 +7,61 @@ import userEvent from '@testing-library/user-event';
|
|
7
7
|
describe('ChatbotWelcomePrompt', () => {
|
8
8
|
it('should render welcome prompt', () => {
|
9
9
|
const { container } = render(
|
10
|
-
<ChatbotWelcomePrompt title="
|
10
|
+
<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />
|
11
11
|
);
|
12
12
|
expect(container).toMatchSnapshot();
|
13
13
|
});
|
14
14
|
|
15
15
|
it('should render correctly', () => {
|
16
|
-
render(<ChatbotWelcomePrompt title="
|
17
|
-
expect(screen.getByText('
|
18
|
-
expect(screen.getByText('How
|
16
|
+
render(<ChatbotWelcomePrompt title="Hi, ChatBot User!" description="How can I help you today?" />);
|
17
|
+
expect(screen.getByText('Hi, ChatBot User!')).toBeTruthy();
|
18
|
+
expect(screen.getByText('How can I help you today?')).toBeTruthy();
|
19
19
|
});
|
20
20
|
it('should render prompts with titles correctly', () => {
|
21
21
|
render(
|
22
22
|
<ChatbotWelcomePrompt
|
23
|
-
title="
|
24
|
-
description="How
|
25
|
-
prompts={[{ title: '
|
23
|
+
title="Hi, ChatBot User!"
|
24
|
+
description="How can I help you today?"
|
25
|
+
prompts={[{ title: 'Set up account' }]}
|
26
26
|
/>
|
27
27
|
);
|
28
|
-
expect(screen.getByText('
|
28
|
+
expect(screen.getByText('Set up account')).toBeTruthy();
|
29
29
|
});
|
30
30
|
it('should render prompts with messages correctly', () => {
|
31
31
|
render(
|
32
32
|
<ChatbotWelcomePrompt
|
33
|
-
title="
|
34
|
-
description="How
|
35
|
-
prompts={[
|
33
|
+
title="Hi, ChatBot User!"
|
34
|
+
description="How can I help you today?"
|
35
|
+
prompts={[
|
36
|
+
{ title: 'Set up account', message: 'Choose the necessary settings and preferences for your account.' }
|
37
|
+
]}
|
36
38
|
/>
|
37
39
|
);
|
38
|
-
expect(screen.getByText('
|
40
|
+
expect(screen.getByText('Choose the necessary settings and preferences for your account.')).toBeTruthy();
|
39
41
|
});
|
40
42
|
it('should render prompts with onClick correctly', async () => {
|
41
43
|
const spy = jest.fn();
|
42
44
|
render(
|
43
45
|
<ChatbotWelcomePrompt
|
44
|
-
title="
|
45
|
-
description="How
|
46
|
-
prompts={[
|
46
|
+
title="Hi, ChatBot User!"
|
47
|
+
description="How can I help you today?"
|
48
|
+
prompts={[
|
49
|
+
{
|
50
|
+
title: 'Set up account',
|
51
|
+
message: 'Choose the necessary settings and preferences for your account.',
|
52
|
+
onClick: spy
|
53
|
+
}
|
54
|
+
]}
|
47
55
|
/>
|
48
56
|
);
|
49
|
-
await userEvent.click(screen.getByRole('button', { name: /
|
57
|
+
await userEvent.click(screen.getByRole('button', { name: /Set up account/i }));
|
50
58
|
expect(spy).toHaveBeenCalled();
|
51
59
|
});
|
52
60
|
it('should apply className appropriately', () => {
|
53
61
|
render(
|
54
62
|
<ChatbotWelcomePrompt
|
55
|
-
title="
|
56
|
-
description="How
|
63
|
+
title="Hi, ChatBot User!"
|
64
|
+
description="How can I help you today?"
|
57
65
|
className="test"
|
58
66
|
testId="welcome-prompt"
|
59
67
|
/>
|
@@ -15,13 +15,13 @@ exports[`ChatbotWelcomePrompt should render welcome prompt 1`] = `
|
|
15
15
|
<span
|
16
16
|
class="pf-chatbot__hello"
|
17
17
|
>
|
18
|
-
|
18
|
+
Hi, ChatBot User!
|
19
19
|
</span>
|
20
20
|
<br />
|
21
21
|
<span
|
22
22
|
class="pf-chatbot__question"
|
23
23
|
>
|
24
|
-
How
|
24
|
+
How can I help you today?
|
25
25
|
</span>
|
26
26
|
</h1>
|
27
27
|
</div>
|
package/src/Message/Message.tsx
CHANGED
@@ -38,6 +38,7 @@ import ThMessage from './TableMessage/ThMessage';
|
|
38
38
|
import { TableProps } from '@patternfly/react-table';
|
39
39
|
import ImageMessage from './ImageMessage/ImageMessage';
|
40
40
|
import rehypeUnwrapImages from 'rehype-unwrap-images';
|
41
|
+
import { PluggableList } from 'react-markdown/lib';
|
41
42
|
|
42
43
|
export interface MessageAttachment {
|
43
44
|
/** Name of file attached to the message */
|
@@ -133,6 +134,8 @@ export interface MessageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'rol
|
|
133
134
|
innerRef?: React.Ref<HTMLDivElement>;
|
134
135
|
/** Props for table message. It is important to include a detailed aria-label that describes the purpose of the table. */
|
135
136
|
tableProps?: Required<Pick<TableProps, 'aria-label'>> & TableProps;
|
137
|
+
/** Additional rehype plugins passed from the consumer */
|
138
|
+
additionalRehypePlugins?: PluggableList;
|
136
139
|
}
|
137
140
|
|
138
141
|
export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
@@ -159,6 +162,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
159
162
|
isLiveRegion = true,
|
160
163
|
innerRef,
|
161
164
|
tableProps,
|
165
|
+
additionalRehypePlugins = [],
|
162
166
|
...props
|
163
167
|
}: MessageProps) => {
|
164
168
|
const { beforeMainContent, afterMainContent, endContent } = extraContent || {};
|
@@ -171,6 +175,9 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
171
175
|
// Keep timestamps consistent between Timestamp component and aria-label
|
172
176
|
const date = new Date();
|
173
177
|
const dateString = timestamp ?? `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
178
|
+
|
179
|
+
const rehypePlugins = [rehypeUnwrapImages, ...(additionalRehypePlugins ?? [])];
|
180
|
+
|
174
181
|
return (
|
175
182
|
<section
|
176
183
|
aria-label={`Message from ${role} - ${dateString}`}
|
@@ -240,7 +247,7 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
240
247
|
img: (props) => <ImageMessage {...props} />
|
241
248
|
}}
|
242
249
|
remarkPlugins={[remarkGfm]}
|
243
|
-
rehypePlugins={
|
250
|
+
rehypePlugins={rehypePlugins}
|
244
251
|
>
|
245
252
|
{content}
|
246
253
|
</Markdown>
|
@@ -68,13 +68,13 @@
|
|
68
68
|
.pf-v6-c-form-control__textarea:focus-visible {
|
69
69
|
outline: none;
|
70
70
|
}
|
71
|
-
|
72
|
-
outline-offset: 0px;
|
71
|
+
textarea {
|
72
|
+
outline-offset: 0px !important;
|
73
73
|
--pf-v6-c-form-control--PaddingBlockStart: 0;
|
74
74
|
--pf-v6-c-form-control--PaddingBlockEnd: 0;
|
75
75
|
--pf-v6-c-form-control--BorderRadius: 0;
|
76
76
|
}
|
77
|
-
|
77
|
+
textarea:focus-visible {
|
78
78
|
outline: none;
|
79
79
|
}
|
80
80
|
}
|
@@ -90,7 +90,7 @@ describe('ResponseActions', () => {
|
|
90
90
|
name="Bot"
|
91
91
|
role="bot"
|
92
92
|
avatar=""
|
93
|
-
content="
|
93
|
+
content="I updated your account with those settings. You're ready to set up your first dashboard!"
|
94
94
|
actions={{
|
95
95
|
positive: {},
|
96
96
|
negative: {}
|
@@ -113,7 +113,9 @@ describe('ResponseActions', () => {
|
|
113
113
|
'pf-chatbot__button--response-action-clicked'
|
114
114
|
);
|
115
115
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
116
|
-
await userEvent.click(
|
116
|
+
await userEvent.click(
|
117
|
+
screen.getByText("I updated your account with those settings. You're ready to set up your first dashboard!")
|
118
|
+
);
|
117
119
|
expect(goodBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
118
120
|
expect(badBtn).not.toHaveClass('pf-chatbot__button--response-action-clicked');
|
119
121
|
});
|