-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: Introduce our own TypeaheadSelect and use it everywhere #21175
lib: Introduce our own TypeaheadSelect and use it everywhere #21175
Conversation
c483dff
to
f59da49
Compare
f59da49
to
dc0e059
Compare
cb132d7
to
2f4974d
Compare
48f1985
to
5e6acf0
Compare
3d62c7d
to
b116924
Compare
I am happy with the huge coverage holes. shrug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the courage and work to address this long-outstanding porting!
I'm not thrilled by the code copy, but I agree it's a nice way to see what we need, and then spoon-feed it to upstream PRs. One hard blocker, and a bunch of nitpicks/questions.
{...(!(isFiltering && filterValue) && !selected ? { style: { display: 'none' } } : {})} | ||
{...(!(isFiltering && filterValue) && !(props.selected && onClearSelection) ? { style: { display: 'none' } } : {})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also feels like a straight upstreamable fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a fix... I have to admit I am not super sure how the Clear button is supposed to behave... I'll submit it.
b.set_file_autocomplete_val("#demo-upload", "/root/") | ||
b.set_file_autocomplete_val("#demo-upload", "/var/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the path change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/root is not listable by admin, and our FileAutocomplete widget shows an error and doesn't let us select /root. Previously, it was possible to make any value stick as the selected value just by closing the dropdown (regardless of whether it exists, or an error occurred, even for !isCreatable
). I consider that a bug, actually.
Now this is no longer possible and we need to use something that can be selected from the dropdown, but not be written to by admin. Also, we need to use something that is not a read-only filesystem on CoreOs.
So there are bugs here still to be fixed, I guess:
- FileAutocomplete should probably not prevent the user from selecting a directory that can't be listed.
- The upload machinery or the test here don't react correctly to a read-only filesystem, only to read-only permission bits.
From 09b16829dcad32650412a66b7145ef8e7552c418.
0186e3b
to
5a2b13d
Compare
And avoid duplicate entries.
5a2b13d
to
d425295
Compare
from gratuitous upstream changes. | ||
*/ | ||
|
||
/* eslint-disable */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be restricted to whitespace errors, or is that too messy? Most other eslint complaints are rather useful
onSelect={(_, value) => { | ||
this.setState({ value }); | ||
this.onPathChange(value); | ||
this.props.onChange(value || '', null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
}} | ||
onClearSelection={this.clearSelection} | ||
isCreatable={this.props.isOptionCreatable} | ||
createOptionMessage={val => cockpit.format(_("Create $0"), val)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
const NO_RESULTS = 'no results'; | ||
|
||
if (isCreatable && !createOptionMessage) | ||
throw "isCreatable requires createOptionMessage"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
!newSelectOptions.find((o) => String(o.content).toLowerCase() === filterValue.toLowerCase()) | ||
) { | ||
const createOption = { | ||
content: typeof createOptionMessage === 'string' ? createOptionMessage : createOptionMessage(filterValue), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
value: filterValue | ||
}; | ||
newSelectOptions = isCreateOptionOnTop | ||
? [createOption, ...newSelectOptions] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
isOpen={isOpen} | ||
selected={selected} | ||
onSelect={_onSelect} | ||
onOpenChange={(isOpen) => !isOpen && closeMenu()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
<SelectList> | ||
{filteredSelections.map((option, index) => { | ||
if (option.divider) | ||
return <Divider key={option.key || index} component="li" />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
<TypeaheadSelect toggleProps={ { id: "systime-timezones" } } | ||
isScrollable | ||
selected={time_zone} | ||
onSelect={(event, value) => { change("time_zone", value) }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
createOptionMessage={val => cockpit.format(_("Use $0"), val)} | ||
selected={value} | ||
onSelect={(_, value) => change(value)} | ||
onClearSelection={() => change("")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
selected={identifiersFilter} | ||
selectedIsTrusted | ||
onSelect={(e, selection) => { onIdentifiersFilterChange(selection) }} | ||
onClearSelection={identifiersFilter != "all" && (() => { onIdentifiersFilterChange("all") })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates! Frankly this looks great to me now, definitively an improvement over using the deprecated component.
#21175 (comment) still mentions some potential bug fixes, but I think these aren't regressions, but follow-ups?
Yes. |
Pixel changes