@@ -20,7 +20,7 @@ import { i18n, Tab } from "@kui-shell/core"
20
20
import { Card , CardResponse , Icons , Loading , Markdown } from "@kui-shell/plugin-client-common"
21
21
import { ButtonProps , Chip , ChipGroup , Grid , GridItem , Progress , Tile , WizardStep } from "@patternfly/react-core"
22
22
23
- import { Graph , CodeBlock , Choices , Wizard as Wiz } from "madwizard"
23
+ import { Graph , CodeBlock , Choices , Memoizer , Wizard as Wiz } from "madwizard"
24
24
25
25
import read from "../read"
26
26
import Wizard from "./Wizard/KWizard"
@@ -72,6 +72,7 @@ type State = Choices.Choices & {
72
72
export default class Guide extends React . PureComponent < Props , State > {
73
73
private readonly choiceIcon1 = ( < Icons className = "yellow-text" icon = "Warning" /> )
74
74
private readonly choiceIcon2 = ( < Icons icon = "PlusSquare" /> )
75
+ private readonly memos = new Memoizer ( )
75
76
76
77
public constructor ( props : Props ) {
77
78
super ( props )
@@ -87,7 +88,7 @@ export default class Guide extends React.PureComponent<Props, State> {
87
88
88
89
private async init ( props : Props , useTheseChoices ?: State [ "choices" ] ) {
89
90
const choices = useTheseChoices || props . choices
90
- const newGraph = await Graph . compile ( props . blocks , choices , undefined , "sequence" , props . title , props . description )
91
+ const newGraph = await Graph . compile ( props . blocks , choices , this . memos , undefined , "sequence" , props . title , props . description )
91
92
choices . onChoice ( this . onChoiceFromAbove )
92
93
93
94
this . setState ( ( state ) => {
@@ -97,7 +98,7 @@ export default class Guide extends React.PureComponent<Props, State> {
97
98
const frontier = noChangeToGraph && state && state . frontier ? state . frontier : Graph . findChoiceFrontier ( graph )
98
99
99
100
const startAtStep = state ? state . startAtStep : 1
100
- const wizard = Wiz . wizardify ( graph , { previous : state ? state . wizard : undefined } )
101
+ const wizard = Wiz . wizardify ( graph , this . memos , { previous : state ? state . wizard : undefined } )
101
102
const wizardStepStatus = noChangeToGraph && state ? state . wizardStepStatus : [ ]
102
103
103
104
const isRunning = state ? state . isRunning : false
@@ -266,7 +267,7 @@ export default class Guide extends React.PureComponent<Props, State> {
266
267
Promise . all (
267
268
steps . map ( async ( _ , idx ) => {
268
269
if ( ! this . state . wizardStepStatus [ idx ] || this . state . wizardStepStatus [ idx ] === "blank" ) {
269
- const status = await Graph . validate ( _ . graph , {
270
+ const status = await Graph . validate ( _ . graph , this . memos , {
270
271
validator : ( cmdline : string ) => this . props . tab . REPL . qexec ( cmdline ) ,
271
272
} )
272
273
if ( status !== this . state . wizardStepStatus [ idx ] ) {
0 commit comments