Skip to content

Commit b429f84

Browse files
committed
chore: bump to the latest madwizard
also update bin/codeflare to use cli mode as the default, with `-u` as the popup option
1 parent 7bc9a5a commit b429f84

File tree

9 files changed

+230
-235
lines changed

9 files changed

+230
-235
lines changed

bin/codeflare

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ else
111111
export GUIDEBOOK_STORE=git
112112
fi
113113

114-
# check if the user wants us to run the headless version (currently
115-
# indicated by the -c option)
116-
while getopts "c" opt
114+
# check if the user wants us to run the graphical version (currently
115+
# indicated by the -u option)
116+
do_cli=1
117+
while getopts "u" opt
117118
do
118119
case $opt in
119-
(c) do_cli=1; shift; continue;;
120+
(u) do_cli=0; shift; continue;;
120121
esac
121122
done
122123

package-lock.json

Lines changed: 119 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@
7777
"printWidth": 120
7878
},
7979
"devDependencies": {
80-
"@kui-shell/builder": "11.5.0-dev-20220525-112639",
81-
"@kui-shell/proxy": "11.5.0-dev-20220525-112639",
82-
"@kui-shell/react": "11.5.0-dev-20220525-112639",
83-
"@kui-shell/webpack": "11.5.0-dev-20220525-112639",
80+
"@kui-shell/builder": "11.5.0-dev-20220525-173538",
81+
"@kui-shell/proxy": "11.5.0-dev-20220525-173538",
82+
"@kui-shell/react": "11.5.0-dev-20220525-173538",
83+
"@kui-shell/webpack": "11.5.0-dev-20220525-173538",
8484
"@playwright/test": "^1.22.2",
8585
"@types/debug": "^4.1.7",
8686
"@types/node": "14.11.8",
@@ -100,18 +100,18 @@
100100
},
101101
"dependencies": {
102102
"@kui-shell/client": "file:./plugins/plugin-client-default",
103-
"@kui-shell/core": "11.5.0-dev-20220525-112639",
104-
"@kui-shell/plugin-bash-like": "11.5.0-dev-20220525-112639",
105-
"@kui-shell/plugin-carbon-themes": "11.5.0-dev-20220525-112639",
106-
"@kui-shell/plugin-client-common": "11.5.0-dev-20220525-112639",
103+
"@kui-shell/core": "11.5.0-dev-20220525-173538",
104+
"@kui-shell/plugin-bash-like": "11.5.0-dev-20220525-173538",
105+
"@kui-shell/plugin-carbon-themes": "11.5.0-dev-20220525-173538",
106+
"@kui-shell/plugin-client-common": "11.5.0-dev-20220525-173538",
107107
"@kui-shell/plugin-codeflare": "file:./plugins/plugin-codeflare",
108-
"@kui-shell/plugin-core-support": "11.5.0-dev-20220525-112639",
109-
"@kui-shell/plugin-electron-components": "11.5.0-dev-20220525-112639",
110-
"@kui-shell/plugin-git": "11.5.0-dev-20220525-112639",
111-
"@kui-shell/plugin-kubectl": "11.5.0-dev-20220525-112639",
108+
"@kui-shell/plugin-core-support": "11.5.0-dev-20220525-173538",
109+
"@kui-shell/plugin-electron-components": "11.5.0-dev-20220525-173538",
110+
"@kui-shell/plugin-git": "11.5.0-dev-20220525-173538",
111+
"@kui-shell/plugin-kubectl": "11.5.0-dev-20220525-173538",
112112
"@kui-shell/plugin-madwizard": "file:./plugins/plugin-madwizard",
113-
"@kui-shell/plugin-patternfly4-themes": "11.5.0-dev-20220525-112639",
114-
"@kui-shell/plugin-proxy-support": "11.5.0-dev-20220525-112639",
115-
"@kui-shell/plugin-s3": "11.5.0-dev-20220525-112639"
113+
"@kui-shell/plugin-patternfly4-themes": "11.5.0-dev-20220525-173538",
114+
"@kui-shell/plugin-proxy-support": "11.5.0-dev-20220525-173538",
115+
"@kui-shell/plugin-s3": "11.5.0-dev-20220525-173538"
116116
}
117117
}

plugins/plugin-madwizard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^0.7.27"
26+
"madwizard": "^0.8.1"
2727
}
2828
}

plugins/plugin-madwizard/src/components/Guide.tsx

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,7 @@ import { i18n, Tab } from "@kui-shell/core"
2020
import { Card, CardResponse, Icons, Loading, Markdown } from "@kui-shell/plugin-client-common"
2121
import { ButtonProps, Chip, ChipGroup, Grid, GridItem, Progress, Tile, WizardStep } from "@patternfly/react-core"
2222

