@@ -23,13 +23,11 @@ import {
2323 ActionGroup ,
2424 Button ,
2525 Card ,
26- CardActions ,
2726 CardBody ,
28- CardHeader ,
29- CardTitle ,
3027 Grid ,
3128 Form ,
3229 FormGroup ,
30+ Hint ,
3331 Select ,
3432 SelectGroup ,
3533 SelectProps ,
@@ -39,8 +37,9 @@ import {
3937} from "@patternfly/react-core"
4038
4139import 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"
4242import InfoIcon from "@patternfly/react-icons/dist/esm/icons/info-circle-icon"
43- import ChoiceIcon from "@patternfly/react-icons/dist/esm/icons/user-cog-icon"
4443
4544import "../../web/scss/components/Ask/_index.scss"
4645
@@ -60,12 +59,19 @@ export type Ask<P extends Prompts.Prompt = Prompts.Prompt> = {
6059}
6160
6261type Props = {
62+ /** Current prompt model */
6363 ask : Ask
64+
65+ /** onClick handler for the home button */
6466 home ( noninteractive ?: boolean ) : void
6567}
6668
6769type State = {
70+ /** User has selected from the Select */
6871 userSelection ?: string
72+
73+ /** User has opted for inline filters in the Select */
74+ hasInlineFilter ?: boolean
6975}
7076
7177/**
@@ -111,10 +117,21 @@ export default class AskUI extends React.PureComponent<Props, State> {
111117 }
112118 }
113119
120+ /** User has clicked on Filter icon */
121+ private readonly _toggleFilter = ( ) => this . setState ( ( curState ) => ( { hasInlineFilter : ! curState . hasInlineFilter } ) )
122+
114123 /** content to show in the upper right */
115124 private actions ( ) {
116125 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+
118135 < Tooltip markdown = { `### Home\n#### Jump back to the beginning\n\n⌘ or Alt-click to open a new window` } >
119136 < Button variant = "link" icon = { < HomeIcon /> } onClick = { this . _home } />
120137 </ Tooltip >
@@ -124,18 +141,12 @@ export default class AskUI extends React.PureComponent<Props, State> {
124141
125142 private card ( title : React . ReactNode , body : React . ReactNode ) {
126143 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" >
137145 < CardBody >
138- { title }
146+ < Hint actions = { this . actions ( ) } className = "somewhat-larger-text" >
147+ { title }
148+ </ Hint >
149+
139150 { body }
140151 </ CardBody >
141152 </ Card >
@@ -267,7 +278,7 @@ export default class AskUI extends React.PureComponent<Props, State> {
267278 isOpen : true ,
268279 isPlain : true ,
269280 isGrouped : true ,
270- hasInlineFilter : true ,
281+ hasInlineFilter : this . state . hasInlineFilter ,
271282 isInputValuePersisted : true ,
272283 isInputFilterPersisted : true ,
273284 onFilter,
@@ -280,9 +291,8 @@ export default class AskUI extends React.PureComponent<Props, State> {
280291 toggleIndicator : < React . Fragment /> ,
281292 children : mkOptions ( ) ,
282293 }
283- console . error ( "!!!!!!!!SSSS" , ask )
284294
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 || "" } ` } />
286296
287297 return (
288298 < React . Fragment >
@@ -308,34 +318,27 @@ export default class AskUI extends React.PureComponent<Props, State> {
308318 this . _form = form
309319
310320 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 >
339342 )
340343 }
341344
0 commit comments