Skip to content

Commit 8a739aa

Browse files
[8.x] [Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041) (#208676)
# Backport This will backport the following commits from `main` to `8.x`: - [[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)](#208041) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-01-29T07:00:22Z","message":"[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)","sha":"d97b6fa7a114192606b638b974e6b83d19922954","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Lens","v9.0.0","Feature:ES|QL","backport:version","v8.18.0"],"title":"[Lens][ES|QL] Going to Discover without carrying the dashboard filters","number":208041,"url":"https://github.com/elastic/kibana/pull/208041","mergeCommit":{"message":"[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)","sha":"d97b6fa7a114192606b638b974e6b83d19922954"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/208041","number":208041,"mergeCommit":{"message":"[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)","sha":"d97b6fa7a114192606b638b974e6b83d19922954"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <[email protected]>
1 parent 4f6d858 commit 8a739aa

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

x-pack/platform/plugins/shared/lens/public/trigger_actions/open_in_discover_action.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,48 @@ describe('open in discover action', () => {
135135
expect(locator.getRedirectUrl).toHaveBeenCalledWith(viewUnderlyingDataArgs);
136136
expect(globalThis.open).toHaveBeenCalledWith(discoverUrl, '_blank');
137137
});
138+
139+
it('navigates to discover for an ES|QL chart but without the filters', async () => {
140+
const viewUnderlyingDataArgs = {
141+
dataViewSpec: { id: 'index-pattern-id' },
142+
timeRange: {},
143+
filters: [{ meta: { type: 'range' } }],
144+
query: undefined,
145+
columns: [],
146+
};
147+
148+
const embeddable = {
149+
...compatibleEmbeddableApi,
150+
getViewUnderlyingDataArgs: jest.fn(() => viewUnderlyingDataArgs),
151+
isTextBasedLanguage: jest.fn(() => true),
152+
};
153+
154+
const discoverUrl = 'https://discover-redirect-url';
155+
const locator = {
156+
getRedirectUrl: jest.fn(() => discoverUrl),
157+
} as unknown as DiscoverAppLocator;
158+
159+
globalThis.open = jest.fn();
160+
161+
await createOpenInDiscoverAction(
162+
locator,
163+
{
164+
get: () => ({
165+
isTimeBased: () => true,
166+
toSpec: () => ({ id: 'index-pattern-id' }),
167+
}),
168+
} as unknown as DataViewsService,
169+
true
170+
).execute({
171+
embeddable,
172+
} as ActionExecutionContext<EmbeddableApiContext>);
173+
174+
expect(embeddable.getViewUnderlyingDataArgs).toHaveBeenCalled();
175+
const viewUnderlyingDataArgsWithoutFilters = {
176+
...viewUnderlyingDataArgs,
177+
filters: [],
178+
};
179+
expect(locator.getRedirectUrl).toHaveBeenCalledWith(viewUnderlyingDataArgsWithoutFilters);
180+
expect(globalThis.open).toHaveBeenCalledWith(discoverUrl, '_blank');
181+
});
138182
});

x-pack/platform/plugins/shared/lens/public/trigger_actions/open_in_discover_helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ async function getDiscoverLocationParams({
5959
throw new Error('Underlying data is not ready');
6060
}
6161
const dataView = await dataViews.get(args.dataViewSpec.id!);
62-
let filtersToApply = [...(filters || []), ...args.filters];
62+
// we don't want to pass the DSL filters when navigating from an ES|SQL embeddable
63+
let filtersToApply = embeddable.isTextBasedLanguage()
64+
? []
65+
: [...(filters || []), ...args.filters];
6366
let timeRangeToApply = args.timeRange;
6467
// if the target data view is time based, attempt to split out a time range from the provided filters
6568
if (dataView.isTimeBased() && dataView.timeFieldName === timeFieldName) {

0 commit comments

Comments
 (0)