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

Fix Saved Objects total item count and table filtering #21574

Merged
merged 8 commits into from
Aug 2, 2018

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Aug 1, 2018

Fixes #21569 and #21615

Also fixes a bug in which applying filters to the table beyond the first one wouldn't have any effect.

@@ -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)) {
Copy link
Contributor Author

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@jen-huang jen-huang left a 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@nreese nreese left a 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.

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, will do.

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

Filters are applied inconstantly to "Export Everything".

For example, If I only filter by "dashboard" type then export everything still exports everything

screen shot 2018-08-02 at 7 01 43 am

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?

screen shot 2018-08-02 at 7 02 03 am

Maybe getSavedObjectCounts still needs to be filtered by type and then in the results, if the type is missing, the count is set to zero

@cjcenizal cjcenizal added blocker and removed blocker labels Aug 2, 2018
@cjcenizal
Copy link
Contributor Author

while you are in this file, how about replacing $http with kfetch?

Great idea, will do!

why does the order of the type filter list change when one is selected?

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.

Filters are applied inconstantly to "Export Everything".

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?

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

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.
@cjcenizal
Copy link
Contributor Author

@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.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

Really nice. Do you even need to still display the total saved object count in the page title?

screen shot 2018-08-02 at 2 26 16 pm

@cjcenizal
Copy link
Contributor Author

@nreese Personally, I think it's useful to know exactly how many saved objects there are when not all of them are visible.

Copy link
Contributor

@nreese nreese left a 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,
Copy link
Contributor

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?

Copy link
Contributor Author

@cjcenizal cjcenizal Aug 2, 2018

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.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

Looks like the de-select does not quite work as expected.

  1. Try selecting a saved object
  2. Do a more inclusive filter that includes the selected saved object
  3. Notice that the saved object is still selected but the delete and export buttons are still disabled

screen shot 2018-08-02 at 4 54 04 pm

@cjcenizal
Copy link
Contributor Author

@nreese I think this is a bug within EUI. There's no way to externally tell EuiBasicTable to reset its selection state. Even EuiInMemoryTable has the same bug you describe, but it manifests itself when you do a search that returns no results. I'll create an EUI issue but I don't think it's a blocker for this PR.

@nreese
Copy link
Contributor

nreese commented Aug 2, 2018

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

@cjcenizal cjcenizal merged commit a207d97 into elastic:master Aug 2, 2018
@cjcenizal cjcenizal deleted the bug/saved-object-counts branch August 2, 2018 23:18
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Aug 2, 2018
* Remove implementation detail assertion from objects table test.
* Reset selection state when table state or query state changes.
* Remove total count from title.
cjcenizal added a commit that referenced this pull request Aug 3, 2018
* Remove implementation detail assertion from objects table test.
* Reset selection state when table state or query state changes.
* Remove total count from title.
cjcenizal added a commit that referenced this pull request Aug 3, 2018
* Remove implementation detail assertion from objects table test.
* Reset selection state when table state or query state changes.
* Remove total count from title.
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.

Saved Object "Export Everything" displays "undefined" for some object type counts
4 participants