-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add table and column loading options #473
Conversation
Use PureRender on Resizable and avoid passing a new function as props on each render in Table.
This change will require some clever changes to SelectionTests
The blasphemy!
3ef3811
to
9b77cbe
Compare
e668650
to
f0b3e5e
Compare
32be46e
to
de72ce6
Compare
return listOfSubsets; | ||
} | ||
|
||
function testLoadingOptionOverrides( |
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 test describes the expected loading option override behavior for all types of cells. is it clear that this is the case, or should i leave 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.
comments are always appreciated, esp in a file with so much complex code.
i suspect there are some nice refactors that could be done to clean this up, but i recognize that you're basically out of time 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 refactored a bit before i put this commit up. i think this is probably easiest to read version of this function.
The expect cell loading function in `cellTestUtils.ts` now makes a more complete set of assertions given the expected loading state of a cell. This commit also introduces an exhaustive set tests for all possible loading option combinations.
de72ce6
to
2c9ae40
Compare
return listOfSubsets; | ||
} | ||
|
||
function testLoadingOptionOverrides( |
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.
comments are always appreciated, esp in a file with so much complex code.
i suspect there are some nice refactors that could be done to clean this up, but i recognize that you're basically out of time here :(
loading = cellLoading; | ||
} else { | ||
loading = this.hasLoadingOption(columnProps.loadingOptions, ColumnLoadingOption.CELLS); | ||
} |
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 tend to prefer ternary ifs for this pattern so you can define the variable as a const
and immediately assign the correct value.
const loading = (cellLoading == null)
? this.hasLoadingOption(columnProps.loadingOptions, ColumnLoadingOption.CELLS)
: cellLoading;
*/ | ||
allTableLoadingOptions.forEach((tableLoadingOptions: TableLoadingOption[]) => { | ||
allColumnLoadingOptions.forEach((columnLoadingOptions: ColumnLoadingOption[]) => { | ||
allRowLoadingOptions.forEach((rowLoadingOptions: RowLoadingOption[]) => { |
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.
shouldn't need types on the params here. can they not be inferred from forEach
?
allColumnLoadingOptions.forEach((columnLoadingOptions: ColumnLoadingOption[]) => { | ||
allRowLoadingOptions.forEach((rowLoadingOptions: RowLoadingOption[]) => { | ||
it(`table: ${tableLoadingOptions}, column: ${columnLoadingOptions}, row: ${rowLoadingOptions}`, () => { | ||
const isCellLoading = (index: number) => { |
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.
pull this function out (define at root level) cuz it's essentially static.
renderColumnHeader={renderColumnHeader} | ||
/> | ||
</Table>, | ||
); |
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.
could even define a quick helper component <TableLoadingOptionsTester>
that does this composition, so it doesn't have to be redefined in each test run.
cellType: CellType, | ||
cellLoading: (index: number) => boolean, | ||
columnLoadingOptions: ColumnLoadingOption[], | ||
tableLoadingOptions: TableLoadingOption[]) { |
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.
put closing paren in line with open:
function name(
args,
...,
) {
columnLoadingOptions: ColumnLoadingOption[], | ||
tableLoadingOptions: TableLoadingOption[]) { | ||
|
||
// tslint:disable-next-line:prefer-for-of |
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.
shouldn't need to disable this? seems like valid usage.
expectCellLoading(columnHeaders.item(i), CellType.COLUMN_HEADER); | ||
} | ||
|
||
const rowHeaders = tableHarness.element.querySelectorAll(".bp-table-row-headers .bp-table-header"); |
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.
you could use .queryAll()
instead of querySelectorAll()
(from dom4
polyfill) which returns an Array, then simply do rowHeaders.forEach(...)
expect(headerNameText.children.length).to.equal(1); | ||
} else { | ||
expect(cell.children.length).to.equal(1); | ||
expect(cell.querySelector(`.${Classes.SKELETON}`)).to.not.be.null; |
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 identical to line 24
: cell.querySelector(".bp-table-row-name"); | ||
expect(headerNameText).to.not.be.null; | ||
expect(headerNameText.textContent).to.equal(""); | ||
expect(headerNameText.children.length).to.equal(1); |
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.
what is the one child? .pt-skeleton
? can you make that explicit?
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.
added a test that the child is a skeleton
7c363fa
to
7b97042
Compare
} else { | ||
expect(cell.children.length).to.equal(1); | ||
expect(cell.querySelector(`.${Classes.SKELETON}`)).to.not.be.null; | ||
expect(cell.children[0].classList.contains(Classes.SKELETON)).to.not.be.null; |
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.
wait why back to this format?
did my comments lead us in a circle? 😶
you're testing too much here and it's not helping.
it should be sufficient to assert that a selector exists, for example:
.bp-table-row-name .pt-skeleton
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 wanted to be explicit about where the skeleton exists, hence the single child test. it's nested further down in header cells vs. normal cells
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.
L31 and L34 are slightly different in this sense.
04b97e6
to
dd737f8
Compare
😅 let's do this! |
Checklist
Changes proposed in this pull request:
Make it easier to set the loading state on common sections of the table such as the headers and body by specifying loading options on
Table
andColumn
, components higher up in the hierarchy. Only exposing aloading
prop on cell components results in needing to define acellRenderer
function just to conditionally set the loading state.When
loadingOptions
are specified on bothTable
andColumn
andloading
is also specified onCell
, the lowest component takes precedence. This allows users to manually make changes to the overall loading appearance of the table.In the following example,
All column / row headers and body cells show the loadings state except: