Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Embeddable Rebuild] [Saved Search] Migrate saved search embeddable to new embeddable framework #180536

Merged
merged 144 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 114 commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
401a86e
Going to move embeddable registry back to Discover plugin
Heenawter Apr 9, 2024
ed20b74
Move back to Discover plugin
Heenawter Apr 10, 2024
bb088e1
Fix unlink bug
Heenawter Apr 10, 2024
2fcf18d
Fix some typing
Heenawter Apr 10, 2024
d4e70b3
Move embeddable registration to saved search plugin
Heenawter Apr 10, 2024
6d66c47
Move fixing after moving embeddable
Heenawter Apr 10, 2024
135735d
Going to move embeddable back to Discover LOL - too much shared code
Heenawter Apr 11, 2024
9fa6d18
Move back to Discover
Heenawter Apr 11, 2024
136d656
Starting to figure it out... maybe
Heenawter Apr 12, 2024
fb2398c
Working on getting fetching to work
Heenawter Apr 15, 2024
438bfa0
Switch to new fetch subscription
Heenawter Apr 15, 2024
d2f9cbb
Some small cleanups
Heenawter Apr 15, 2024
115180b
Starting to make column callbacks work
Heenawter Apr 15, 2024
c8730c2
Small cleanup + getting more actions working
Heenawter Apr 15, 2024
01f3647
Delete duplicated code
Heenawter Apr 15, 2024
da65460
Make filtering work
Heenawter Apr 16, 2024
ed654cf
Do some component separation + get parent filtering to work
Heenawter Apr 16, 2024
810fbae
Do some more cleanup
Heenawter Apr 16, 2024
faf8ce2
Rearrange some things
Heenawter Apr 16, 2024
26c50c0
Tiny cleanup
Heenawter Apr 16, 2024
43976a5
Starting to convert tests
Heenawter Apr 17, 2024
d2b6f98
Modify + add search source tests
Heenawter Apr 17, 2024
3f02cec
Clean up to run tests
Heenawter Apr 17, 2024
14ac3c8
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Apr 17, 2024
c128ace
Work on adding editing + unlink still broken
Heenawter Apr 22, 2024
ec0fafb
Clean up merge conflicts
Heenawter Apr 23, 2024
7eae7c2
Change how app target is fetched
Heenawter Apr 23, 2024
9b5440a
Conditionally add edit capabilities
Heenawter Apr 30, 2024
87dba53
Do some more cleanup after merge
Heenawter Apr 30, 2024
8ff3ed0
Register saved object
Heenawter Apr 30, 2024
8ebda3f
Fix error caused by merge conflict
Heenawter Apr 30, 2024
de3f1a2
Fix comparator
Heenawter Apr 30, 2024
357920c
Add runtime state type
Heenawter May 2, 2024
770532a
Clean up merge conflicts
Heenawter May 29, 2024
eece65d
Working on getting saved search working after merge
Heenawter May 31, 2024
d439c6c
Get link + unlink working
Heenawter May 31, 2024
095a023
Make sort work
Heenawter Jun 3, 2024
1921699
Fix state diffing
Heenawter Jun 3, 2024
6e99ece
Fix defaults
Heenawter Jun 3, 2024
b367de5
Fix default title/description + remove attribute service
Heenawter Jun 3, 2024
923a080
Fix titles + descriptions when unlinking
Heenawter Jun 3, 2024
c31e36b
Merge branch 'main' of github.com:elastic/kibana into refactor-saved-…
Heenawter Jun 4, 2024
90b21d9
Fix merge conflict
Heenawter Jun 4, 2024
41c80fe
Fix clone panel
Heenawter Jun 5, 2024
ad5710c
Cleaner fix for cloning
Heenawter Jun 5, 2024
d8a5cd1
Fix references backup
Heenawter Jun 5, 2024
76cbb98
Fix editing of by reference
Heenawter Jun 6, 2024
9030b49
Make runtime state serializable
Heenawter Jun 6, 2024
034a9b7
Fix filter actions
Heenawter Jun 6, 2024
a121a07
Fix types
Heenawter Jun 6, 2024
5e028e3
Fix ESQL
Heenawter Jun 7, 2024
6be016f
Do some initial clean up
Heenawter Jun 7, 2024
e2e6dc4
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 7, 2024
dae85af
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 7, 2024
a0e1358
Make timeslice work with ESQL
Heenawter Jun 7, 2024
51bd00e
Merge branch 'refactor-saved-search_2024-04-05' of github.com:heenawt…
Heenawter Jun 7, 2024
63ae404
Fix some types
Heenawter Jun 7, 2024
f25f68f
Fix hit count
Heenawter Jun 7, 2024
ee2b882
Fix more types
Heenawter Jun 7, 2024
5197cdd
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 7, 2024
29d82cb
Merge branch 'main' of github.com:elastic/kibana into refactor-saved-…
Heenawter Jun 10, 2024
a91953c
Fix merge conflicts
Heenawter Jun 10, 2024
6e23e4e
Fix some test failures
Heenawter Jun 10, 2024
70518d5
Fix more types
Heenawter Jun 10, 2024
5e6e7bf
Remove clone fix + change save behaviour of saved search
Heenawter Jun 10, 2024
067b078
Small cleanup
Heenawter Jun 11, 2024
6ba2864
Add fetch warnings + fix titles + fix time range
Heenawter Jun 11, 2024
b3bec84
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jun 12, 2024
53b2c3b
Fix sorting for ES|QL tables
Heenawter Jun 12, 2024
655be4f
Fix execution context
Heenawter Jun 12, 2024
ef3e11d
Fix types
Heenawter Jun 12, 2024
e6f0985
Fix loading + sample size
Heenawter Jun 13, 2024
9514e6a
Clean up the search embeddable API
Heenawter Jun 13, 2024
2018ee3
More cleanup + fix failing tests
Heenawter Jun 13, 2024
e6d8437
More cleanup + fix state bug
Heenawter Jun 13, 2024
7b545d7
Merge branch 'main' of github.com:elastic/kibana into refactor-saved-…
Heenawter Jun 18, 2024
dfeac53
Do some more cleanup
Heenawter Jun 18, 2024
6eab288
Undo changes to saved search grid
Heenawter Jun 18, 2024
a4637f1
Fix imports
Heenawter Jun 18, 2024
cdf5287
More cleanup + fix tests
Heenawter Jun 18, 2024
16dd8c4
Add context to comment
Heenawter Jun 18, 2024
5810551
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jun 19, 2024
40ba2d4
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jun 19, 2024
4648fb2
More clean up + add tests
Heenawter Jun 19, 2024
15069c2
Merge branch 'refactor-saved-search_2024-04-05' of github.com:heenawt…
Heenawter Jun 19, 2024
d87d622
Fix duplication
Heenawter Jun 19, 2024
1504436
stash runtime state
Heenawter Jun 19, 2024
faf7653
Merge branch 'main' into refactor-saved-search_2024-04-05
kibanamachine Jun 19, 2024
da99bd1
Fix merge conflict
Heenawter Jun 19, 2024
8ab617a
More more cleanup + fix timeslice fetching
Heenawter Jun 19, 2024
fd15e75
Add time range to fetch API
Heenawter Jun 20, 2024
c2a9ea7
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jun 20, 2024
3a1c230
Undo container changes
Heenawter Jun 20, 2024
299fb66
Add `getByValueRuntimeSnapshot`
Heenawter Jun 20, 2024
3e34cf8
Fix Canvas types
Heenawter Jun 20, 2024
6c92c40
Use non-legacy unlink action
Heenawter Jun 20, 2024
8169f8d
Undo changes to `duplicate_dashboard_panel`
Heenawter Jun 20, 2024
53580df
Merge branch 'main' into refactor-saved-search_2024-04-05
kibanamachine Jun 24, 2024
ff01107
Remove unused export
Heenawter Jun 27, 2024
31669d2
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jun 27, 2024
4362c2e
Address `TODO`
Heenawter Jun 27, 2024
af76713
Add time range to `FieldStatsTable`
Heenawter Jul 2, 2024
83ef665
Merge branch 'main' of github.com:elastic/kibana into refactor-saved-…
Heenawter Jul 2, 2024
59090fd
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 3, 2024
c8013da
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 5, 2024
7ebcf02
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 8, 2024
72c6f7c
Remove `breakdownField`
Heenawter Jul 9, 2024
5e3c453
Add embeddable tests
Heenawter Jul 9, 2024
76b5d43
Fix import
Heenawter Jul 10, 2024
0202cc5
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 10, 2024
66cd738
Re-add `toSavedSearch` test
Heenawter Jul 10, 2024
48e6cfe
Fix unnecessary promise
Heenawter Jul 10, 2024
dd4db62
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 10, 2024
f0df3bb
Fix types in test
Heenawter Jul 10, 2024
da72b44
Fix by-reference overwrite state
Heenawter Jul 10, 2024
0d74cd8
Mark `serializeState` as `async`
Heenawter Jul 10, 2024
2fc8a7f
Replace `serializable` in deserialize and remove it from serialize
Heenawter Jul 10, 2024
a5bdb62
Fix max allowed sample size
Heenawter Jul 12, 2024
17f855b
Fix `hidePanelTitles`
Heenawter Jul 12, 2024
53a02a8
Fix panel-level filters
Heenawter Jul 12, 2024
f6361c1
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 12, 2024
94aeb72
Fix imports
Heenawter Jul 12, 2024
fcfa1b1
Fix comment
Heenawter Jul 12, 2024
3ba4ce9
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 12, 2024
b846b83
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 15, 2024
3883fe1
Fix grid
Heenawter Jul 15, 2024
080e20a
Fix typo in comment
Heenawter Jul 15, 2024
1430d53
Fix type of mock
Heenawter Jul 16, 2024
7ba7df4
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 16, 2024
113048a
Fix add new panel + backup with runtime state
Heenawter Jul 16, 2024
510fedc
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 17, 2024
e96522e
Make saved search plugin changes
Heenawter Jul 19, 2024
6491931
Merge branch 'refactor-saved-search_2024-04-05' of github.com:heenawt…
Heenawter Jul 19, 2024
6de3429
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 19, 2024
bfcf0cf
Remove unnecessary filters update
Heenawter Jul 19, 2024
1b61a41
Merge branch 'refactor-saved-search_2024-04-05' of github.com:heenawt…
Heenawter Jul 19, 2024
177fed2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 19, 2024
19cf82a
Remove `id` from `toSavedSearch` + rename
Heenawter Jul 19, 2024
2c9e264
More small cleanups
Heenawter Jul 19, 2024
78c2f60
Use saved search columns in field stats table
Heenawter Jul 19, 2024
9e24c2d
Clean up abort controller
Heenawter Jul 19, 2024
229d241
Add refetch test + fix `onAddFilter`
Heenawter Jul 19, 2024
0ece8d7
Fix failing tests
Heenawter Jul 19, 2024
56d65a8
Merge branch 'main' into refactor-saved-search_2024-04-05
Heenawter Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ import { CoreStart } from '@kbn/core/public';
import { coreMock } from '@kbn/core/public/mocks';
import type { SearchSource } from '@kbn/data-plugin/common';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { PublishesSavedSearch } from '@kbn/discover-plugin/public';
import { dataViewMock } from '@kbn/discover-utils/src/__mocks__';
import { LicenseCheckState } from '@kbn/licensing-plugin/public';
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { EmbeddableApiContext } from '@kbn/presentation-publishing';
import { ReportingAPIClient } from '@kbn/reporting-public';
import type { ClientConfigType } from '@kbn/reporting-public/types';
import {
ActionContext,
type PanelActionDependencies,
ReportingCsvPanelAction,
} from './get_csv_panel_action';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import { BehaviorSubject } from 'rxjs';
import { ReportingCsvPanelAction, type PanelActionDependencies } from './get_csv_panel_action';

