Skip to content

Commit

Permalink
Fix highlight config so it doesn't require a refresh to apply (#10346)
Browse files Browse the repository at this point in the history
* Acknowledge doc_table:highlight config even after init

* Use highlightAll on dashboard
  • Loading branch information
lukasolson committed Feb 15, 2017
1 parent f8e8374 commit d54757b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/core_plugins/kibana/public/dashboard/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
let pendingVisCount = _.size(dashboardState.getPanels());

timefilter.enabled = true;
dash.searchSource.highlightAll(true);
courier.setRootSearchSource(dash.searchSource);

// Following the "best practice" of always have a '.' in your ng-models –
Expand Down
10 changes: 10 additions & 0 deletions src/ui/public/highlight/__tests__/highlight_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,14 @@ describe('getHighlightRequest', () => {
const request = getHighlightRequest(queryStringQuery);
expect(request.fields['*']).to.not.have.property('highlight_query');
});

it('should enable/disable highlighting if config is changed', () => {
getHighlightRequest = getHighlightRequestProvider(config);
let request = getHighlightRequest(queryStringQuery);
expect(request).to.not.be(undefined);

config.set('doc_table:highlight', false);
request = getHighlightRequest(queryStringQuery);
expect(request).to.be(undefined);
});
});
6 changes: 2 additions & 4 deletions src/ui/public/highlight/highlight_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ function getHighlightQuery(query) {
}

export default function getHighlightRequestProvider(config) {
if (!config.get('doc_table:highlight')) {
return _.noop;
}

return function getHighlightRequest(query) {
if (!config.get('doc_table:highlight')) return;

const fieldsParams = config.get('doc_table:highlight:all_fields')
? { highlight_query: getHighlightQuery(query) }
: {};
Expand Down

0 comments on commit d54757b

Please sign in to comment.