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

Migrate legacy sort arrays on saved searches #43038

Merged
merged 8 commits into from
Aug 13, 2019
Merged

Conversation

Bargs
Copy link
Contributor

@Bargs Bargs commented Aug 9, 2019

Summary

Fixes #42982

With my multi sort PR I changed the sort property on saved searches to contain a nested array. Discover and Dashboard were backwards compatible with the old format but it turns out the nested array caused issues for CSV export. Instead of trying to support single and two dimension arrays everywhere, this PR simply adds a migration for saved searches in 7.4 and updates our sample data sets so that we can always expect sort objects to be two dimensional arrays. I also cleaned up the backwards compatibility code in Discover and Dashboard.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@Bargs Bargs added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.4.0 labels Aug 9, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@elasticmachine
Copy link
Contributor

💔 Build Failed

@@ -29,24 +29,25 @@ function createSortObject(sortPair, indexPattern) {
const [ field, direction ] = sortPair;
return { [field]: direction };
}
else if (_.isPlainObject(sortPair) && isSortable(Object.keys(sortPair)[0], indexPattern)) {
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 noticed a bug where getSort.array was being used with an Elasticsearch formatted sort object but we weren't actually handling that in the getSort code. So I updated this method to handle that case and added tests to make it more clear what all getSort.array is expected to do.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@Bargs Bargs requested a review from bmcconaghy August 9, 2019 20:13
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

This looks good. Unless I'm missing something, if someone fires up 7.4.0 and then uses one of the add sample data wizards, they will wind up with a saved search that has a sort that is only a 1 dimensional array. We should probably fix those as part of this PR too.

@Bargs
Copy link
Contributor Author

Bargs commented Aug 12, 2019

@bmcconaghy that should already be fixed, I updated the sample data files: https://github.com/elastic/kibana/pull/43038/files#diff-23e156bef21eddb8b1b0ea745bea791a

Is there one I missed?

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

Code LGTM.

@bmcconaghy
Copy link
Contributor

@Bargs nope I just missed your changes.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@Bargs Bargs merged commit cda3de6 into elastic:master Aug 13, 2019
Bargs added a commit to Bargs/kibana that referenced this pull request Aug 13, 2019
With my multi sort PR I changed the sort property on saved searches to contain a nested array. Discover and Dashboard were backwards compatible with the old format but it turns out the nested array caused issues for CSV export. Instead of trying to support single and two dimension arrays everywhere, this PR simply adds a migration for saved searches in 7.4 and updates our sample data sets so that we can always expect sort objects to be two dimensional arrays. I also cleaned up the backwards compatibility code in Discover and Dashboard.
Bargs added a commit that referenced this pull request Aug 15, 2019
With my multi sort PR I changed the sort property on saved searches to contain a nested array. Discover and Dashboard were backwards compatible with the old format but it turns out the nested array caused issues for CSV export. Instead of trying to support single and two dimension arrays everywhere, this PR simply adds a migration for saved searches in 7.4 and updates our sample data sets so that we can always expect sort objects to be two dimensional arrays. I also cleaned up the backwards compatibility code in Discover and Dashboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.4.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saved searches sort should always be a nested array
3 participants