@@ -23,13 +23,11 @@ import {
23
23
ActionGroup ,
24
24
Button ,
25
25
Card ,
26
- CardActions ,
27
26
CardBody ,
28
- CardHeader ,
29
- CardTitle ,
30
27
Grid ,
31
28
Form ,
32
29
FormGroup ,
30
+ Hint ,
33
31
Select ,
34
32
SelectGroup ,
35
33
SelectProps ,
@@ -39,8 +37,9 @@ import {
39
37
} from "@patternfly/react-core"
40
38
41
39
import HomeIcon from "@patternfly/react-icons/dist/esm/icons/home-icon"
40
+ import FilterIcon from "@patternfly/react-icons/dist/esm/icons/filter-icon"
41
+ import FilterAltIcon from "@patternfly/react-icons/dist/esm/icons/filter-alt-icon"
42
42
import InfoIcon from "@patternfly/react-icons/dist/esm/icons/info-circle-icon"
43
- import ChoiceIcon from "@patternfly/react-icons/dist/esm/icons/user-cog-icon"
44
43
45
44
import "../../web/scss/components/Ask/_index.scss"
46
45
@@ -60,12 +59,19 @@ export type Ask<P extends Prompts.Prompt = Prompts.Prompt> = {
60
59
}
61
60
62
61
type Props = {
62
+ /** Current prompt model */
63
63
ask : Ask
64
+
65
+ /** onClick handler for the home button */
64
66
home ( noninteractive ?: boolean ) : void
65
67
}
66
68
67
69
type State = {
70
+ /** User has selected from the Select */
68
71
userSelection ?: string
72
+
73
+ /** User has opted for inline filters in the Select */
74
+ hasInlineFilter ?: boolean
69
75
}
70
76
71
77
/**
@@ -111,10 +117,21 @@ export default class AskUI extends React.PureComponent<Props, State> {
111
117
}
112
118
}
113
119
120
+ /** User has clicked on Filter icon */
121
+ private readonly _toggleFilter = ( ) => this . setState ( ( curState ) => ( { hasInlineFilter : ! curState . hasInlineFilter } ) )
122
+
114
123
/** content to show in the upper right */
115
124
private actions ( ) {
116
125
return (
117
- < ActionGroup className = "kui--guide-actions" >
126
+ < ActionGroup >
127
+ < Tooltip content = { this . state . hasInlineFilter ? `Disable filter` : `Enable filter` } >
128
+ < Button
129
+ variant = "link"
130
+ icon = { this . state . hasInlineFilter ? < FilterAltIcon /> : < FilterIcon /> }
131
+ onClick = { this . _toggleFilter }
132
+ />
133
+ </ Tooltip >
134
+
118
135
< Tooltip markdown = { `### Home\n#### Jump back to the beginning\n\n⌘ or Alt-click to open a new window` } >
119
136
< Button variant = "link" icon = { < HomeIcon /> } onClick = { this . _home } />
120
137
</ Tooltip >
@@ -124,18 +141,12 @@ export default class AskUI extends React.PureComponent<Props, State> {
124
141
125
142
private card ( title : React . ReactNode , body : React . ReactNode ) {
126
143
return (
127
- < Card isPlain className = "sans-serif" >
128
- < CardHeader >
129
- < CardTitle >
130
- < div className = "flex-layout" >
131
- < ChoiceIcon className = "larger-text slightly-deemphasize small-right-pad" /> Configure
132
- </ div >
133
- </ CardTitle >
134
- < CardActions hasNoOffset > { this . actions ( ) } </ CardActions >
135
- </ CardHeader >
136
-
144
+ < Card isLarge isPlain className = "sans-serif" >
137
145
< CardBody >
138
- { title }
146
+ < Hint actions = { this . actions ( ) } className = "somewhat-larger-text" >
147
+ { title }
148
+ </ Hint >
149
+
139
150
{ body }
140
151
</ CardBody >
141
152
</ Card >
@@ -267,7 +278,7 @@ export default class AskUI extends React.PureComponent<Props, State> {
267
278
isOpen : true ,
268
279
isPlain : true ,
269
280
isGrouped : true ,
270
- hasInlineFilter : true ,
281
+ hasInlineFilter : this . state . hasInlineFilter ,
271
282
isInputValuePersisted : true ,
272
283
isInputFilterPersisted : true ,
273
284
onFilter,
@@ -280,9 +291,8 @@ export default class AskUI extends React.PureComponent<Props, State> {
280
291
toggleIndicator : < React . Fragment /> ,
281
292
children : mkOptions ( ) ,
282
293
}
283
- console . error ( "!!!!!!!!SSSS" , ask )
284
294
285
- const title = < Markdown nested source = { `#### ${ this . title ( ask ) } \n\n${ ask . description || "" } ` } />
295
+ const title = < Markdown nested source = { `### ${ this . title ( ask ) } \n\n${ ask . description || "" } ` } />
286
296
287
297
return (
288
298
< React . Fragment >
@@ -308,34 +318,27 @@ export default class AskUI extends React.PureComponent<Props, State> {
308
318
this . _form = form
309
319
310
320
return this . card (
311
- "" ,
312
- < Card >
313
- < CardHeader >
314
- < CardTitle > { this . title ( ask ) } </ CardTitle >
315
- </ CardHeader >
316
- < CardBody >
317
- < Form onSubmit = { this . _onFormSubmit } >
318
- < Grid hasGutter md = { 6 } >
319
- { ask . prompt . choices . map ( ( _ ) => (
320
- < FormGroup isRequired key = { _ . name } label = { _ . name } >
321
- < TextInput
322
- aria-label = { `text-input-${ _ . name } ` }
323
- isRequired
324
- value = { form [ _ . name ] }
325
- onChange = { ( value ) => ( form [ _ . name ] = value ) }
326
- />
327
- </ FormGroup >
328
- ) ) }
329
- </ Grid >
330
-
331
- < ActionGroup >
332
- < Button variant = "primary" type = "submit" >
333
- Next
334
- </ Button >
335
- </ ActionGroup >
336
- </ Form >
337
- </ CardBody >
338
- </ Card >
321
+ this . title ( ask ) ,
322
+ < Form onSubmit = { this . _onFormSubmit } className = "top-pad" >
323
+ < Grid hasGutter md = { 6 } >
324
+ { ask . prompt . choices . map ( ( _ ) => (
325
+ < FormGroup isRequired key = { _ . name } label = { _ . name } >
326
+ < TextInput
327
+ aria-label = { `text-input-${ _ . name } ` }
328
+ isRequired
329
+ value = { form [ _ . name ] }
330
+ onChange = { ( value ) => ( form [ _ . name ] = value ) }
331
+ />
332
+ </ FormGroup >
333
+ ) ) }
334
+ </ Grid >
335
+
336
+ < ActionGroup >
337
+ < Button variant = "primary" type = "submit" >
338
+ Next
339
+ </ Button >
340
+ </ ActionGroup >
341
+ </ Form >
339
342
)
340
343
}
341
344
0 commit comments