const core = coreMock.createSetup();
let apiClient: ReportingAPIClient;

describe('GetCsvReportPanelAction', () => {
let csvConfig: ClientConfigType['csv'];
let context: ActionContext;
let context: EmbeddableApiContext;
let mockLicenseState: LicenseCheckState;
let mockSearchSource: SearchSource;
let mockStartServicesPayload: [CoreStart, PanelActionDependencies, unknown];
Expand Down Expand Up @@ -93,9 +92,7 @@ describe('GetCsvReportPanelAction', () => {
context = {
embeddable: {
type: 'search',
getSavedSearch: () => {
return { searchSource: mockSearchSource };
},
savedSearch$: new BehaviorSubject({ searchSource: mockSearchSource }),
getTitle: () => `The Dude`,
getInspectorAdapters: () => null,
getInput: () => ({
Expand All @@ -106,8 +103,11 @@ describe('GetCsvReportPanelAction', () => {
},
}),
hasTimeRange: () => true,
parentApi: {
viewMode: new BehaviorSubject('view'),
},
},
} as unknown as ActionContext;
} as EmbeddableApiContext;
});

afterEach(() => {
Expand Down Expand Up @@ -145,12 +145,10 @@ describe('GetCsvReportPanelAction', () => {
getField: jest.fn((name) => (name === 'index' ? dataViewMock : undefined)),
getSerializedFields: jest.fn().mockImplementation(() => ({ testData: 'testDataValue' })),
} as unknown as SearchSource;
context.embeddable.getSavedSearch = () => {
return {
searchSource: mockSearchSource,
columns: ['column_a', 'column_b'],
} as unknown as SavedSearch;
};
(context.embeddable as PublishesSavedSearch).savedSearch$ = new BehaviorSubject({
searchSource: mockSearchSource,
columns: ['column_a', 'column_b'],
} as unknown as SavedSearch);

const panel = new ReportingCsvPanelAction({
core,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,34 @@ import {
ThemeServiceSetup,
} from '@kbn/core/public';
import { DataPublicPluginStart, SerializedSearchSourceFields } from '@kbn/data-plugin/public';
import type { ISearchEmbeddable } from '@kbn/discover-plugin/public';
import { loadSharingDataHelpers, SEARCH_EMBEDDABLE_TYPE } from '@kbn/discover-plugin/public';
import type { IEmbeddable } from '@kbn/embeddable-plugin/public';
import {
loadSharingDataHelpers,
SEARCH_EMBEDDABLE_TYPE,
apiPublishesSavedSearch,
PublishesSavedSearch,
HasTimeRange,
} from '@kbn/discover-plugin/public';
import { ViewMode } from '@kbn/embeddable-plugin/public';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
import type { SavedSearch } from '@kbn/saved-search-plugin/public';
import {
apiCanAccessViewMode,
apiHasType,
apiIsOfType,
CanAccessViewMode,
EmbeddableApiContext,
getInheritedViewMode,
HasType,
} from '@kbn/presentation-publishing';
import { toMountPoint } from '@kbn/react-kibana-mount';
import { CSV_REPORTING_ACTION, JobAppParamsCSV } from '@kbn/reporting-export-types-csv-common';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import type { UiActionsActionDefinition as ActionDefinition } from '@kbn/ui-actions-plugin/public';
import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public';

import { CSV_REPORTING_ACTION, JobAppParamsCSV } from '@kbn/reporting-export-types-csv-common';
import type { ClientConfigType } from '@kbn/reporting-public/types';
import { checkLicense } from '@kbn/reporting-public/license_check';
import type { ReportingAPIClient } from '@kbn/reporting-public/reporting_api_client';
import { getI18nStrings } from './strings';

function isSavedSearchEmbeddable(
embeddable: IEmbeddable | ISearchEmbeddable
): embeddable is ISearchEmbeddable {
return embeddable.type === SEARCH_EMBEDDABLE_TYPE;
}

export interface ActionContext {
embeddable: ISearchEmbeddable;
}
import { getI18nStrings } from './strings';

export interface PanelActionDependencies {
data: DataPublicPluginStart;
Expand Down Expand Up @@ -79,7 +82,19 @@ interface ExecutionParams {
i18nStart: I18nStart;
}

export class ReportingCsvPanelAction implements ActionDefinition<ActionContext> {
type GetCsvActionApi = HasType & PublishesSavedSearch & CanAccessViewMode & HasTimeRange;

const compatibilityCheck = (api: EmbeddableApiContext['embeddable']): api is GetCsvActionApi => {
return (
apiHasType(api) &&
apiIsOfType(api, SEARCH_EMBEDDABLE_TYPE) &&
apiPublishesSavedSearch(api) &&
apiCanAccessViewMode(api) &&
Boolean((api as unknown as HasTimeRange).hasTimeRange)
);
};

export class ReportingCsvPanelAction implements ActionDefinition<EmbeddableApiContext> {
private isDownloading: boolean;
public readonly type = '';
public readonly id = CSV_REPORTING_ACTION;
Expand Down Expand Up @@ -118,10 +133,10 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
return await getSharingData(savedSearch.searchSource, savedSearch, { uiSettings, data });
}

public isCompatible = async (context: ActionContext) => {
public isCompatible = async (context: EmbeddableApiContext) => {
const { embeddable } = context;

if (embeddable.type !== 'search') {
if (!compatibilityCheck(embeddable)) {
return false;
}

Expand All @@ -138,7 +153,7 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
return false;
}

return embeddable.getInput().viewMode !== ViewMode.EDIT;
return getInheritedViewMode(embeddable) !== ViewMode.EDIT;
};

/**
Expand Down Expand Up @@ -240,14 +255,14 @@ export class ReportingCsvPanelAction implements ActionDefinition<ActionContext>
});
};

public execute = async (context: ActionContext) => {
public execute = async (context: EmbeddableApiContext) => {
const { embeddable } = context;

if (!isSavedSearchEmbeddable(embeddable) || !(await this.isCompatible(context))) {
if (!compatibilityCheck(embeddable) || !(await this.isCompatible(context))) {
throw new IncompatibleActionError();
}

const savedSearch = embeddable.getSavedSearch();
const savedSearch = embeddable.savedSearch$.getValue();

if (!savedSearch || this.isDownloading) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"@kbn/ui-actions-plugin",
"@kbn/react-kibana-mount",
"@kbn/reporting-public",
"@kbn/presentation-publishing",
]
}
13 changes: 3 additions & 10 deletions packages/kbn-reporting/public/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node"
]
"types": ["jest", "node"]
},
"include": [
"**/*.ts", "**/*.tsx"
],
"exclude": [
"target/**/*"
],
"include": ["**/*.ts", "**/*.tsx"],
"exclude": ["target/**/*"],
"kbn_references": [
"@kbn/reporting-common",
"@kbn/core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ export const UnifiedDataTable = ({
data-test-subj="discoverDocTable"
data-render-complete={isRenderComplete}
data-shared-item=""
data-rendering-count={1} // TODO: Fix this as part of https://github.com/elastic/kibana/issues/179376
Copy link
Contributor Author

@Heenawter Heenawter Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be handled by the RenderCompleteDispatcher, but new React embeddables no longer use this - however, since legacy embeddables are still using the RenderCompleteDispatcher, we cannot move this logic into the Presentation Panel component until all embeddables are converted to the new React embeddable system. Therefore, this will be updated to be the actual render count in #179376.

data-title={searchTitle}
data-description={searchDescription}
data-document-number={displayedRows.length}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { SavedSearchByValueAttributes } from '@kbn/saved-search-plugin/public';
import { extract, inject } from './search_inject_extract';

describe('search inject extract', () => {
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('search inject extract', () => {
id: 'id',
attributes: {
references: [{ name: 'name', type: 'type', id: '1' }],
},
} as SavedSearchByValueAttributes,
};
expect(extract(state)).toEqual({
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
*/

import type { SavedObjectReference } from '@kbn/core-saved-objects-server';
import type { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common';
import type { SearchByValueInput } from '@kbn/saved-search-plugin/public';
import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common';
import type { SavedSearchByValueAttributes } from '@kbn/saved-search-plugin/public';

export const inject = (
state: EmbeddableStateWithType,
injectedReferences: SavedObjectReference[]
): EmbeddableStateWithType => {
): EmbeddableStateWithType & { attributes?: SavedSearchByValueAttributes } => {
if (hasAttributes(state)) {
// Filter out references that are not in the state
// https://github.com/elastic/kibana/pull/119079
Expand All @@ -36,7 +36,7 @@ export const inject = (
};

export const extract = (
state: EmbeddableStateWithType
state: EmbeddableStateWithType & { attributes?: SavedSearchByValueAttributes }
): { state: EmbeddableStateWithType; references: SavedObjectReference[] } => {
let references: SavedObjectReference[] = [];

Expand All @@ -49,4 +49,5 @@ export const extract = (

const hasAttributes = (
state: EmbeddableStateWithType
): state is EmbeddableStateWithType & SearchByValueInput => 'attributes' in state;
): state is EmbeddableStateWithType & { attributes: SavedSearchByValueAttributes } =>
'attributes' in state;
5 changes: 4 additions & 1 deletion src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { Observable, of } from 'rxjs';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { DiscoverServices } from '../build_services';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks';
Expand Down Expand Up @@ -35,6 +35,7 @@ import { TopNavMenu } from '@kbn/navigation-plugin/public';
import { FORMATS_UI_SETTINGS } from '@kbn/field-formats-plugin/common';
import { chartPluginMock } from '@kbn/charts-plugin/public/mocks';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { embeddablePluginMock } from '@kbn/embeddable-plugin/public/mocks';
import { LocalStorageMock } from './local_storage_mock';
import { createDiscoverDataViewsMock } from './data_views';
import { SearchSourceDependencies } from '@kbn/data-plugin/common';
Expand Down Expand Up @@ -142,6 +143,7 @@ export function createDiscoverServicesMock(): DiscoverServices {
const theme = themeServiceMock.createSetupContract({ darkMode: false });

corePluginMock.theme = theme;
corePluginMock.chrome.getActiveSolutionNavId$.mockReturnValue(new BehaviorSubject(null));

return {
core: corePluginMock,
Expand All @@ -163,6 +165,7 @@ export function createDiscoverServicesMock(): DiscoverServices {
PatternAnalysisComponent: jest.fn(() => createElement('div')),
},
docLinks: docLinksServiceMock.createStartContract(),
embeddable: embeddablePluginMock.createStartContract(),
capabilities: {
visualize: {
show: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { pluck } from 'rxjs';
import { lastValueFrom } from 'rxjs';
import { i18n } from '@kbn/i18n';
import type { Query, AggregateQuery, Filter } from '@kbn/es-query';
import { Query, AggregateQuery, Filter, TimeRange } from '@kbn/es-query';
import type { Adapters } from '@kbn/inspector-plugin/common';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
Expand All @@ -30,6 +30,7 @@ export function fetchEsql({
query,
inputQuery,
filters,
inputTimeRange,
dataView,
abortSignal,
inspectorAdapters,
Expand All @@ -40,14 +41,15 @@ export function fetchEsql({
query: Query | AggregateQuery;
inputQuery?: Query;
filters?: Filter[];
inputTimeRange?: TimeRange;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it so that ES|QL saved searches now respond to the dashboard timeslider - previously, the timeslice was ignored.

dataView: DataView;
abortSignal?: AbortSignal;
inspectorAdapters: Adapters;
data: DataPublicPluginStart;
expressions: ExpressionsStart;
profilesManager: ProfilesManager;
}): Promise<RecordsFetchResponse> {
const timeRange = data.query.timefilter.timefilter.getTime();
const timeRange = inputTimeRange ?? data.query.timefilter.timefilter.getTime();
return textBasedQueryStateToAstWithValidation({
filters,
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
MAX_ROWS_PER_PAGE_OPTION,
} from './components/pager/tool_bar_pagination';
import { DocTableProps, DocTableRenderProps, DocTableWrapper } from './doc_table_wrapper';
import { SavedSearchEmbeddableBase } from '../../embeddable/saved_search_embeddable_base';
import { SavedSearchEmbeddableBase } from '../../embeddable/components/saved_search_embeddable_base';

export interface DocTableEmbeddableProps extends Omit<DocTableProps, 'dataTestSubj'> {
totalHitCount?: number;
Expand Down
Loading