Skip to content

Conversation

@priley86
Copy link
Member

@priley86 priley86 commented Dec 23, 2017

What:
Ho, ho, ho PatternFly React! How about some Data Tables from Santa this year?? 🎅 🎄 🎁

This PR starts the data table contribution w/ Reactabular.

Reactabular is a very powerful library, one that I've barely scratched the surface of here...

Some initial things i've showcased here:

As one can see, this is an extremely flexible React table...

Some things I'd like to do soon...

  • Add pagination / pagination components
  • Add row selection example
  • Add column visibility filters example (just sets the hidden attribute on columns)
  • Add empty state abstractions when rows are empty or all data has been filtered
  • Add any a11y attributes we'd like...
  • Some general cleanup/extendability... (this was put together quite quickly)
  • maybe even ask @bebraw for some suggestions? he's on gitter a lot it seems ;)

Link to Storybook

Additional issues:
I am off on PTO until 1/3/2018. Maybe someone can review this in the meantime and provide any feedback?

cc: @jeff-phillips-18 @ohadlevy @jgiardino @yaacov @amirfefer @jtomasek

Merry Christmas!
image

@priley86 priley86 changed the title feat(tables): adds reactabular and patternfly tables examples WIP feat(tables): adds reactabular and patternfly tables examples Dec 23, 2017
@serenamarie125
Copy link
Member

Nice gift @priley86 🎁 🎄
🤶🏼 Merry Christmas

@bebraw
Copy link

bebraw commented Dec 26, 2017

Great to see Reactabular in action. Feel free to PR something to my README after merge so people find patternfly. 👍

@priley86
Copy link
Member Author

@bebraw will definitely reach back soon! many thanks for reactabular and being a terrific open source maintainer in the React community! 💯 🏅 👏 👏 👏

Copy link
Member

@ohadlevy ohadlevy left a comment

Choose a reason for hiding this comment

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

first of all - awesome :)
I've left a couple of questions in line. whats the next steps for this pr? (e.g. testsing etc)


// Point the transform to your rows. React state can work for this purpose
// but you can use a state manager as well.
const getSortingColumns = () => this.state.sortingColumns || {};
Copy link
Member

Choose a reason for hiding this comment

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

Should be props or state?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can probably provide as props which get converted to state (and tracked in componentWillRecieveProps) in a more abstract implementation. We can probably abstract a lot of this to save the consumer some typing in some use cases. Was thinking the same...

Copy link
Member Author

Choose a reason for hiding this comment

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

I.e I think some use cases will prefer something quite simple where client sorting is enabled via Boolean “sort” prop, and others more specific where we leave everything open to consumer as we do here. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think we can probably use Mike T's controlled HOC pattern for this. I will circle back once that's in. This is not super pressing just yet... you will have the option downstream.

sortingOrder,
selectedColumn,
}),
});
Copy link
Member

Choose a reason for hiding this comment

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

Nice, what about server side sorting?

Copy link

Choose a reason for hiding this comment

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

Technically Reactabular should allow that as there's nothing frontend specific in the sorting logic. I assume you would apply sort before hydrating the data.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ohadlevy good point. We can simply provide click callbacks when server side sorting/paging and ignore client paging/sortabular there. I am guessing we will have a lot of variety here so will keep it flexible.

@priley86
Copy link
Member Author

priley86 commented Jan 4, 2018

good morning, happy 2018 🍾

I've made a few updates here... and have a few questions.

  • rebased w/ feat(Form): Add form related components #131 as I needed a lot of Form components for the pagination. Can we try to merge that one soon?
  • broke this into three components: Table, DataTable, and Pagination. The reactabular-table implementation is light enough for basic tables it seems, and I have broken the smaller components into their stateless components which can be shared across. The Pagination row/client side paginator should be reusable for card view/list view/etc... thoughts?
  • I decided to mimic reactabular's pagination API, but self implement it. The react-pagify and reactabular pagination components are very different from our design, and are quite simple to write ourself. I left an example of client side sorting and an example of sorting+paging as to not conflate the two...thoughts on combining them or leaving them separate? I will write an example for server side sort/page next (it should be much simpler).
  • I noticed some styles for the DropdownButton component are different than the ones we have in Core for bootstrap-select. I made some minor tweaks, but I think we'll need some enhancements either here or in Core. @jgiardino do you mind playing around with the pagination "per page" dropdown css when you get a chance?

Some things I am still working on:

  • empty state
  • column visibility example
  • row selections
  • a11y attributes
  • server side example
  • possibly a "dumbed down/easy mode" component that does client side paging/sorting for you and accepts boolean sort args on each column. I don't know if it's worth doing this yet, but I know this use case will probably exist and make life easier for some...

Should we start looking at integrating Filter or a Toolbar next? My vote is to merge this PR first and do those after...

updated storybook is here:
https://rawgit.com/priley86/patternfly-react/reactabular-storybook/index.html

@jeff-phillips-18
Copy link
Member

@priley86 I think the toolbar/filter integration should be part of the demo app. We could write advanced storybook stories as well if that is desired.

@priley86
Copy link
Member Author

priley86 commented Jan 8, 2018

will rebase Forms + Empty State next and try to finish this one out...

@bkearney
Copy link

@priley86 @ohadlevy how close is this? I would like this for foreman version 1.18.

@priley86
Copy link
Member Author

priley86 commented Jan 10, 2018

@bkearney i'm going to post some updates here later today... here's what i've done locally:

  • rebased w/ latest
  • added a11y attributes
  • row selection example alongside page + sort example is added
  • refactored a bit to remove some reactabular dependencies and make them optionalDependencies (you only need sortabular if you are doing client side sorting, for example)
  • added some more useful stateless functional components to go alongside the table row selection cells

Just doing some local testing / cleanup at this point...

I will push this up shortly for review and we can decide if it's worth merging soon, although I prefer a few more days for review here. I think the main idea here is you will have a lot of flexibility on what you want to do (as server side sorting + paging is almost entirely on the downstream and can be simplified a great deal from client side sorting + paging). I plan to add examples of both of those this week to clarify the usage of reactabular... (as it's quite a bit different if doing things on the server). There are plenty of other use cases we can demonstrate, but I'll have to discuss those first.

Hope this gives some context but my aim is to have something ready to merge this week as to open up the door for downstreams to get started...

@priley86
Copy link
Member Author

i've updated w/ my latest local copy here. Still working on some of the things mentioned above, but this should give the idea.

updated storybook:
https://rawgit.com/priley86/patternfly-react/reactabular-storybook/index.html

FIRST: 'asc',
asc: 'desc',
desc: 'asc'
};
Copy link
Member Author

Choose a reason for hiding this comment

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

leaving this named constants.js for now... will circle back and update all of them in #159

},
transforms: [sortable],
formatters: [sortingFormat],
customFormatters: [sortableHeaderCell]
Copy link
Member Author

@priley86 priley86 Jan 10, 2018

Choose a reason for hiding this comment

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

customFormatters is only due to the fact that reactabular sortabular formatters do not appear to support wrapped formatters (there is a conflict when using the sort formatter + our own formatter causing sort click / onSort to not fire). I will follow up with @bebraw on this, as ideally, we can just support formatters: [sortingFormat, sortableHeaderCell]. I've mimicked this closely using my own custom formatter in addition to reactabular formatters for now.

@priley86
Copy link
Member Author

few more updates today:
2fd5c38

@priley86 priley86 changed the title WIP feat(tables): adds reactabular and patternfly tables examples feat(tables): adds reactabular and patternfly tables examples Jan 15, 2018
@priley86
Copy link
Member Author

i've added the following in my last commit:

  • Broke out PaginationRow components and added PaginationRowButtonGroup to extend ButtonGroup with .pagination-pf-pagesize class. I've also updated the PF Core PR for this here.
  • Made all data table formatters consumable/sharable. Formatters which rely on state have been moved to customFormatters so we can pass any arguments we'd like.
  • Added Server Side pagination example with mockServerApi. Reorganized stories to say "Client side" and "Server side" respectively. Logged server api actions in the Actions addon.
  • Added Table.Checkbox per Checkbox Support #119
  • Added more snapshots to ensure we have coverage of all new components

updated storybook:
https://rawgit.com/priley86/patternfly-react/reactabular-storybook/index.html

I'd like to merge this one soon as I have some other upcoming work this week (also this PR is growing quickly). I think we can revisit empty states in another story/another PR which integrates filters and toolbar too possibly?

@tstrachota
Copy link

@priley86 nope, that was all I found so far.

The "per page" text position is still wrong. Can you check it, please:
screenshot from 2018-01-24 14-34-48

@jeff-phillips-18
Copy link
Member

Alignment looks fine to me. I don't see the need for the   spacing looks fine without it.

@jgiardino
Copy link
Contributor

jgiardino commented Jan 26, 2018

I'm also not seeing issues with alignment (I checked Chrome, FF, and Safari). And I agree that we don't need the  .

@priley86
Copy link
Member Author

  • removed fixed space
  • rebased
  • redeployed SB

@jgiardino
Copy link
Contributor

I also checked just now with IE 10 & 11.

@tstrachota What browser and version were you using?

@tstrachota
Copy link

It turned out to be issue on my side. My pf-react master apparently wasn't up to date. The alignment is fine when I test the PR on top of the latest master.

I'm sorry for the confusion. 👍 to merge from my side. Good job @priley86 !

@priley86
Copy link
Member Author

thanks very much for the reviews and working through this one with me @tstrachota 👍

@jeff-phillips-18
Copy link
Member

Any further comments @jgiardino or anyone else or is this good to merge?

@jeff-phillips-18
Copy link
Member

Missed @jgiardino's LGTM above. Going to go ahead and merge this one. Been a long process, thanks @priley86 for all your work on this!

@jeff-phillips-18 jeff-phillips-18 merged commit e664275 into patternfly:master Jan 29, 2018
@jgiardino jgiardino removed the review label Jan 29, 2018
@tstrachota
Copy link

Good job everybody!

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.