Skip to content

Allow pagination for interpreted results#481

Merged
jcreedcmu merged 16 commits intogithub:mainfrom
jcreedcmu:jcreed/interpreted-pagination
Jul 6, 2020
Merged

Allow pagination for interpreted results#481
jcreedcmu merged 16 commits intogithub:mainfrom
jcreedcmu:jcreed/interpreted-pagination

Conversation

@jcreedcmu
Copy link
Copy Markdown
Contributor

@jcreedcmu jcreedcmu commented Jun 30, 2020

Enable pagination for interpreted as well as raw results.

This is still under feature flag, so no user-facing changes quite yet, but the flag can possibly be enabled for everyone once this lands. There will be a number of code cleanups available at that point.

#277

@jcreedcmu jcreedcmu requested a review from aeisenberg June 30, 2020 14:19
pageNumber: 0,
numPages: numPagesOfResultSet(resultSet),
resultSet,
resultSet: { t: 'RawResultSet', ...resultSet },
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.

Has the type RawResultSet changed? In the current main branch, it looks like there is no t property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To accomodate sarif results, I changed the type of the .resultSet field of ExtensionParsedResultSets from being always only a RawResultSet to being a ResultSet (which is either a RawResultSet or a SarifResultSet, tagged appropriately)

extends React.Component<ResultTablesProps, ResultTablesState> {

private getResultSets(): ResultSet[] {
private static _getResultSetsOfProps(props: ResultTablesProps): ResultSet[] {
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.

Why convert to static?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So that it can be called from the static lifecycle method getDerivedStateFromProps.

return resultSets;
}

private getResultSets(): ResultSet[] {
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.

Looks like this isn't used.

Wait...it is. Though, not sure what the difference is between this function and the static _getResultSetsOfProps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just factored out the body of that method into a static method that takes a props argument, so that I could call it from getDerivedStateFromProps.

/**
* Holds if we actually should show pagination interface right now. This is
* still false for the time being when we're viewing alerts.
* true as long as the result sets we're given are marked to permit it.
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.

should probably just get rid of this function since it duplicates paginationAllowed without adding anything new. And paginationAllowed will be removed when we remove the pagination flag, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, could just inline that now.

@aeisenberg
Copy link
Copy Markdown
Contributor

It looks like this adds pagination for alerts table, but not paths tables. Is that part coming later?

@jcreedcmu
Copy link
Copy Markdown
Contributor Author

It looks like this adds pagination for alerts table, but not paths tables. Is that part coming later?

No, it works for me on path tables when I test it? This may be a worthwhile cleanup in how things are named if that's confusing.

@aeisenberg
Copy link
Copy Markdown
Contributor

OK...tried this out on a proper path query. Looks great. A couple of things, though:

  1. We should have some better styling for the pagination section (I said that before, and this can still happen later).
  2. it's not possible to edit the pagination text box. I haven't looked at the reason why, but I suspect that this is a react problem. Should be easy to fix.

@aeisenberg
Copy link
Copy Markdown
Contributor

I think for 2, the problem has to do wih getDerivedStateFromProps returning the old value of the selected page.

Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Nice job!

I have some time now, so I am going to look at a little better style.

@aeisenberg aeisenberg mentioned this pull request Jul 2, 2020
3 tasks
@jcreedcmu jcreedcmu merged commit 454e847 into github:main Jul 6, 2020
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.

2 participants