Skip to content

Commit a6e056d

Browse files
authored
Merge pull request patternfly#356 from kmcfaul/qs-chatbot-support
feat(misc): chatbot support
2 parents f8d2f0e + 8d392e2 commit a6e056d

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

packages/module/src/QuickStartController.tsx

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import * as React from 'react';
22
import QuickStartContent from './controller/QuickStartContent';
33
import QuickStartFooter from './controller/QuickStartFooter';
4-
import { QuickStartContext, QuickStartContextValues } from './utils/quick-start-context';
4+
import {
5+
getDefaultQuickStartState,
6+
QuickStartContext,
7+
QuickStartContextValues,
8+
} from './utils/quick-start-context';
59
import { QuickStart, QuickStartStatus, QuickStartTaskStatus } from './utils/quick-start-types';
610

711
interface QuickStartControllerProps {
12+
/** The current active quickstart */
813
quickStart: QuickStart;
14+
/** The next quickstart */
915
nextQuickStarts?: QuickStart[];
10-
footerClass: string;
11-
contentRef: React.Ref<HTMLDivElement>;
16+
/** Additional footer classes */
17+
footerClass?: string;
18+
/** Ref for the quickstart content */
19+
contentRef?: React.Ref<HTMLDivElement>;
1220
}
1321

14-
const QuickStartController: React.FC<QuickStartControllerProps> = ({
22+
export const QuickStartController: React.FC<QuickStartControllerProps> = ({
1523
quickStart,
1624
nextQuickStarts,
1725
contentRef,
@@ -23,13 +31,26 @@ const QuickStartController: React.FC<QuickStartControllerProps> = ({
2331
} = quickStart;
2432
const totalTasks = tasks?.length;
2533
const {
34+
activeQuickStartID,
35+
allQuickStartStates,
36+
setAllQuickStartStates,
2637
activeQuickStartState,
2738
setActiveQuickStart,
2839
setQuickStartTaskNumber,
2940
setQuickStartTaskStatus,
3041
nextStep,
3142
previousStep,
3243
} = React.useContext<QuickStartContextValues>(QuickStartContext);
44+
React.useEffect(() => {
45+
// If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
46+
if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
47+
setAllQuickStartStates({
48+
...allQuickStartStates,
49+
[activeQuickStartID]: getDefaultQuickStartState(),
50+
});
51+
}
52+
}, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
53+
3354
const status = activeQuickStartState?.status as QuickStartStatus;
3455
const taskNumber = activeQuickStartState?.taskNumber as number;
3556
const allTaskStatuses = tasks.map(

packages/module/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './QuickStartCatalogPage';
44
export * from './catalog';
55
export * from './ConsoleInternal/components/utils';
66
export * from './QuickStartContainer';
7+
export * from './QuickStartController';
78
export * from './QuickStartDrawer';
89
export * from './QuickStartDrawerContent';
910
export * from './QuickStartCloseModal';

0 commit comments

Comments
 (0)