-
Notifications
You must be signed in to change notification settings - Fork 370
feat(DualListSelector): add a Dual List Selector component #395
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
feat(DualListSelector): add a Dual List Selector component #395
Conversation
b15e46c
to
3cf32ac
Compare
@LaViro can you please rebase? thanks |
3cf32ac
to
7cac4ed
Compare
7cac4ed
to
5ae4a54
Compare
@patternfly/patternfly-react-ux Can someone self-assign to do the UX review please? |
Adding my comments from slack to here for everyone's visibility: I'm seeing some alignment issues at the top with the filter input colliding with the top of the pane. Additionally the select all checkbox is slightly lower than expected. Other than that it looks and functions very well. Nice work! |
Deploy preview for patternfly-react ready! Built with commit 5ae4a54 |
import DualList from './DualList'; | ||
import mockLists from './mockLists'; | ||
|
||
test('patternfly Icon is working', () => { |
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 test does not cover anything other than the initial render. The snapshot is also ~450 lines. Anything over ~30 lines tends to not be that useful since people just skip looking at them.
It would be better to test the actual logic of the component (sorting, filtering, moving, etc).
items={items} | ||
filterResults={filterResults} | ||
filterTerm={filterTerm} | ||
onChange={e => onItemChange(e)} |
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 can be written as onChange={onItemChange}
/> | ||
) : ( | ||
<div className="pf-dual-list-no-items"> | ||
{filterResults ? 'No items were found' : 'No items to show'} |
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.
these strings should be able to be passed in from props. That will enable localization/translation.
|
||
const DualListCounter = ({ selected, total }) => ( | ||
<strong> | ||
{selected} of {total} items selected |
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.
same with this. maybe make it something like props.getSelectedMessage(selected, total)
<input | ||
type="checkbox" | ||
name={item.name} | ||
onChange={e => onChange(e)} |
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.
onChange={onChange}
const DualListFilter = ({ onChange, side }) => ( | ||
<span className="pf-dual-list-filter"> | ||
<input | ||
onChange={e => onChange(e)} |
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.
onChange={onChange}
} | ||
} | ||
|
||
DualList.propTypes = { |
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.
It looks like currently, you can't do anything with the list values? It is all contained in local state. This needs to either be controlled by having the consumer manage the lists through callbacks and values or an onChange needs to be available. Controlled is a more work, but usually gives more freedom to the consumer.
@Rohoover thanks ! |
587d2a4
to
1c46f33
Compare
@LaViro |
@Rohoover |
@Rohoover I saw that in Foreman they use titles in the selectors: Should we add that option? |
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.
I agree with @Rohoover . Not sure that we have room nor do I think they add that much clarity, for example "All items" could be confusing if the list on the left is only a subset of items that are available to this task. |
@mcarrano |
3b2d915
to
b4faec7
Compare
This comment has been minimized.
This comment has been minimized.
b4faec7
to
2ca97d4
Compare
Should this component be added to the |
const isParent = itemsCopy[index].children; | ||
if (isParent) { | ||
// update the item's children check state. | ||
itemsCopy[index].children.forEach(child => { |
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 we abstract some of this logic out into testable functions?
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.
Could it wait for a follow up PR?
I think we should let users play with this component and get more feedback.
as I see it, the DualList
is kind of an helper to DualListControlled
as it receives all of data in a clean way.
I agree adding helpers to Dual List
could make things more clear,
though this means breaking many things right now and testing many use cases again.
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.
First up, appreciate the effort, it does show! much appreciated! But feel a re-evaluation around carrying props over to related components needs to take place.
Reasons:
- quite a few repeated props
- this does come across as an effort to avoid having to update multiple components, that is a valid reason, however...
- there are also misaligned props, for example
onChange
vsonItemChange
, see comments
Currently a few of these components simply reference other components' props. That can work in some cases, but...
Possible solutions:
It may be a little clearer if the props are either:
- redeclared in their respective components, granted that is a bit of extra around updating
- or the props all come from a single source instead of a multitude of components
- or another possibility is to look at passing the props down, instead of pulling them from a child. This could happen through a generic
...props
.- This also happens to work if the intention is to have a child only ever used internally
...ges/patternfly-3/patternfly-react/src/components/DualListSelector/components/DualListItem.js
Outdated
Show resolved
Hide resolved
.../patternfly-3/patternfly-react/src/components/DualListSelector/components/DualListHeading.js
Show resolved
Hide resolved
...es/patternfly-3/patternfly-react/src/components/DualListSelector/components/DualListItems.js
Outdated
Show resolved
Hide resolved
...ges/patternfly-3/patternfly-react/src/components/DualListSelector/components/DualListBody.js
Show resolved
Hide resolved
Thanks @cdcabrera !! |
fc02a58
to
e02768d
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
e02768d
to
c06ada8
Compare
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.
@LaViro addressed my review comments, so LGTM, but understand there may be other review comments which may need to be addressed -thanks
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
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.
Just a few basics around questions, and some minor syntax clean up. Overall, after this, looking good for me
packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js
Outdated
Show resolved
Hide resolved
packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js
Outdated
Show resolved
Hide resolved
packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js
Show resolved
Hide resolved
c06ada8
to
a6ebfa8
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
a6ebfa8
to
a06f862
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
Hey guys, fixed all of your suggestions, thanks |
a06f862
to
0593c6f
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
0593c6f
to
fcce2fe
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
fcce2fe
to
ebfa606
Compare
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
ebfa606
to
16dcf34
Compare
Hey guys, feel free to review now :) |
PatternFly-React preview: https://395-pr-patternfly-react-patternfly.surge.sh |
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 has been a ton of effort @LaViro and it shows kudos!
Just a few notes for a potential round two... looking forward to seeing some actions responses on/through storybook, and some expanded unit tests on those helpers. But going to defer to someone else on those aspects
sortBy: 'label', | ||
filterTerm: '', | ||
isMainChecked: false | ||
}); |
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.
note:
Default props in 2 locations, understand why it was done, but it's an indicator for a potential fail/frustration point for anyone trying to update this component.
At minimum a note or reference to this location needs to be called out possibly in the DualList.js
file around DualList.defaultProps = {
.
Others, of us, may want this to just be a reference to default props contained within the DualList
class with something like DualList.defaultProps.left
, I'll leave that up to you
packages/patternfly-3/patternfly-react/src/components/DualListSelector/helpers.js
Show resolved
Hide resolved
packages/patternfly-3/patternfly-react/src/components/DualListSelector/helpers.js
Show resolved
Hide resolved
packages/patternfly-3/patternfly-react/src/components/DualListSelector/helpers.js
Show resolved
Hide resolved
packages/patternfly-3/patternfly-react/src/components/DualListSelector/helpers.js
Show resolved
Hide resolved
Pleasure to work with you guys ! |
Add DualListSelector component with storybook and tests. fix #379
Storybook
Design