Skip to content

[DataGrid] Light refactor - #5008

Merged
chandlerprall merged 2 commits into
elastic:masterfrom
myasonik:data-grid-rows
Aug 18, 2021
Merged

chandlerprall merged 2 commits into
elastic:masterfrom
myasonik:data-grid-rows

Conversation

@myasonik

@myasonik myasonik commented Aug 5, 2021

Copy link
Copy Markdown
Contributor

Summary

This refactor doesn't refactor any of the underlying logic, rather it moves things around to better encapsulate concerns.

Why?

Having not thoroughly looked at DataGrid in some months, I found it difficult to wrap my head around all the pieces that I needed to look at to make a change. By drawing more boundary lines between concerns, hopefully this should make it easier to reason about where you should begin to make a change.

Major changes

  • All props now live in data_grid_types
  • Moved all child components that only are used in the DataGridHeader to a header folder
  • Moved all child components that are only used in the DataGridBody to a body folder
    • Making these two folders makes it clear what is a top level concern and what isn't. As well as helps you figure out which components you might need to touch to make a change.
  • Extracted DataGridPagination and DataGridToolbar into their own components

Minor changes

  • Tweaked a handful of strings for better i18n (mostly by using more interpolation for values)
  • A few spelling mistakes in variable names and whatnot

(Future) TODO

This work could be taken a lot further but I figured this was enough of a first step to test the waters and see if people like it. Both the DataGrid and DataGridBody components are particularly long and complex and the types file is somewhat unwieldy.

Checklist

There weren't any feature changes but I checked that everything still renders as expected

@myasonik myasonik added chore data grid skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) labels Aug 5, 2021
@kibanamachine

Copy link
Copy Markdown
Contributor

@thompsongl
thompsongl self-requested a review August 9, 2021 18:06

@thompsongl thompsongl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!
Clicked and tabbed around the various examples without any apparent changes.

import { EuiTablePagination } from '../table/table_pagination';
import { EuiDataGridPaginationRendererProps } from './data_grid_types';

export const EuiDataGridPaginationRenderer = ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙌

@chandlerprall chandlerprall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have a full dive on data_grid.tsx's changes still, but all of this looks great. Particularly the better a11y usage, but readability refactor++ ❤️

@chandlerprall chandlerprall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGreatTM! Spot checked, tested locally, and also built Kibana to uan the type checker & jest tests for ml+discover - all with no issues

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

Labels

chore data grid skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants