From faba375bd9789e5e40c5be031d7491bee332d04a Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Tue, 29 Aug 2017 11:09:00 -0400 Subject: [PATCH] Just pass a default order --- .../kibana/public/discover/controllers/discover.js | 2 +- src/ui/public/doc_table/lib/get_sort.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 90286f92a0de6..5d6a3237e8fc0 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -253,7 +253,7 @@ function discoverController( function getStateDefaults() { return { query: $scope.searchSource.get('query') || { query: '', language: config.get('search:queryLanguage') }, - sort: getSort.array(savedSearch.sort, $scope.indexPattern, { order: config.get('discover:sort:defaultOrder') }), + sort: getSort.array(savedSearch.sort, $scope.indexPattern, config.get('discover:sort:defaultOrder')), columns: savedSearch.columns.length > 0 ? savedSearch.columns : config.get('defaultColumns').slice(), index: $scope.indexPattern.id, interval: 'auto', diff --git a/src/ui/public/doc_table/lib/get_sort.js b/src/ui/public/doc_table/lib/get_sort.js index c4a4de57d3392..e4749d8439131 100644 --- a/src/ui/public/doc_table/lib/get_sort.js +++ b/src/ui/public/doc_table/lib/get_sort.js @@ -6,7 +6,7 @@ import _ from 'lodash'; * @param {object} indexPattern used for determining default sort * @returns {object} a sort object suitable for returning to elasticsearch */ -export function getSort(sort, indexPattern, sortOptions = {}) { +export function getSort(sort, indexPattern, defaultSortOrder = 'desc') { const sortObj = {}; let field; let direction; @@ -21,7 +21,7 @@ export function getSort(sort, indexPattern, sortOptions = {}) { direction = sort[1]; } else if (indexPattern.timeFieldName && isSortable(indexPattern.timeFieldName)) { field = indexPattern.timeFieldName; - direction = sortOptions.order || 'desc'; + direction = defaultSortOrder; } if (field) { @@ -35,7 +35,7 @@ export function getSort(sort, indexPattern, sortOptions = {}) { return sortObj; } -getSort.array = function (sort, indexPattern, sortOptions) { - return _(getSort(sort, indexPattern, sortOptions)).pairs().pop(); +getSort.array = function (sort, indexPattern, defaultSortOrder) { + return _(getSort(sort, indexPattern, defaultSortOrder)).pairs().pop(); };