mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.5] [Discover] Fix saved search with custom label running into "aborted" error on a dashboard (#147310) (#149826)
# Backport This will backport the following commits from `main` to `8.5`: - [[Discover] Fix saved search with custom label running into "aborted" error on a dashboard (#147310)](https://github.com/elastic/kibana/pull/147310) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthias Wilhelm","email":"matthias.wilhelm@elastic.co"},"sourceCommit":{"committedDate":"2022-12-14T09:49:22Z","message":"[Discover] Fix saved search with custom label running into \"aborted\" error on a dashboard (#147310)","sha":"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","backport:prev-minor","v8.6.0","v8.7.0","v8.5.4"],"number":147310,"url":"https://github.com/elastic/kibana/pull/147310","mergeCommit":{"message":"[Discover] Fix saved search with custom label running into \"aborted\" error on a dashboard (#147310)","sha":"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae"}},"sourceBranch":"main","suggestedTargetBranches":["8.5"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/147496","number":147496,"state":"MERGED","mergeCommit":{"sha":"29576ba168eaa5f4e9775ae88c96cb422e81d97e","message":"[8.6] [Discover] Fix saved search with custom label running into \"aborted\" error on a dashboard (#147310) (#147496)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.6`:\n- [[Discover] Fix saved search with custom label running into \"aborted\"\nerror on a dashboard\n(#147310)](https://github.com/elastic/kibana/pull/147310)\n\n<!--- Backport version: 8.9.7 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Matthias\nWilhelm\",\"email\":\"matthias.wilhelm@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2022-12-14T09:49:22Z\",\"message\":\"[Discover]\nFix saved search with custom label running into \\\"aborted\\\" error on a\ndashboard\n(#147310)\",\"sha\":\"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae\",\"branchLabelMapping\":{\"^v8.7.0$\":\"main\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"Feature:Discover\",\"release_note:fix\",\"Team:DataDiscovery\",\"backport:prev-minor\",\"v8.7.0\"],\"number\":147310,\"url\":\"https://github.com/elastic/kibana/pull/147310\",\"mergeCommit\":{\"message\":\"[Discover]\nFix saved search with custom label running into \\\"aborted\\\" error on a\ndashboard\n(#147310)\",\"sha\":\"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v8.7.0\",\"labelRegex\":\"^v8.7.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/147310\",\"number\":147310,\"mergeCommit\":{\"message\":\"[Discover]\nFix saved search with custom label running into \\\"aborted\\\" error on a\ndashboard\n(#147310)\",\"sha\":\"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae\"}}]}]\nBACKPORT-->\n\nCo-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>"}},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147310","number":147310,"mergeCommit":{"message":"[Discover] Fix saved search with custom label running into \"aborted\" error on a dashboard (#147310)","sha":"e3364c9c3d8f0f2ae3f1273969823b3c6d275bae"}},{"branch":"8.5","label":"v8.5.4","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This commit is contained in:
parent
b1a7008a27
commit
c0e535e57c
2 changed files with 31 additions and 11 deletions
|
@ -16,7 +16,7 @@ import { discoverServiceMock } from '../__mocks__/services';
|
|||
import { SavedSearchEmbeddable, SearchEmbeddableConfig } from './saved_search_embeddable';
|
||||
import { render } from 'react-dom';
|
||||
import { createSearchSourceMock } from '@kbn/data-plugin/public/mocks';
|
||||
import { throwError } from 'rxjs';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { ReactWrapper } from 'enzyme';
|
||||
import { SavedSearchEmbeddableComponent } from './saved_search_embeddable_component';
|
||||
|
||||
|
@ -81,7 +81,7 @@ describe('saved search embeddable', () => {
|
|||
(input) => (input.lastReloadRequestTime = Date.now())
|
||||
);
|
||||
|
||||
return { embeddable };
|
||||
return { embeddable, searchInput };
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -159,4 +159,24 @@ describe('saved search embeddable', () => {
|
|||
'Fetch error'
|
||||
);
|
||||
});
|
||||
|
||||
it('a custom title should not start another search which would cause an Abort error', async () => {
|
||||
const search = jest.fn().mockReturnValue(
|
||||
of({
|
||||
rawResponse: { hits: { hits: [], total: 0 } },
|
||||
isPartial: false,
|
||||
isRunning: false,
|
||||
})
|
||||
);
|
||||
const { embeddable, searchInput } = createEmbeddable(search);
|
||||
|
||||
embeddable.render(mountpoint);
|
||||
// wait for data fetching
|
||||
await waitOneTick();
|
||||
expect(search).toHaveBeenCalledTimes(1);
|
||||
embeddable.updateOutput({ title: 'custom title' });
|
||||
embeddable.updateInput(searchInput);
|
||||
await waitOneTick();
|
||||
expect(search).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -149,13 +149,13 @@ export class SavedSearchEmbeddable
|
|||
if (titleChanged) {
|
||||
this.panelTitle = this.output.title || '';
|
||||
}
|
||||
if (
|
||||
this.searchProps &&
|
||||
(titleChanged ||
|
||||
this.isFetchRequired(this.searchProps) ||
|
||||
this.isRerenderRequired(this.searchProps))
|
||||
) {
|
||||
this.reload();
|
||||
if (!this.searchProps) {
|
||||
return;
|
||||
}
|
||||
const isFetchRequired = this.isFetchRequired(this.searchProps);
|
||||
const isRerenderRequired = this.isRerenderRequired(this.searchProps);
|
||||
if (titleChanged || isFetchRequired || isRerenderRequired) {
|
||||
this.reload(isFetchRequired);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -550,9 +550,9 @@ export class SavedSearchEmbeddable
|
|||
}
|
||||
}
|
||||
|
||||
public reload() {
|
||||
public reload(forceFetch = true) {
|
||||
if (this.searchProps) {
|
||||
this.load(this.searchProps, true);
|
||||
this.load(this.searchProps, forceFetch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue