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

[Discover] Deangularize discover controller #96766

Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5ebdd10
Initial work
kertal Mar 26, 2021
e69df9d
First functional version
kertal Mar 29, 2021
cc67c89
Fix tests
kertal Mar 29, 2021
a9156b5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-03…
kertal Mar 29, 2021
3eeae74
Merge branch 'master' into kertal-pr-2021-03-26-discover-refactor-his…
kibanamachine Mar 31, 2021
22b6c70
Merge deangularize controller works
kertal Apr 12, 2021
7f9c5b6
temporary quickfix for testing
kertal Apr 13, 2021
1c73275
Restore update_search_source.ts
kertal Apr 14, 2021
d8396aa
Improve code
kertal Apr 19, 2021
e5c4e44
Merge master / fix conflicts
kertal Apr 26, 2021
27caaf4
Make autorefresh work part 1
kertal Apr 26, 2021
7defd39
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal Apr 27, 2021
c8f8546
Make autorefresh work part 2
kertal Apr 27, 2021
31ce893
Fix switching index pattern test
kertal Apr 27, 2021
7056387
Fix histogram hiding test
kertal Apr 28, 2021
b226201
Merge master / fix conflicts
kertal Apr 29, 2021
8115e1d
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal Apr 29, 2021
efc6988
Fix Share functionality
kertal Apr 29, 2021
8e7eadd
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 3, 2021
9d99d5d
Fix functional runtime tests
kertal May 3, 2021
592e5f7
Fix tests and types
kertal May 3, 2021
5e05610
Fix functional test for CSV export
kertal May 3, 2021
1760b89
Improve structure
kertal May 4, 2021
2c015f0
Fix jest tests
kertal May 4, 2021
3b80313
Fix hopefully all jest tests
kertal May 4, 2021
27a6de5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 5, 2021
fd78e1f
Fix back button tesat
kertal May 5, 2021
6b65217
Fix types
kertal May 6, 2021
d452332
Fix another test
kertal May 6, 2021
55afbde
Fix search session cleanup
kertal May 6, 2021
3d5337c
Refactor
kertal May 10, 2021
3be8e49
Fix inital url propagation
kertal May 10, 2021
b8bb659
Fix use of any
kertal May 10, 2021
50f1a1f
Fix functionals
kertal May 10, 2021
8c5b851
Fix runtime field functionals
kertal May 11, 2021
fa62818
Trying to debug another functional failure
kertal May 11, 2021
1e6785f
Fix wrong runtime fields test
kertal May 11, 2021
f2998cb
Refactor folder structure
kertal May 11, 2021
45d0d94
Fix functional test
kertal May 16, 2021
4b1b56b
Fix tests, reduce re-renderings
kertal May 17, 2021
094d1af
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 17, 2021
6f0c257
Fix searchOnPageLoad functional test
kertal May 17, 2021
4b2c075
Fix another functional
kertal May 17, 2021
15ac508
Merge branch 'master' into kertal-pr-2021-04-12-discover-split-search…
kibanamachine May 17, 2021
08cd196
Adapt Observables
kertal May 18, 2021
95ebebf
Merge branch 'kertal-pr-2021-04-12-discover-split-search-source-queri…
kertal May 18, 2021
742fc80
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 18, 2021
6d27f02
Fix saved search
kertal May 18, 2021
a317c61
Fix fields counts
kertal May 18, 2021
a326264
Fix auto refresh
kertal May 19, 2021
e8add10
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 19, 2021
4b7a69d
Improve code
kertal May 19, 2021
3e30357
Undo splitting of query
kertal May 19, 2021
e95abc4
Fix types
kertal May 19, 2021
3d6f8dc
Merge branch 'master' into kertal-pr-2021-04-12-discover-split-search…
kibanamachine May 19, 2021
68a0135
Add search session test
kertal May 20, 2021
2f64e9a
Merge branch 'kertal-pr-2021-04-12-discover-split-search-source-queri…
kertal May 20, 2021
47caea2
Add unit tests for hooks
kertal May 20, 2021
f30a8e7
Add unit test for useSavedSearch
kertal May 20, 2021
cbbcd6b
Fix jest test
kertal May 20, 2021
7dba8dc
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 20, 2021
438ed24
Migrate url functions
kertal May 25, 2021
b78f2b1
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal May 25, 2021
c720140
Fixing a potential angular problem
kertal May 25, 2021
8aa36ff
Simplify code, add documentation
kertal May 25, 2021
33acd54
Merge branch 'master' into kertal-pr-2021-04-12-discover-split-search…
kibanamachine May 27, 2021
5743294
Merge branch 'master' into kertal-pr-2021-04-12-discover-split-search…
kibanamachine May 31, 2021
3ae9a40
Update src/plugins/data/common/search/search_source/search_source.ts
kertal May 31, 2021
2f3a738
Update src/plugins/discover/public/application/apps/main/utils/update…
kertal May 31, 2021
d135560
Address review feedback
kertal Jun 1, 2021
a22daf8
Merge branch 'kertal-pr-2021-04-12-discover-split-search-source-queri…
kertal Jun 1, 2021
79f563e
Fix linting error
kertal Jun 1, 2021
d2444d4
Merge branch 'master' into kertal-pr-2021-04-12-discover-split-search…
kibanamachine Jun 1, 2021
015a013
Merge upstream / fix conflicts
kertal Jun 1, 2021
6e36c37
Implement useSingleton
kertal Jun 1, 2021
07e11ea
refactor updateSearchSource and useSingleton
kertal Jun 1, 2021
f21e1c9
Switch fetchStatuses to TypeScript enum
kertal Jun 1, 2021
452798d
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal Jun 3, 2021
4677322
Fix index switching issue
kertal Jun 4, 2021
be7d95f
Add test for searchsessions with relative time ranges
kertal Jun 4, 2021
a62b187
Fix index switching issue
kertal Jun 4, 2021
5b2db51
Fix searchSession triggering double request
kertal Jun 7, 2021
10c9319
Merge remote-tracking branch 'upstream/master' into kertal-pr-2021-04…
kertal Jun 7, 2021
fc677b3
Migrate classic table to use $evalAsync
kertal Jun 7, 2021
6d1b9b7
Fix classic table scroll to bottom with $applyAsync
kertal Jun 7, 2021
692c79f
Update src/plugins/discover/public/application/apps/main/services/use…
kertal Jun 7, 2021
c823cd0
Update src/plugins/discover/public/application/apps/main/utils/update…
kertal Jun 7, 2021
3e1303a
Address review comments
kertal Jun 8, 2021
8b93117
Merge upstream / fix conflicts
kertal Jun 8, 2021
996f1fc
Improve code and typings
kertal Jun 8, 2021
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
6 changes: 5 additions & 1 deletion src/plugins/data/common/search/search_source/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const searchSourceCommonMock: jest.Mocked<ISearchStartSearchSource> = {
export const createSearchSourceMock = (fields?: SearchSourceFields) =>
new SearchSource(fields, {
getConfig: uiSettingsServiceMock.createStartContract().get,
search: jest.fn(),
search: jest
.fn()
.mockReturnValue(
of({ rawResponse: { hits: { hits: [], total: 0 } }, isPartial: false, isRunning: false })
),
onResponse: jest.fn().mockImplementation((req, res) => res),
});
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ export class SearchSource {
searchRequest.body = searchRequest.body || {};
const { body, index, query, filters, highlightAll } = searchRequest;
searchRequest.indexType = this.getIndexType(index);
const metaFields = getConfig(UI_SETTINGS.META_FIELDS);
const metaFields = getConfig(UI_SETTINGS.META_FIELDS) ?? [];

// get some special field types from the index pattern
const { docvalueFields, scriptFields, storedFields, runtimeFields } = index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
*/

import { QueryStringContract } from '.';
import { Observable } from 'rxjs';

const createSetupContractMock = () => {
const queryStringManagerMock: jest.Mocked<QueryStringContract> = {
getQuery: jest.fn(),
setQuery: jest.fn(),
getUpdates$: jest.fn(),
getUpdates$: jest.fn(() => new Observable()),
getDefaultQuery: jest.fn(),
formatQuery: jest.fn(),
clearQuery: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createSetupContractMock = () => {
getTimeUpdate$: jest.fn(),
getRefreshIntervalUpdate$: jest.fn(),
getAutoRefreshFetch$: jest.fn(() => new Observable<() => void>()),
getFetch$: jest.fn(),
getFetch$: jest.fn(() => new Observable<() => void>()),
getTime: jest.fn(),
setTime: jest.fn(),
setRefreshInterval: jest.fn(),
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/discover/public/__mocks__/index_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ fields.getByName = (name: string) => {
return fields.find((field) => field.name === name);
};

fields.getAll = () => {
return fields;
};

const indexPattern = ({
id: 'the-index-pattern-id',
title: 'the-index-pattern-title',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const fields = [
fields.getByName = (name: string) => {
return fields.find((field) => field.name === name);
};
fields.getAll = () => {
return fields;
};

const indexPattern = ({
id: 'index-pattern-with-timefield-id',
Expand All @@ -72,5 +75,8 @@ const indexPattern = ({

indexPattern.flattenHit = indexPatterns.flattenHitWrapper(indexPattern, indexPattern.metaFields);
indexPattern.isTimeBased = () => !!indexPattern.timeFieldName;
indexPattern.formatField = (hit: Record<string, unknown>, fieldName: string) => {
return fieldName === '_source' ? hit._source : indexPattern.flattenHit(hit)[fieldName];
};

export const indexPatternWithTimefieldMock = indexPattern;
3 changes: 3 additions & 0 deletions src/plugins/discover/public/__mocks__/saved_search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

import { SavedSearch } from '../saved_searches';
import { createSearchSourceMock } from '../../../data/public/mocks';
import { indexPatternMock } from './index_pattern';

export const savedSearchMock = ({
id: 'the-saved-search-id',
Expand All @@ -27,4 +29,5 @@ export const savedSearchMock = ({
],
migrationVersion: { search: '7.5.0' },
error: undefined,
searchSource: createSearchSourceMock({ index: indexPatternMock }),
} as unknown) as SavedSearch;
27 changes: 27 additions & 0 deletions src/plugins/discover/public/__mocks__/search_session.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { createMemoryHistory } from 'history';
import { dataPluginMock } from '../../../data/public/mocks';
import { DataPublicPluginStart } from '../../../data/public';
import { DiscoverSearchSessionManager } from '../application/apps/main/services/discover_search_session';

export function createSearchSessionMock() {
const history = createMemoryHistory();
const session = dataPluginMock.createStartContract().search.session as jest.Mocked<
DataPublicPluginStart['search']['session']
>;
const searchSessionManager = new DiscoverSearchSessionManager({
history,
session,
});
return {
history,
session,
searchSessionManager,
};
}
63 changes: 63 additions & 0 deletions src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { DiscoverServices } from '../build_services';
import { dataPluginMock } from '../../../data/public/mocks';
import { chromeServiceMock, coreMock, docLinksServiceMock } from '../../../../core/public/mocks';
import { DEFAULT_COLUMNS_SETTING } from '../../common';
import { savedSearchMock } from './saved_search';
import { UI_SETTINGS } from '../../../data/common';
import { TopNavMenu } from '../../../navigation/public';
const dataPlugin = dataPluginMock.createStartContract();

export const discoverServiceMock = ({
core: coreMock.createStart(),
chrome: chromeServiceMock.createStartContract(),
history: () => ({
location: {
search: '',
},
}),
data: dataPlugin,
docLinks: docLinksServiceMock.createStartContract(),
capabilities: {
visualize: {
show: true,
},
discover: {
save: false,
},
advancedSettings: {
save: true,
},
},
filterManager: dataPlugin.query.filterManager,
uiSettings: {
get: (key: string) => {
if (key === 'fields:popularLimit') {
return 5;
} else if (key === DEFAULT_COLUMNS_SETTING) {
return [];
} else if (key === UI_SETTINGS.META_FIELDS) {
return [];
}
},
},
indexPatternFieldEditor: {
openEditor: jest.fn(),
userPermissions: {
editIndexPattern: jest.fn(),
},
},
getSavedSearchById: (id?: string) => Promise.resolve(savedSearchMock),
navigation: {
ui: { TopNavMenu },
},
metadata: {
branch: 'test',
},
} as unknown) as DiscoverServices;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { DiscoverMainApp } from '../apps/main';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createDiscoverDirective(reactDirective: any) {
return reactDirective(DiscoverMainApp, [
['indexPattern', { watchDepth: 'reference' }],
['opts', { watchDepth: 'reference' }],
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import React, { useState } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { DiscoverGrid, DiscoverGridProps } from './discover_grid/discover_grid';
import { DiscoverGrid, DiscoverGridProps } from '../components/discover_grid/discover_grid';
import { getServices } from '../../kibana_services';
import { ElasticSearchHit } from '../doc_views/doc_views_types';

Expand Down

This file was deleted.

This file was deleted.

Loading