23-
import {
24-
Choice,
25-
Choices,
26-
CodeBlockProps,
27-
Status,
28-
Title,
29-
Description,
30-
OrderedGraph,
31-
extractTitle,
32-
extractDescription,
33-
sameGraph,
34-
order,
35-
compile,
36-
validate,
37-
findChoiceFrontier,
38-
wizardify,
39-
Wizard as WizardModel,
40-
ChoiceStep,
41-
isChoiceStep,
42-
TaskStep,
43-
isTaskStep,
44-
} from "madwizard"
23+
import { Graph, CodeBlock, Choices, Wizard as Wiz } from "madwizard"
4524

4625
import read from "../read"
4726
import Wizard from "./Wizard/KWizard"
@@ -51,37 +30,37 @@ import "@kui-shell/plugin-client-common/web/scss/components/Wizard/Guide.scss"
5130

5231
const strings = i18n("plugin-client-common", "code")
5332

54-
export type Props = Choices &
55-
Partial<Title> &
56-
Partial<Description> & {
33+
export type Props = Choices.Choices &
34+
Partial<CodeBlock.Title> &
35+
Partial<CodeBlock.Description> & {
5736
/** Enclosing Kui Tab */
5837
tab: Tab
5938

6039
/** markdown document id */
6140
uuid: string
6241

6342
/** Raw list of code blocks */
64-
blocks: CodeBlockProps[]
43+
blocks: CodeBlock.CodeBlockProps[]
6544

6645
/** Status of code blocks */
6746
// codeBlockResponses: CodeBlockResponseFn
6847
}
6948

70-
type State = Choices & {
49+
type State = Choices.Choices & {
7150
/** Internal error in rendering? */
7251
error?: unknown
7352

7453
/** Graph of code blocks to be executed */
75-
graph: OrderedGraph
54+
graph: Graph.OrderedGraph
7655

7756
/** Choice Frontier */
78-
frontier: ReturnType<typeof findChoiceFrontier>
57+
frontier: ReturnType<typeof Graph.findChoiceFrontier>
7958

8059
/** Instance of Wizard model */
81-
wizard: WizardModel
60+
wizard: Wiz.Wizard
8261

8362
/** validation status of each wizard step */
84-
wizardStepStatus: Status[]
63+
wizardStepStatus: Graph.Status[]
8564

8665
/** Which of `wizardStepStatus` to display (indexed from 1) */
8766
startAtStep: number
@@ -102,23 +81,23 @@ export default class Guide extends React.PureComponent<Props, State> {
10281
/**
10382
* TODO move to a more common location?
10483
*/
105-
private static isValidFrontier(frontier: ReturnType<typeof findChoiceFrontier>): boolean {
84+
private static isValidFrontier(frontier: ReturnType<typeof Graph.findChoiceFrontier>): boolean {
10685
return frontier.length > 0 && frontier.every((_) => (_.prereqs && _.prereqs.length > 0) || !!_.choice)
10786
}
10887

10988
private async init(props: Props, useTheseChoices?: State["choices"]) {
11089
const choices = useTheseChoices || props.choices
111-
const newGraph = await compile(props.blocks, choices, undefined, "sequence", props.title, props.description)
90+
const newGraph = await Graph.compile(props.blocks, choices, undefined, "sequence", props.title, props.description)
11291
choices.onChoice(this.onChoiceFromAbove)
11392

11493
this.setState((state) => {
115-
const noChangeToGraph = state && sameGraph(state.graph, newGraph)
94+
const noChangeToGraph = state && Graph.sameGraph(state.graph, newGraph)
11695

117-
const graph = noChangeToGraph ? state.graph : order(newGraph)
118-
const frontier = noChangeToGraph && state && state.frontier ? state.frontier : findChoiceFrontier(graph)
96+
const graph = noChangeToGraph ? state.graph : Graph.order(newGraph)
97+
const frontier = noChangeToGraph && state && state.frontier ? state.frontier : Graph.findChoiceFrontier(graph)
11998

12099
const startAtStep = state ? state.startAtStep : 1
121-
const wizard = wizardify(graph, { previous: state ? state.wizard : undefined })
100+
const wizard = Wiz.wizardify(graph, { previous: state ? state.wizard : undefined })
122101
const wizardStepStatus = noChangeToGraph && state ? state.wizardStepStatus : []
123102

124103
const isRunning = state ? state.isRunning : false
@@ -144,7 +123,7 @@ export default class Guide extends React.PureComponent<Props, State> {
144123
}
145124

146125
/** @return a UI component to visualize the given markdown source */
147-
private renderContent(source: TaskStep["step"]["content"]) {
126+
private renderContent(source: Wiz.TaskStep["step"]["content"]) {
148127
return (
149128
source &&
150129
this.stepContent(
@@ -165,7 +144,7 @@ export default class Guide extends React.PureComponent<Props, State> {
165144
}
166145

167146
/** A choice was made somewhere in the UI */
168-
private readonly onChoiceFromAbove = ({ choices }: Choices) => this.init(this.props, choices.clone())
147+
private readonly onChoiceFromAbove = ({ choices }: Choices.Choices) => this.init(this.props, choices.clone())
169148

170149
/**
171150
* A choice was made in *this* UI. The `this.props.choices.set()`
@@ -181,7 +160,7 @@ export default class Guide extends React.PureComponent<Props, State> {
181160
}
182161

183162
/** @return UI that offers the user a choice */
184-
private tilesForChoice(choice: Choice) {
163+
private tilesForChoice(choice: Graph.Choice) {
185164
return this.stepContent(
186165
<Grid hasGutter span={4}>
187166
{choice.choices.map((_) => {
@@ -206,7 +185,7 @@ export default class Guide extends React.PureComponent<Props, State> {
206185
)
207186
}
208187

209-
private withStatus(name: WizardStep["name"], status: Status) {
188+
private withStatus(name: WizardStep["name"], status: Graph.Status) {
210189
const icon = status && statusToIcon(status)
211190
if (icon) {
212191
return (
@@ -231,7 +210,7 @@ export default class Guide extends React.PureComponent<Props, State> {
231210
}
232211

233212
/** Add React `component` to the given choice step */
234-
private choiceUI({ status, step, graph }: ChoiceStep, isFirstChoice: boolean) {
213+
private choiceUI({ status, step, graph }: Wiz.ChoiceStep, isFirstChoice: boolean) {
235214
return {
236215
status,
237216
graph,
@@ -250,15 +229,15 @@ export default class Guide extends React.PureComponent<Props, State> {
250229
}
251230

252231
/** Add React `component` to the given task execution step */
253-
private taskUI({ status, step, graph }: TaskStep) {
232+
private taskUI({ status, step, graph }: Wiz.TaskStep) {
254233
return {
255234
status,
256235
graph,
257236
step: {
258237
name: step.name === "Missing title" ? <span className="red-text">{step.name}</span> : step.name,
259238
component: this.renderContent(step.content),
260239
stepNavItemProps: {
261-
children: this.wizardStepDescription(extractDescription(graph)),
240+
children: this.wizardStepDescription(Graph.extractDescription(graph)),
262241
},
263242
},
264243
}
@@ -268,13 +247,13 @@ export default class Guide extends React.PureComponent<Props, State> {
268247
private wizardSteps() {
269248
let isFirstChoice = true
270249
return this.state.wizard.reduce((uiSteps, _, idx, A) => {
271-
if (isChoiceStep(_)) {
250+
if (Wiz.isChoiceStep(_)) {
272251
const ui = this.choiceUI(_, isFirstChoice)
273252
isFirstChoice = false
274253
uiSteps.push(ui)
275-
} else if (isTaskStep(_)) {
254+
} else if (Wiz.isTaskStep(_)) {
276255
const previous = A[idx - 1]
277-
if (!previous || !isTaskStep(previous) || previous.step.name !== _.step.name) {
256+
if (!previous || !Wiz.isTaskStep(previous) || previous.step.name !== _.step.name) {
278257
// task steps with multiple code blocks... combine them into one ui step
279258
uiSteps.push(this.taskUI(_))
280259
}
@@ -287,7 +266,9 @@ export default class Guide extends React.PureComponent<Props, State> {
287266
Promise.all(
288267
steps.map(async (_, idx) => {
289268
if (!this.state.wizardStepStatus[idx] || this.state.wizardStepStatus[idx] === "blank") {
290-
const status = await validate(_.graph, { validator: (cmdline: string) => this.props.tab.REPL.qexec(cmdline) })
269+
const status = await Graph.validate(_.graph, {
270+
validator: (cmdline: string) => this.props.tab.REPL.qexec(cmdline),
271+
})
291272
if (status !== this.state.wizardStepStatus[idx]) {
292273
this.setState((curState) => ({
293274
wizardStepStatus: [
@@ -368,7 +349,7 @@ export default class Guide extends React.PureComponent<Props, State> {
368349
}
369350

370351
private wizardDescription() {
371-
const descriptionContent = extractDescription(this.state.graph)
352+
const descriptionContent = Graph.extractDescription(this.state.graph)
372353
return descriptionContent && <Markdown nested source={descriptionContent} />
373354
}
374355

@@ -377,7 +358,7 @@ export default class Guide extends React.PureComponent<Props, State> {
377358
}
378359

379360
private wizardTitle() {
380-
return extractTitle(this.state.graph)
361+
return Graph.extractTitle(this.state.graph)
381362
// {this.state.isRunning && <span className="small-left-pad">{statusToIcon('in-progress')}</span>}
382363
}
383364

0 commit comments

Comments
 (0)