-
Notifications
You must be signed in to change notification settings - Fork 378
Fixes #123 - add PaginationRow component #162
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 . 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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 think we can expose it ;)
| onPageSet: p => {}, | ||
| onPerPageSet: pp => {}, | ||
| messages: {}, | ||
| className: 'content-view-pf-pagination' |
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.
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.
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.
+1
| /** 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use PropTypes.shape here?
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.
+1
|
|
||
| stories.addWithInfo('With translations', '', () => { | ||
| var messages = {}; | ||
| for (var key in PaginationRow.defaultMessages) { |
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.
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/
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.
+1
|
@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: