Fixes #123 - add PaginationRow component#162
Fixes #123 - add PaginationRow component#162tstrachota wants to merge 1 commit intopatternfly:masterfrom tstrachota:pagination
Conversation
|
@tstrachota thanks for this - I am happy to compare/contrast with what I've started in #143. I'll try to accommodate anything I am missing here. Also - feel free to chime in with any issues... |
|
|
||
| import { MenuItem, DropdownButton } from '../../index'; | ||
|
|
||
| const defaultMessages = { |
There was a problem hiding this comment.
👍 . I like this addition of making the message text a parameter with default prop values. Will also add this in #143
There was a problem hiding this comment.
this is a must for i18n... so thanks again for this. I'll continue to be on the lookout for these kind of things.
|
|
||
| handleFormSubmit(e) { | ||
| this.setPage(this.state.pageChangeValue); | ||
| e.preventDefault(); |
There was a problem hiding this comment.
dont think it matters much (or at all), but I would make sure the browser doesn't submit first :)
There was a problem hiding this comment.
also, shouldn't we allow to execute a custom action? e.g. actually go fetch new data or something?
There was a problem hiding this comment.
ya i don't think we need to handle form submit... just handle the callback when the values change...and have the server go fetch it...and the send the props back down.
There was a problem hiding this comment.
It actually prevents the form from being submitted. I didn't find any way how to use onChange only, because it's triggered on every key-up -> you can't enter more than one-digit numbers.
this.setPage executes onPageSet callback that can be injected via props and used to trigger new data fetch.
|
Updated. |
| return ( | ||
| <div> | ||
| <form | ||
| className="content-view-pf-pagination clearfix" |
There was a problem hiding this comment.
To make this usable with a table view, we need a mechanism to add .table-view-pf-pagination here.
There was a problem hiding this comment.
I added a className prop to PaginationRow
| title={this.msg('firstPage')} | ||
| onClick={() => this.setPage(1)} | ||
| > | ||
| <span className="i fa fa-angle-double-left" /> |
There was a problem hiding this comment.
This and others following can use the <Icon> component.
| currentPage: PropTypes.number.isRequired, | ||
| onPerPageSet: PropTypes.func, | ||
| onPageSet: PropTypes.func, | ||
| messages: PropTypes.object |
There was a problem hiding this comment.
Can we add comments to show the list messages in storybook?
|
Updated. I also added a storybook example with messages. |
Can you provide a link to the storybook as detailed here: https://github.com/patternfly/patternfly-react/#storybook-ui-development |
sharvit
left a comment
There was a problem hiding this comment.
Thanks @tstrachota, looks pretty good!
Can you deploy the storybook please?
|
|
||
| const ArrowIcon = props => { | ||
| const name = `angle-${props.name}`; | ||
| return <Icon type="fa" name={name} className="i" />; |
There was a problem hiding this comment.
Can you move the ArrowIcon into src/components/PaginationRow/InnerComponents/ArrowIcon.js as described here:
https://github.com/patternfly/patternfly-react/blob/master/CONTRIBUTING.md#code-consistency
| onPageSet: p => {}, | ||
| onPerPageSet: pp => {}, | ||
| messages: {}, | ||
| className: 'content-view-pf-pagination' |
There was a problem hiding this comment.
Passing a className will override the content-view-pf-pagination, shouldn't it always be there?
Checkout this pr #163
You can add another prop called baseClassName that can have content-view-pf-pagination as default value.
So consumers can add more classes when using className and override the base class when passing baseClassName.
| /** A callback triggered when a page is switched */ | ||
| onPageSet: PropTypes.func, | ||
| /** Strings in the component, see PaginationRow.defaultMessages for details */ | ||
| messages: PropTypes.object, |
There was a problem hiding this comment.
Can you use PropTypes.shape here?
|
|
||
| stories.addWithInfo('With translations', '', () => { | ||
| var messages = {}; | ||
| for (var key in PaginationRow.defaultMessages) { |
There was a problem hiding this comment.
In today javascript, we should never use for...in syntax again, it is actually danger.
Please use for...of which is an es2015 syntax.
https://www.eventbrite.com/engineering/learning-es6-for-of-loop/
|
@tstrachota what are your thoughts on the pagination row being done as part of #75? Does that remove the need for this PR? Does that contain everything you wanted from this PR? |
|
@jeff-phillips-18 Did you mean #143? |
|
@jeff-phillips-18 I'd like to send as PR into @priley86's branch that adds my functionality on the top of his components. |
|
Ok @tstrachota sounds good. Once that is done, can you close this PR? |
|
OK, @priley86 copied my code to his branch over my PTO. There's no sense in doing the PR now. I give up. Closing this PR. Will at least try to review the other PR. |
Adds
PaginationRowcomponent that implements Patternfly pagination:https://rawgit.com/patternfly/patternfly/master-dist/dist/tests/pagination.html
Usage: