Skip to content
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

Convert EuiTableOfRecords to simpler table component in scripted fields table. #16901

Merged
merged 4 commits into from
Mar 9, 2018

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Feb 23, 2018

Switching to EuiBasicTable results in a 12% reduction in code... not bad.
Aaaaand switching to EuiInMemoryTable reduced the code by 48%.

@cjcenizal cjcenizal changed the title Convert EuiTableOfRecords to EuiBasicTable in scripted fields table. Convert EuiTableOfRecords to simpler table component in scripted fields table. Feb 23, 2018
@cjcenizal cjcenizal force-pushed the remove-table-of-records branch from eb1537c to 3a1dca5 Compare February 24, 2018 00:05
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

Awesome! This looks great! Seeing how easy this is, I'm going to go ahead and update #16649 to use the new implementation!

I found one bug but other than that, looks great!

this.setState(this.computeTableState(this.state.criteria, nextProps));
if (fieldFilter) {
const normalizedFieldFilter = this.props.fieldFilter.toLowerCase();
return fields.filter(field => field.name.toLowerCase().includes(normalizedFieldFilter));
Copy link
Contributor

Choose a reason for hiding this comment

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

So because we are doing a return here, we aren't applying both filters consistently so we end up in a state like:

screen shot 2018-03-04 at 3 39 07 pm

Where we are only looking at a certain scripted field language but it's showing others because on the initial filter match

Copy link
Contributor

Choose a reason for hiding this comment

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

After talking this through with @cjcenizal, I think I was promoting a poor pattern of storing computed data which makes it hard to manage the original data set as well as the computed set. It doesn't seem like a good idea to store them both so I think we should move to a pattern where we only store the original data set and calculate the computed data during the render() method. To help on performance of potentially recalculating computed data unnecessarily, let's use reselect which is a tiny library designed to only call a function when the parameters have changed.

See 56e76d2

@cjcenizal
Copy link
Contributor Author

cjcenizal commented Mar 9, 2018

@chrisronline I addressed your feedback, but I didn't use your reselect suggestion. Can you take another look? Are you OK if we implement reselect in another PR, just so I can get some time to familiarize myself with it?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM!!

The reselect optimization isn't always necessary so it's totally fine to exclude for now. If the data set will always be small, it's an unnecessary optimization but the implementation is fairly trivial and straight forward so we can revisit later and quickly add if desired.

@cjcenizal cjcenizal force-pushed the remove-table-of-records branch from 0d6a1d3 to bc28cb3 Compare March 9, 2018 20:45
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@cjcenizal cjcenizal merged commit 33033ad into elastic:master Mar 9, 2018
@cjcenizal cjcenizal deleted the remove-table-of-records branch March 9, 2018 22:18
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Mar 9, 2018
…ds table. (elastic#16901)

* Convert EuiTableOfRecords to EuiBasicTable in scripted fields table.
* Convert from EuiBasicTable to EuiInMemoryTable.
* Fix bug with filtering and show 'no items' message when the filter doens't match any scripted fields.
cjcenizal added a commit that referenced this pull request Mar 9, 2018
…ds table. (#16901) (#17079)

* Convert EuiTableOfRecords to EuiBasicTable in scripted fields table.
* Convert from EuiBasicTable to EuiInMemoryTable.
* Fix bug with filtering and show 'no items' message when the filter doens't match any scripted fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants