Skip to content

Commit

Permalink
[Discover] Don't update index pattern field popularity without save c…
Browse files Browse the repository at this point in the history
…apabilities (elastic#67836)
  • Loading branch information
ashikmeerankutty authored Jun 12, 2020
1 parent cb2c90c commit 1b85b40
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/plugins/discover/public/application/angular/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,13 +970,17 @@ function discoverController(
};

$scope.addColumn = function addColumn(columnName) {
$scope.indexPattern.popularizeField(columnName, 1);
if (uiCapabilities.discover.save) {
$scope.indexPattern.popularizeField(columnName, 1);
}
const columns = columnActions.addColumn($scope.state.columns, columnName);
setAppState({ columns });
};

$scope.removeColumn = function removeColumn(columnName) {
$scope.indexPattern.popularizeField(columnName, 1);
if (uiCapabilities.discover.save) {
$scope.indexPattern.popularizeField(columnName, 1);
}
const columns = columnActions.removeColumn($scope.state.columns, columnName);
setAppState({ columns });
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jest.mock('../../../kibana_services', () => ({
visualize: {
show: true,
},
discover: {
save: false,
},
},
uiSettings: {
get: (key: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ export function DiscoverSidebar({
setOpenFieldMap(new Map(openFieldMap.set(field.name, false)));
} else {
setOpenFieldMap(new Map(openFieldMap.set(field.name, true)));
selectedIndexPattern.popularizeField(field.name, 1);
if (services.capabilities.discover.save) {
selectedIndexPattern.popularizeField(field.name, 1);
}
}
},
[openFieldMap, selectedIndexPattern]
[openFieldMap, selectedIndexPattern, services.capabilities.discover.save]
);
const onChangeFieldSearch = useCallback(
(field: string, value: string | boolean | undefined) => {
Expand Down

0 comments on commit 1b85b40

Please sign in to comment.