-
Notifications
You must be signed in to change notification settings - Fork 8.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
Fix Saved Objects total item count and table filtering #21574
Conversation
…e header and for the table.
@@ -196,11 +206,8 @@ export class ObjectsTable extends Component { | |||
}; | |||
|
|||
onQueryChange = ({ query }) => { | |||
// TODO: investigate why this happens at EUI level | |||
if (isSameQuery(query, this.state.activeQuery)) { |
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 think there's a bug in EUI in which a reference is being reused within the query.ast
instance, causing this comparison to incorrectly return true
.
💔 Build Failed |
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.
Tested locally and confirmed that object counts are correct. Just a small question, otherwise LGTM!
@@ -425,7 +425,6 @@ describe('ObjectsTable', () => { | |||
expect(mockSavedObjectsClient.delete).toHaveBeenCalledWith(mockSavedObjects[0].type, mockSavedObjects[0].id); | |||
expect(mockSavedObjectsClient.delete).toHaveBeenCalledWith(mockSavedObjects[1].type, mockSavedObjects[1].id); | |||
expect(component.state('selectedSavedObjects').length).toBe(0); | |||
expect(defaultProps.savedObjectsClient.find.mock.calls.length).toBe(2); |
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.
is this meant to be removed? does its equivalence need to be added elsewhere or in another test?
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.
It took me awhile to understand the intention of this test. When I realized it failed on CI because I had added additional calls to fetch the number of saved objects, I decided it was testing an implementation detail. I removed it because I don't think it's providing value.
💚 Build Succeeded |
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.
while you are in this file, how about replacing $http with kfetch? getSavedObjectCounts
should just use kfetch.
another question - why does the order of the type filter list change when one is selected? Its a short list, why not just always display in alphabetic order? It is annoying when the UI changes underneath you and then a click is registered for the wrong item |
@@ -141,7 +138,8 @@ export class ObjectsTable extends Component { | |||
if (!activeQuery) { | |||
return { | |||
pageOfItems: [], | |||
totalItemCount: 0, | |||
// Deliberately don't reset totalItemCount because 0 wouldn't be accurate. |
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.
Why does this method short circuit when there are not active queries?
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'm not sure and looking through the code I actually don't see how this branch could ever be hit. I'm going to try removing it.
type: INCLUDED_TYPES, | ||
}); | ||
|
||
totalItemCount = allSavedObjects.total; |
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.
Now that the totatItemCount ignores filters, does it still make sense to display right next to the page title? I find this a little misleading. How about moving the totalItemCount to "Export Everything" button since that is where the total number of objects is really only relevant.
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.
Good idea, will do.
Filters are applied inconstantly to "Export Everything". For example, If I only filter by "dashboard" type then export everything still exports everything However, then if I add another filter that filters by saved object name by typing a string in the input box, then export everything is now filtered by that string but not by type? Why? As a user, how would I know or expect the difference? Maybe |
Great idea, will do!
I find this really annoying too. It's so that all of the selected items are at the top. This is a problem with EUI, so we should file an issue in the EUI repo.
This is my mistake. I think the original design was to make this button export everything that's in the table (i.e. after all filters and search have been applied). I think this is a desirable UX -- you can search for some objects by name and bulk export that entire set. What do you think? |
I agree that "export everything" should export the table contents since there is no other way to export the table. |
…aved objects in bulk export button. Only show visible types in bulk export modal.
@nreese Could you take another look? Considering that this is going into 6.4, I'd prefer to save the $http -> fkfetch migration for another PR. |
💚 Build Succeeded |
@nreese Personally, I think it's useful to know exactly how many saved objects there are when not all of them are visible. |
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.
Thanks for fixing this
lgtm
code review, test changes and verified problem has been addressed.
const savedObjectCounts = await getSavedObjectCounts( | ||
this.props.$http, | ||
type, | ||
INCLUDED_TYPES, |
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.
Why was this changed from filteredTypes
to all types?
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.
It's used to populate the filter dropdown in the table. Originally, filtering on a type would reduce the counts of the non-selected types to 0, within the filter dropdown. I'll add a comment.
💚 Build Succeeded |
@nreese I think this is a bug within EUI. There's no way to externally tell |
Agreed, its not a blocker for this PR. It is easy for the user to recover by de-selecting and then re-selecting the item again. lgtm |
* Remove implementation detail assertion from objects table test. * Reset selection state when table state or query state changes. * Remove total count from title.
Fixes #21569 and #21615
Also fixes a bug in which applying filters to the table beyond the first one wouldn't have any effect.