@patternfly/chatbot 6.4.0-prerelease.10 → 6.4.0-prerelease.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/chatbot",
|
|
3
|
-
"version": "6.4.0-prerelease.
|
|
3
|
+
"version": "6.4.0-prerelease.11",
|
|
4
4
|
"description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -38,6 +38,9 @@ import { RobotIcon } from '@patternfly/react-icons/dist/esm/icons/robot-icon';
|
|
|
38
38
|
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
|
|
39
39
|
import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon';
|
|
40
40
|
import RedoIcon from '@patternfly/react-icons/dist/esm/icons/redo-icon';
|
|
41
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
42
|
+
import ArrowCircleDownIcon from '@patternfly/react-icons/dist/esm/icons/arrow-circle-down-icon';
|
|
43
|
+
import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon';
|
|
41
44
|
import patternflyAvatar from './patternfly_avatar.jpg';
|
|
42
45
|
import AttachmentEdit from '@patternfly/chatbot/dist/dynamic/AttachmentEdit';
|
|
43
46
|
import FileDetails from '@patternfly/chatbot/dist/dynamic/FileDetails';
|
package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessageWithExtraContent.tsx
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
|
-
import { Fragment, FunctionComponent } from 'react';
|
|
2
|
-
|
|
1
|
+
import { Fragment, FunctionComponent, useState, useEffect } from 'react';
|
|
3
2
|
import Message from '@patternfly/chatbot/dist/dynamic/Message';
|
|
4
3
|
import userAvatar from './user_avatar.svg';
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Accordion,
|
|
6
|
+
AccordionContent,
|
|
7
|
+
AccordionItem,
|
|
8
|
+
AccordionToggle,
|
|
9
|
+
Alert,
|
|
10
|
+
Badge,
|
|
11
|
+
Button,
|
|
12
|
+
ButtonVariant,
|
|
13
|
+
Card,
|
|
14
|
+
CardBody,
|
|
15
|
+
CardExpandableContent,
|
|
16
|
+
CardFooter,
|
|
17
|
+
CardHeader,
|
|
18
|
+
CardTitle,
|
|
19
|
+
CodeBlock,
|
|
20
|
+
CodeBlockCode,
|
|
21
|
+
Content,
|
|
22
|
+
ContentVariants,
|
|
23
|
+
DescriptionList,
|
|
24
|
+
DescriptionListDescription,
|
|
25
|
+
DescriptionListGroup,
|
|
26
|
+
DescriptionListTerm,
|
|
27
|
+
Flex,
|
|
28
|
+
FlexItem,
|
|
29
|
+
HelperText,
|
|
30
|
+
HelperTextItem,
|
|
31
|
+
Icon,
|
|
32
|
+
Progress,
|
|
33
|
+
ProgressMeasureLocation,
|
|
34
|
+
Spinner
|
|
35
|
+
} from '@patternfly/react-core';
|
|
36
|
+
import ArrowCircleDownIcon from '@patternfly/react-icons/dist/esm/icons/arrow-circle-down-icon';
|
|
37
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
38
|
+
import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-icon';
|
|
39
|
+
import patternflyAvatar from '../Messages/patternfly_avatar.jpg';
|
|
40
|
+
import React from 'react';
|
|
6
41
|
|
|
7
42
|
const UserActionEndContent = () => {
|
|
8
43
|
// eslint-disable-next-line no-console
|
|
@@ -36,6 +71,350 @@ const BeforeMainContent = () => (
|
|
|
36
71
|
</div>
|
|
37
72
|
);
|
|
38
73
|
|
|
74
|
+
const downloadCard = (
|
|
75
|
+
<Card>
|
|
76
|
+
<CardHeader isToggleRightAligned>
|
|
77
|
+
<CardTitle>
|
|
78
|
+
<Flex spaceItems={{ default: 'spaceItemsSm' }}>
|
|
79
|
+
<FlexItem>
|
|
80
|
+
<Icon size="lg" status="success">
|
|
81
|
+
<CheckCircleIcon />
|
|
82
|
+
</Icon>
|
|
83
|
+
</FlexItem>
|
|
84
|
+
<FlexItem>Your discovery ISO is ready</FlexItem>
|
|
85
|
+
</Flex>
|
|
86
|
+
</CardTitle>
|
|
87
|
+
</CardHeader>
|
|
88
|
+
|
|
89
|
+
<CardBody>
|
|
90
|
+
<Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsLg' }}>
|
|
91
|
+
<FlexItem>
|
|
92
|
+
<Content component={ContentVariants.p}>
|
|
93
|
+
To begin adding hosts to your bare metal cluster, you first need to boot them with the generated Discovery
|
|
94
|
+
ISO. This allows the installation program to see and manage your hardware.
|
|
95
|
+
</Content>
|
|
96
|
+
</FlexItem>
|
|
97
|
+
|
|
98
|
+
<Flex direction={{ default: 'column' }} spaceItems={{ default: 'spaceItemsSm' }}>
|
|
99
|
+
<FlexItem>
|
|
100
|
+
<Button variant={ButtonVariant.primary} icon={<ArrowCircleDownIcon />} isBlock>
|
|
101
|
+
Download Discovery ISO
|
|
102
|
+
</Button>
|
|
103
|
+
</FlexItem>
|
|
104
|
+
|
|
105
|
+
<FlexItem alignSelf={{ default: 'alignSelfCenter' }}>
|
|
106
|
+
<Content component={ContentVariants.small}>1.2 GB • Expires in 24 hours</Content>
|
|
107
|
+
</FlexItem>
|
|
108
|
+
</Flex>
|
|
109
|
+
</Flex>
|
|
110
|
+
</CardBody>
|
|
111
|
+
|
|
112
|
+
<CardFooter>
|
|
113
|
+
<Content component={ContentVariants.small}>
|
|
114
|
+
<strong>Next step:</strong> After downloading, boot your bare metal hosts from this ISO image.
|
|
115
|
+
</Content>
|
|
116
|
+
</CardFooter>
|
|
117
|
+
</Card>
|
|
118
|
+
);
|
|
119
|
+
interface Stage {
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
startProgress: number;
|
|
123
|
+
endProgress: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const LiveProgressSummaryCard = () => {
|
|
127
|
+
const [isCardExpanded, setIsCardExpanded] = useState(false);
|
|
128
|
+
const [isAccordionExpanded, setIsAccordionExpanded] = useState('installing-toggle');
|
|
129
|
+
const [progress, setProgress] = useState(15);
|
|
130
|
+
const [isSimulationRunning, setIsSimulationRunning] = useState(false);
|
|
131
|
+
const [userManuallyExpandedAccordion, setUserManuallyExpandedAccordion] = useState(false);
|
|
132
|
+
|
|
133
|
+
const stages: Stage[] = [
|
|
134
|
+
{
|
|
135
|
+
id: 'installing-toggle',
|
|
136
|
+
name: 'Installing cluster bootstrap',
|
|
137
|
+
startProgress: 0,
|
|
138
|
+
endProgress: 25
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'setup-toggle',
|
|
142
|
+
name: 'Control plane setup',
|
|
143
|
+
startProgress: 25,
|
|
144
|
+
endProgress: 45
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 'deploying-toggle',
|
|
148
|
+
name: 'Deploying cluster operators',
|
|
149
|
+
startProgress: 45,
|
|
150
|
+
endProgress: 85
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 'finalizing-toggle',
|
|
154
|
+
name: 'Finalizing installation',
|
|
155
|
+
startProgress: 85,
|
|
156
|
+
endProgress: 100
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
const getCurrentStage = () =>
|
|
161
|
+
stages.find((stage) => progress >= stage.startProgress && progress < stage.endProgress) ||
|
|
162
|
+
stages[stages.length - 1];
|
|
163
|
+
|
|
164
|
+
const getTimeRemaining = () => {
|
|
165
|
+
const remainingProgress = 100 - progress;
|
|
166
|
+
const estimatedMinutes = Math.max(1, Math.round((remainingProgress / 100) * 30)); // 30 minutes total simulation
|
|
167
|
+
return `About ${estimatedMinutes} minute${estimatedMinutes !== 1 ? 's' : ''} remaining`;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const getCurrentStageName = () => {
|
|
171
|
+
const currentStage = getCurrentStage();
|
|
172
|
+
return currentStage.name;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const getStageStatus = (stage: Stage) => {
|
|
176
|
+
if (progress >= stage.endProgress) {
|
|
177
|
+
return 'completed';
|
|
178
|
+
}
|
|
179
|
+
if (progress >= stage.startProgress) {
|
|
180
|
+
return 'in-progress';
|
|
181
|
+
}
|
|
182
|
+
return 'pending';
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const renderStageIcon = (stage: Stage) => {
|
|
186
|
+
const status = getStageStatus(stage);
|
|
187
|
+
|
|
188
|
+
if (status === 'completed') {
|
|
189
|
+
return <CheckCircleIcon color="green" aria-label="Complete" />;
|
|
190
|
+
} else if (status === 'in-progress') {
|
|
191
|
+
return <Spinner size="sm" aria-valuetext="In progress" />;
|
|
192
|
+
} else {
|
|
193
|
+
return <div style={{ width: 'var(--pf-t--global--spacer--md)' }}>{/* Empty space for pending stages */}</div>;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// Auto-increment progress when simulation is running
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
let interval;
|
|
200
|
+
|
|
201
|
+
if (isSimulationRunning && progress < 100) {
|
|
202
|
+
interval = setInterval(() => {
|
|
203
|
+
setProgress((prev) => {
|
|
204
|
+
const increment = Math.random() * 2 + 0.5; // Random increment between 0.5-2.5%
|
|
205
|
+
const newProgress = Math.min(prev + increment, 100);
|
|
206
|
+
|
|
207
|
+
// Stop simulation when complete
|
|
208
|
+
if (newProgress >= 100) {
|
|
209
|
+
setIsSimulationRunning(false);
|
|
210
|
+
setUserManuallyExpandedAccordion(false); // Reset manual override when simulation completes
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return newProgress;
|
|
214
|
+
});
|
|
215
|
+
}, 800);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return () => {
|
|
219
|
+
if (interval) {
|
|
220
|
+
clearInterval(interval);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}, [isSimulationRunning, progress]);
|
|
224
|
+
|
|
225
|
+
// Auto-expand accordion to show current stage (only if user hasn't manually overridden)
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (isSimulationRunning && !userManuallyExpandedAccordion) {
|
|
228
|
+
setIsAccordionExpanded(getCurrentStage().id);
|
|
229
|
+
}
|
|
230
|
+
}, [progress, isSimulationRunning, userManuallyExpandedAccordion]);
|
|
231
|
+
|
|
232
|
+
const onExpandCard = (_event: React.MouseEvent) => {
|
|
233
|
+
setIsCardExpanded(!isCardExpanded);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const onExpandAccordion = (id: string) => {
|
|
237
|
+
setUserManuallyExpandedAccordion(true);
|
|
238
|
+
|
|
239
|
+
if (id === isAccordionExpanded) {
|
|
240
|
+
setIsAccordionExpanded('');
|
|
241
|
+
} else {
|
|
242
|
+
setIsAccordionExpanded(id);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const getStageContent = (stage: Stage) => {
|
|
247
|
+
const status = getStageStatus(stage);
|
|
248
|
+
|
|
249
|
+
if (status === 'in-progress') {
|
|
250
|
+
switch (stage.id) {
|
|
251
|
+
case 'installing-toggle':
|
|
252
|
+
return `Installing bootstrap node...
|
|
253
|
+
Installing etcd cluster...
|
|
254
|
+
Installing control plane...`;
|
|
255
|
+
case 'setup-toggle':
|
|
256
|
+
return `Configuring cluster networking...
|
|
257
|
+
Setting up OpenShift API server...
|
|
258
|
+
Configuring authentication...
|
|
259
|
+
Setting up cluster operators...`;
|
|
260
|
+
case 'deploying-toggle':
|
|
261
|
+
return `Deploying openshift-apiserver operator...
|
|
262
|
+
Deploying openshift-sdn operator...
|
|
263
|
+
Deploying openshift-ingress operator...
|
|
264
|
+
`;
|
|
265
|
+
case 'finalizing-toggle':
|
|
266
|
+
return `Finalizing cluster configuration...
|
|
267
|
+
Running post-installation tasks...
|
|
268
|
+
Setting up cluster console...`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (status === 'pending') {
|
|
272
|
+
return 'Processing...';
|
|
273
|
+
}
|
|
274
|
+
return 'Complete!';
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const renderCodeBlock = (stage: Stage) => (
|
|
278
|
+
<CodeBlock
|
|
279
|
+
style={
|
|
280
|
+
{
|
|
281
|
+
'--pf-v6-c-code-block--BackgroundColor': 'var(--pf-t--color--gray--95)',
|
|
282
|
+
'--pf-v6-c-code-block--BorderRadius': 'var(--pf-t--global--border--radius--small)'
|
|
283
|
+
} as React.CSSProperties
|
|
284
|
+
}
|
|
285
|
+
>
|
|
286
|
+
<CodeBlockCode>{getStageContent(stage)}</CodeBlockCode>
|
|
287
|
+
</CodeBlock>
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
return (
|
|
291
|
+
<>
|
|
292
|
+
<Flex className="pf-v6-u-mt-lg" spaceItems={{ default: 'spaceItemsSm' }}>
|
|
293
|
+
<FlexItem>
|
|
294
|
+
<Button
|
|
295
|
+
variant="primary"
|
|
296
|
+
size="sm"
|
|
297
|
+
onClick={() => {
|
|
298
|
+
setProgress(15);
|
|
299
|
+
setIsSimulationRunning(true);
|
|
300
|
+
setUserManuallyExpandedAccordion(false);
|
|
301
|
+
}}
|
|
302
|
+
isDisabled={isSimulationRunning}
|
|
303
|
+
>
|
|
304
|
+
{isSimulationRunning ? 'Simulation running...' : 'Start simulation of cluster installation progress'}
|
|
305
|
+
</Button>
|
|
306
|
+
</FlexItem>
|
|
307
|
+
<FlexItem>
|
|
308
|
+
<Button
|
|
309
|
+
variant="secondary"
|
|
310
|
+
size="sm"
|
|
311
|
+
onClick={() => {
|
|
312
|
+
setIsSimulationRunning(false);
|
|
313
|
+
setProgress(15);
|
|
314
|
+
setIsAccordionExpanded('installing-toggle');
|
|
315
|
+
setUserManuallyExpandedAccordion(false);
|
|
316
|
+
}}
|
|
317
|
+
>
|
|
318
|
+
Reset
|
|
319
|
+
</Button>
|
|
320
|
+
</FlexItem>
|
|
321
|
+
</Flex>
|
|
322
|
+
<Card ouiaId="BasicCard" isExpanded={isCardExpanded}>
|
|
323
|
+
<CardHeader
|
|
324
|
+
onExpand={onExpandCard}
|
|
325
|
+
isToggleRightAligned
|
|
326
|
+
toggleButtonProps={{
|
|
327
|
+
id: 'toggle-button1',
|
|
328
|
+
'aria-label': 'Details',
|
|
329
|
+
'aria-labelledby': 'expandable-card-title toggle-button1',
|
|
330
|
+
'aria-expanded': isCardExpanded
|
|
331
|
+
}}
|
|
332
|
+
>
|
|
333
|
+
<DescriptionList>
|
|
334
|
+
<DescriptionListGroup
|
|
335
|
+
style={
|
|
336
|
+
{
|
|
337
|
+
'--pf-v6-c-description-list__group--RowGap': 'var(--pf-t--global--spacer--md)'
|
|
338
|
+
} as React.CSSProperties
|
|
339
|
+
}
|
|
340
|
+
>
|
|
341
|
+
<DescriptionListTerm id="title-outside-progress-example-label">
|
|
342
|
+
OpenShift cluster installation
|
|
343
|
+
</DescriptionListTerm>
|
|
344
|
+
<DescriptionListDescription>
|
|
345
|
+
<Progress
|
|
346
|
+
aria-labelledby="title-outside-progress-example-label"
|
|
347
|
+
value={progress}
|
|
348
|
+
measureLocation={ProgressMeasureLocation.outside}
|
|
349
|
+
style={{ '--pf-v6-c-progress--GridGap': 'var(--pf-t--global--spacer--sm' } as React.CSSProperties}
|
|
350
|
+
helperText={
|
|
351
|
+
<Flex justifyContent={{ default: 'justifyContentSpaceBetween' }}>
|
|
352
|
+
<FlexItem>
|
|
353
|
+
<HelperText>
|
|
354
|
+
<HelperTextItem>
|
|
355
|
+
{progress >= 100 ? 'Installation complete!' : getCurrentStageName()}
|
|
356
|
+
</HelperTextItem>
|
|
357
|
+
</HelperText>
|
|
358
|
+
</FlexItem>
|
|
359
|
+
<FlexItem>
|
|
360
|
+
<HelperText>
|
|
361
|
+
{/* Progress was getting announced on VoiceOver constantly - this helps avoid that */}
|
|
362
|
+
<HelperTextItem aria-live="off">
|
|
363
|
+
{progress >= 100 ? 'Completed' : getTimeRemaining()}
|
|
364
|
+
</HelperTextItem>
|
|
365
|
+
</HelperText>
|
|
366
|
+
</FlexItem>
|
|
367
|
+
</Flex>
|
|
368
|
+
}
|
|
369
|
+
/>
|
|
370
|
+
</DescriptionListDescription>
|
|
371
|
+
</DescriptionListGroup>
|
|
372
|
+
</DescriptionList>
|
|
373
|
+
</CardHeader>
|
|
374
|
+
<CardExpandableContent>
|
|
375
|
+
<CardBody>
|
|
376
|
+
<hr className="pf-v6-u-mb-md" />
|
|
377
|
+
<Accordion
|
|
378
|
+
style={
|
|
379
|
+
{
|
|
380
|
+
'--pf-v6-c-accordion__expandable-content-body--PaddingBlockStart': 'var(--pf-t--global--spacer--md)',
|
|
381
|
+
'--pf-v6-c-accordion__expandable-content-body--PaddingBlockEnd': '0',
|
|
382
|
+
'--pf-v6-c-accordion__expandable-content-body--PaddingInlineStart': '0',
|
|
383
|
+
'--pf-v6-c-accordion__expandable-content-body--PaddingInlineEnd': '0',
|
|
384
|
+
'--pf-v6-c-accordion__expandable-content--BackgroundColor': 'initial',
|
|
385
|
+
'--pf-v6-c-accordion__expandable-content--Color': '#fff'
|
|
386
|
+
} as React.CSSProperties
|
|
387
|
+
}
|
|
388
|
+
>
|
|
389
|
+
{stages.map((stage) => (
|
|
390
|
+
<AccordionItem key={stage.id} isExpanded={isAccordionExpanded === stage.id}>
|
|
391
|
+
<AccordionToggle
|
|
392
|
+
onClick={() => {
|
|
393
|
+
onExpandAccordion(stage.id);
|
|
394
|
+
}}
|
|
395
|
+
id={stage.id}
|
|
396
|
+
>
|
|
397
|
+
<Flex spaceItems={{ default: 'spaceItemsSm' }} alignItems={{ default: 'alignItemsCenter' }}>
|
|
398
|
+
<FlexItem>{renderStageIcon(stage)}</FlexItem>
|
|
399
|
+
<FlexItem>{stage.name}</FlexItem>
|
|
400
|
+
</Flex>
|
|
401
|
+
</AccordionToggle>
|
|
402
|
+
<AccordionContent id={stage.id.replace('-toggle', '')}>{renderCodeBlock(stage)}</AccordionContent>
|
|
403
|
+
</AccordionItem>
|
|
404
|
+
))}
|
|
405
|
+
</Accordion>
|
|
406
|
+
</CardBody>
|
|
407
|
+
</CardExpandableContent>
|
|
408
|
+
<CardFooter>
|
|
409
|
+
<Button isBlock variant="tertiary" icon={<ArrowRightIcon />} iconPosition="end">
|
|
410
|
+
Open in console
|
|
411
|
+
</Button>
|
|
412
|
+
</CardFooter>
|
|
413
|
+
</Card>
|
|
414
|
+
</>
|
|
415
|
+
);
|
|
416
|
+
};
|
|
417
|
+
|
|
39
418
|
export const UserMessageWithExtraContent: FunctionComponent = () => (
|
|
40
419
|
<>
|
|
41
420
|
<Message
|
|
@@ -50,5 +429,24 @@ export const UserMessageWithExtraContent: FunctionComponent = () => (
|
|
|
50
429
|
endContent: <UserActionEndContent />
|
|
51
430
|
}}
|
|
52
431
|
/>
|
|
432
|
+
<Message
|
|
433
|
+
avatar={userAvatar}
|
|
434
|
+
name="User"
|
|
435
|
+
role="user"
|
|
436
|
+
content="This is a main message."
|
|
437
|
+
timestamp="1 hour ago"
|
|
438
|
+
extraContent={{
|
|
439
|
+
afterMainContent: <LiveProgressSummaryCard />
|
|
440
|
+
}}
|
|
441
|
+
/>
|
|
442
|
+
<Message
|
|
443
|
+
avatar={patternflyAvatar}
|
|
444
|
+
name="Bot"
|
|
445
|
+
role="bot"
|
|
446
|
+
content="All set! I've finished building the Discovery ISO. The next step is to download it and boot your hosts, which you can do using the summary card I've prepared for you:"
|
|
447
|
+
extraContent={{
|
|
448
|
+
endContent: downloadCard
|
|
449
|
+
}}
|
|
450
|
+
/>
|
|
53
451
|
</>
|
|
54
452
|
);
|