mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Lens][ES|QL] Going to Discover without carrying the dashboard filters (#208041)
This commit is contained in:
parent
8b7b36a692
commit
d97b6fa7a1
2 changed files with 48 additions and 1 deletions
|
@ -135,4 +135,48 @@ describe('open in discover action', () => {
|
||||||
expect(locator.getRedirectUrl).toHaveBeenCalledWith(viewUnderlyingDataArgs);
|
expect(locator.getRedirectUrl).toHaveBeenCalledWith(viewUnderlyingDataArgs);
|
||||||
expect(globalThis.open).toHaveBeenCalledWith(discoverUrl, '_blank');
|
expect(globalThis.open).toHaveBeenCalledWith(discoverUrl, '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('navigates to discover for an ES|QL chart but without the filters', async () => {
|
||||||
|
const viewUnderlyingDataArgs = {
|
||||||
|
dataViewSpec: { id: 'index-pattern-id' },
|
||||||
|
timeRange: {},
|
||||||
|
filters: [{ meta: { type: 'range' } }],
|
||||||
|
query: undefined,
|
||||||
|
columns: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const embeddable = {
|
||||||
|
...compatibleEmbeddableApi,
|
||||||
|
getViewUnderlyingDataArgs: jest.fn(() => viewUnderlyingDataArgs),
|
||||||
|
isTextBasedLanguage: jest.fn(() => true),
|
||||||
|
};
|
||||||
|
|
||||||
|
const discoverUrl = 'https://discover-redirect-url';
|
||||||
|
const locator = {
|
||||||
|
getRedirectUrl: jest.fn(() => discoverUrl),
|
||||||
|
} as unknown as DiscoverAppLocator;
|
||||||
|
|
||||||
|
globalThis.open = jest.fn();
|
||||||
|
|
||||||
|
await createOpenInDiscoverAction(
|
||||||
|
locator,
|
||||||
|
{
|
||||||
|
get: () => ({
|
||||||
|
isTimeBased: () => true,
|
||||||
|
toSpec: () => ({ id: 'index-pattern-id' }),
|
||||||
|
}),
|
||||||
|
} as unknown as DataViewsService,
|
||||||
|
true
|
||||||
|
).execute({
|
||||||
|
embeddable,
|
||||||
|
} as ActionExecutionContext<EmbeddableApiContext>);
|
||||||
|
|
||||||
|
expect(embeddable.getViewUnderlyingDataArgs).toHaveBeenCalled();
|
||||||
|
const viewUnderlyingDataArgsWithoutFilters = {
|
||||||
|
...viewUnderlyingDataArgs,
|
||||||
|
filters: [],
|
||||||
|
};
|
||||||
|
expect(locator.getRedirectUrl).toHaveBeenCalledWith(viewUnderlyingDataArgsWithoutFilters);
|
||||||
|
expect(globalThis.open).toHaveBeenCalledWith(discoverUrl, '_blank');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -59,7 +59,10 @@ async function getDiscoverLocationParams({
|
||||||
throw new Error('Underlying data is not ready');
|
throw new Error('Underlying data is not ready');
|
||||||
}
|
}
|
||||||
const dataView = await dataViews.get(args.dataViewSpec.id!);
|
const dataView = await dataViews.get(args.dataViewSpec.id!);
|
||||||
let filtersToApply = [...(filters || []), ...args.filters];
|
// we don't want to pass the DSL filters when navigating from an ES|SQL embeddable
|
||||||
|
let filtersToApply = embeddable.isTextBasedLanguage()
|
||||||
|
? []
|
||||||
|
: [...(filters || []), ...args.filters];
|
||||||
let timeRangeToApply = args.timeRange;
|
let timeRangeToApply = args.timeRange;
|
||||||
// if the target data view is time based, attempt to split out a time range from the provided filters
|
// if the target data view is time based, attempt to split out a time range from the provided filters
|
||||||
if (dataView.isTimeBased() && dataView.timeFieldName === timeFieldName) {
|
if (dataView.isTimeBased() && dataView.timeFieldName === timeFieldName) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue