Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Mar 18, 2020
1 parent 2877557 commit 1e0b548
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,6 @@ describe('Doc Table', function() {
maxLength: 50,
});

/**
sinon
.stub(config, 'get')
.withArgs('metaFields')
.returns(['_id']); **/

// Open the row
$scope.toggleRow();
$scope.$digest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const {
share,
timefilter,
toastNotifications,
uiSettings,
uiSettings: config,
visualizations,
} = getServices();

Expand Down Expand Up @@ -131,7 +131,7 @@ app.config($routeProvider => {
*
* @type {State}
*/
const id = getIndexPatternId(index, indexPatternList, uiSettings.get('defaultIndex'));
const id = getIndexPatternId(index, indexPatternList, config.get('defaultIndex'));
return Promise.props({
list: indexPatternList,
loaded: indexPatterns.get(id),
Expand Down Expand Up @@ -211,7 +211,7 @@ function discoverController(
getPreviousAppState,
} = getState({
defaultAppState: getStateDefaults(),
storeInSessionStorage: getServices().uiSettings.get('state:storeInSessionStorage'),
storeInSessionStorage: config.get('state:storeInSessionStorage'),
history,
});
if (appStateContainer.getState().index !== $scope.indexPattern.id) {
Expand Down Expand Up @@ -536,15 +536,15 @@ function discoverController(
const { searchFields, selectFields } = await getSharingDataFields(
$scope.state.columns,
$scope.indexPattern.timeFieldName,
uiSettings.get('doc_table:hideTimeColumn')
config.get('doc_table:hideTimeColumn')
);
searchSource.setField('fields', searchFields);
searchSource.setField(
'sort',
getSortForSearchSource(
$scope.state.sort,
$scope.indexPattern,
uiSettings.get('discover:sort:defaultOrder')
config.get('discover:sort:defaultOrder')
)
);
searchSource.setField('highlight', null);
Expand All @@ -571,15 +571,13 @@ function discoverController(
const query =
$scope.searchSource.getField('query') ||
getDefaultQuery(
localStorage.get('kibana.userQueryLanguage') || uiSettings.get('search:queryLanguage')
localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage')
);
return {
query,
sort: getSortArray(savedSearch.sort, $scope.indexPattern),
columns:
savedSearch.columns.length > 0
? savedSearch.columns
: uiSettings.get('defaultColumns').slice(),
savedSearch.columns.length > 0 ? savedSearch.columns : config.get('defaultColumns').slice(),
index: $scope.indexPattern.id,
interval: 'auto',
filters: _.cloneDeep($scope.searchSource.getOwnField('filter')),
Expand Down Expand Up @@ -609,7 +607,7 @@ function discoverController(

$scope.opts = {
// number of records to fetch, then paginate through
sampleSize: uiSettings.get('discover:sampleSize'),
sampleSize: config.get('discover:sampleSize'),
timefield: getTimeField(),
savedSearch: savedSearch,
indexPatternList: $route.current.locals.savedObjects.ip.list,
Expand All @@ -619,7 +617,7 @@ function discoverController(
// A saved search is created on every page load, so we check the ID to see if we're loading a
// previously saved search or if it is just transient
return (
uiSettings.get('discover:searchOnPageLoad') ||
config.get('discover:searchOnPageLoad') ||
savedSearch.id !== undefined ||
timefilter.getRefreshInterval().pause === false
);
Expand Down Expand Up @@ -829,7 +827,7 @@ function discoverController(
const state = {
...appStateContainer.getState(),
query: getDefaultQuery(
localStorage.get('kibana.userQueryLanguage') || uiSettings.get('search:queryLanguage')
localStorage.get('kibana.userQueryLanguage') || config.get('search:queryLanguage')
),
filters: [],
};
Expand Down Expand Up @@ -919,7 +917,7 @@ function discoverController(
};

$scope.toMoment = function(datetime) {
return moment(datetime).format(uiSettings.get('dateFormat'));
return moment(datetime).format(config.get('dateFormat'));
};

$scope.resetQuery = function() {
Expand All @@ -940,7 +938,7 @@ function discoverController(
getSortForSearchSource(
$scope.state.sort,
indexPattern,
uiSettings.get('discover:sort:defaultOrder')
config.get('discover:sort:defaultOrder')
)
)
.setField('query', $scope.state.query || null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { TableHeader } from './table_header/table_header';
import { wrapInI18nContext, getServices } from '../../../../kibana_services';

export function createTableHeaderDirective(reactDirective: any) {
const { uiSettings: config } = getServices();

return reactDirective(
wrapInI18nContext(TableHeader),
[
Expand All @@ -34,9 +36,9 @@ export function createTableHeaderDirective(reactDirective: any) {
],
{ restrict: 'A' },
{
hideTimeColumn: getServices().uiSettings.get('doc_table:hideTimeColumn'),
isShortDots: getServices().uiSettings.get('shortDots:enable'),
defaultSortOrder: getServices().uiSettings.get('discover:sort:defaultOrder'),
hideTimeColumn: config.get('doc_table:hideTimeColumn'),
isShortDots: config.get('shortDots:enable'),
defaultSortOrder: config.get('discover:sort:defaultOrder'),
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function createFieldChooserDirective($location) {
$scope.showFilter = false;
$scope.toggleShowFilter = () => ($scope.showFilter = !$scope.showFilter);
$scope.indexPatternList = _.sortBy($scope.indexPatternList, o => o.get('title'));
const config = getServices().uiSettings;

const filter = ($scope.filter = {
props: ['type', 'aggregatable', 'searchable', 'missing', 'name'],
Expand Down Expand Up @@ -157,9 +158,7 @@ export function createFieldChooserDirective($location) {
groups.unpopular = groups.unpopular || [];

// move excess popular fields to un-popular list
const extras = groups.popular.splice(
getServices().uiSettings.get('fields:popularLimit')
);
const extras = groups.popular.splice(config.get('fields:popularLimit'));
groups.unpopular = extras.concat(groups.unpopular);
})
.each(function(group, name) {
Expand Down Expand Up @@ -216,7 +215,7 @@ export function createFieldChooserDirective($location) {
schema: 'segment',
params: {
field: field.name,
size: parseInt(getServices().uiSettings.get('discover:aggs:terms:size'), 10),
size: parseInt(config.get('discover:aggs:terms:size'), 10),
orderBy: '2',
},
};
Expand Down

0 comments on commit 1e0b548

Please sign in to comment.