Skip to content

Conversation

@tstrachota
Copy link

Adds PaginationRow component that implements Patternfly pagination:
https://rawgit.com/patternfly/patternfly/master-dist/dist/tests/pagination.html

Usage:

<PaginationRow
    totalCount={75}
    perPage={10}
    currentPage={2}
    perPageOptions={[5, 10, 15]}
    onPageSet={action('page set')}
    onPerPageSet={action('per page value set')}
/>

@priley86
Copy link
Member

@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 = {
Copy link
Member

@priley86 priley86 Jan 11, 2018

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

Copy link
Member

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();
Copy link
Member

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 :)

Copy link
Member

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?

Copy link
Member

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.

Copy link
Author

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.

@tstrachota
Copy link
Author

Updated. handlePageChange was raising exception for undefined this.

return (
<div>
<form
className="content-view-pf-pagination clearfix"
Copy link
Member

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.

Copy link
Author

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" />
Copy link
Member

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
Copy link
Member

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?

@tstrachota
Copy link
Author

Updated. I also added a storybook example with messages.

@waldenraines
Copy link

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

Copy link
Contributor

@sharvit sharvit left a 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" />;
Copy link
Contributor

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

Copy link
Member

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'
Copy link
Contributor

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.

Copy link
Member

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,
Copy link
Contributor

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?

Copy link
Member

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) {
Copy link
Contributor

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/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@jeff-phillips-18
Copy link
Member

@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?

@jgiardino
Copy link
Contributor

@jeff-phillips-18 Did you mean #143?
Is the pagination in that example specific to tables @priley86, or could it be reused for other views, like the list view?

@jeff-phillips-18
Copy link
Member

Yes, sorry #143 (we should probably close #75)

@tstrachota
Copy link
Author

@jeff-phillips-18 I'd like to send as PR into @priley86's branch that adds my functionality on the top of his components.

@jeff-phillips-18
Copy link
Member

Ok @tstrachota sounds good. Once that is done, can you close this PR?

@tstrachota
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants