Skip to content

Commit e737969

Browse files
committed
fix: ui refinements to ProfileExplorer and Ask
In Ask, don't use card header "Configure". Use Hint for title. Place Home icon in Hint. Don't show filter for Select by default. Add filter toggle action to Hint. Add description to ui for choices. In ProfileExplorer, don't use larger font size for action buttons.
1 parent 809f30f commit e737969

File tree

2 files changed

+64
-53
lines changed

2 files changed

+64
-53
lines changed

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

+50-47
Original file line numberDiff line numberDiff line change
@@ -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

4139
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"
4242
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"
4443

4544
import "../../web/scss/components/Ask/_index.scss"
4645

@@ -60,12 +59,19 @@ export type Ask<P extends Prompts.Prompt = Prompts.Prompt> = {
6059
}
6160

6261
type Props = {
62+
/** Current prompt model */
6363
ask: Ask
64+
65+
/** onClick handler for the home button */
6466
home(noninteractive?: boolean): void
6567
}
6668

6769
type 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

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,16 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
542542
}
543543
this.sort(data)
544544

545-
return <TreeView hasGuides defaultAllExpanded data={data} variant="compact" toolbar={this.title()} />
545+
return (
546+
<TreeView
547+
defaultAllExpanded={this.state.editable}
548+
hasBadges
549+
hasGuides
550+
data={data}
551+
variant="compact"
552+
toolbar={this.title()}
553+
/>
554+
)
546555
}
547556

548557
return <Loading />
@@ -570,7 +579,7 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
570579
<Flex flexWrap={this.nowrap} justifyContent={this.flexEnd}>
571580
<FlexItem flex={this.flex1}>
572581
<Tooltip position="top" content="Create a new profile">
573-
<Button variant="link" className="larger-text" icon={<PlusSquareIcon />} onClick={this._onNew} />
582+
<Button variant="link" icon={<PlusSquareIcon />} onClick={this._onNew} />
574583
</Tooltip>
575584
</FlexItem>
576585

@@ -585,16 +594,15 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
585594
>
586595
<Button
587596
variant="link"
588-
className="larger-text"
589597
icon={this.state.editable ? <LockOpenIcon /> : <LockIcon />}
590598
onClick={this._onToggleEditable}
591599
/>
592600
</Tooltip>
593601
<Tooltip position="top" content="Reset the choices in this profile">
594-
<Button variant="link" className="larger-text" icon={<EraserIcon />} onClick={this._onReset} />
602+
<Button variant="link" icon={<EraserIcon />} onClick={this._onReset} />
595603
</Tooltip>
596604
<Tooltip position="top" content="Delete this profile">
597-
<Button variant="link" className="larger-text" icon={<TrashIcon />} onClick={this._onDelete} />
605+
<Button variant="link" icon={<TrashIcon />} onClick={this._onDelete} />
598606
</Tooltip>
599607
</FlexItem>
600608
</Flex>
@@ -603,7 +611,7 @@ class ProfileCard extends React.PureComponent<ProfileCardProps, ProfileCardState
603611

604612
public render() {
605613
return (
606-
<Card isPlain>
614+
<Card isLarge isPlain>
607615
<CardHeader>
608616
<CardTitle>
609617
<div className="flex-layout">

0 commit comments

Comments
 (0)