Skip to content

Commit 8036b28

Browse files
committed
feat: incorporate [email protected] support for Choice descriptions into <Ask/>
1 parent cf0a55c commit 8036b28

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed

Diff for: package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare/src/components/Ask.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import React from "react"
1818
import stripAnsi from "strip-ansi"
1919
import { Prompts, Tree } from "madwizard"
2020

21-
import { Ansi, Tooltip } from "@kui-shell/plugin-client-common"
21+
import { Ansi, Markdown, Tooltip } from "@kui-shell/plugin-client-common"
2222
import {
2323
ActionGroup,
2424
Button,
@@ -49,6 +49,9 @@ export type Ask<P extends Prompts.Prompt = Prompts.Prompt> = {
4949
/** Title for this ask */
5050
title: string
5151

52+
/** Description for this ask */
53+
description?: string
54+
5255
/** Model of what to ask the user */
5356
prompt: P
5457

@@ -119,7 +122,7 @@ export default class AskUI extends React.PureComponent<Props, State> {
119122
)
120123
}
121124

122-
private card(title: string, body: React.ReactNode) {
125+
private card(title: React.ReactNode, body: React.ReactNode) {
123126
return (
124127
<Card isPlain className="sans-serif">
125128
<CardHeader>
@@ -131,7 +134,10 @@ export default class AskUI extends React.PureComponent<Props, State> {
131134
<CardActions hasNoOffset>{this.actions()}</CardActions>
132135
</CardHeader>
133136

134-
<CardBody>{body}</CardBody>
137+
<CardBody>
138+
{title}
139+
{body}
140+
</CardBody>
135141
</Card>
136142
)
137143
}
@@ -267,18 +273,21 @@ export default class AskUI extends React.PureComponent<Props, State> {
267273
onFilter,
268274
"aria-labelledby": titleId,
269275
noResultsFoundText: "No matching choices",
270-
placeholderText: this.title(ask), // place the guidebook title here
276+
placeholderText: "",
271277
inlineFilterPlaceholderText: "Filter choices",
272278
onSelect: this._onSelect,
273279
onToggle: this._doNothing,
274280
toggleIndicator: <React.Fragment />,
275281
children: mkOptions(),
276282
}
283+
console.error("!!!!!!!!SSSS", ask)
284+
285+
const title = <Markdown nested source={`#### ${this.title(ask)}\n\n${ask.description || ""}`} />
277286

278287
return (
279288
<React.Fragment>
280289
<span id={titleId} hidden />
281-
{this.card(ask.title, <Select {...props} />)}
290+
{this.card(title, <Select {...props} />)}
282291
</React.Fragment>
283292
)
284293
}
@@ -299,7 +308,7 @@ export default class AskUI extends React.PureComponent<Props, State> {
299308
this._form = form
300309

301310
return this.card(
302-
ask.title,
311+
"",
303312
<Card>
304313
<CardHeader>
305314
<CardTitle>{this.title(ask)}</CardTitle>

Diff for: plugins/plugin-codeflare/src/components/AskingTerminal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default class AskingTerminal extends React.PureComponent<Props, State> {
203203
write((typeof choice === "string" ? choice : JSON.stringify(choice)) + "\n")
204204
}
205205
const prompt = msg.ask
206-
const ask = { title: prompt.name || "Make a Choice", prompt, onChoose }
206+
const ask = { title: prompt.name || "Make a Choice", description: prompt.description, prompt, onChoose }
207207
this.setState({ ask, status: "q&a" })
208208
}
209209
} catch (err) {

Diff for: plugins/plugin-codeflare/src/components/Guide.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class Guide extends React.PureComponent<Props, State> {
8585

8686
/** Guidebook runner presents a question to the user */
8787
private async onAsk(prompt: Prompts.Prompt, onChoose: (choice: ReturnType<Tree.AnsiUI["ask"]>) => void) {
88-
this.setState({ ask: { prompt, onChoose, title: prompt.name || "Make a Choice" } })
88+
this.setState({ ask: { prompt, onChoose, title: prompt.name || "Make a Choice", description: prompt.description } })
8989
}
9090

9191
private async init() {

Diff for: plugins/plugin-codeflare/web/scss/components/Ask/_index.scss

+17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@
2626
}
2727
}
2828

29+
@include Ask {
30+
.pf-c-select__toggle-text {
31+
text-align: left;
32+
}
33+
}
34+
35+
/** Title */
36+
@include Ask {
37+
.pf-c-select__toggle {
38+
/* This is the default <button> from PatternFly's <Select> */
39+
display: none;
40+
}
41+
.pf-c-card__body .pf-c-content {
42+
height: auto;
43+
}
44+
}
45+
2946
@include Ask {
3047
&,
3148
.pf-c-card {

Diff for: plugins/plugin-madwizard/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^1.7.3",
26+
"madwizard": "^1.8.1",
2727
"@guidebooks/store": "^0.17.4"
2828
}
2929
}

0 commit comments

Comments
 (0)