Skip to content

Commit d97b6fa

Browse files
authored
[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)
1 parent 8b7b36a commit d97b6fa

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)