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][UnifiedFieldList] Integrate unified field list sections into Discover #144412

Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
e553508
[Discover] Integrate unified field list sections into Discover
jughosta Oct 25, 2022
9484e52
[Discover] Cleanup redundant labels
jughosta Nov 2, 2022
5526227
[Discover] Fix tests
jughosta Nov 2, 2022
c8e0261
[Discover] Fix tests
jughosta Nov 2, 2022
7d6f072
[Discover] Simplify state management
jughosta Nov 3, 2022
1844e51
[Discover] Some optimizations
jughosta Nov 3, 2022
ed7a877
[Discover] Field stats don't work when search from source anyway
jughosta Nov 3, 2022
bb56e10
[Discover] Support source filtering for fields
jughosta Nov 3, 2022
3dc92e9
[Discover] Treat unmapped fields as Available rather than Empty
jughosta Nov 3, 2022
3f53b6b
[Discover] Reduce number of iterations
jughosta Nov 3, 2022
0253e5f
[Discover] Reduce number of iterations
jughosta Nov 3, 2022
8283c20
[Discover] Change sorting for Popular fields
jughosta Nov 4, 2022
58737e8
[Discover] Address feedback
jughosta Nov 4, 2022
e36e82b
[Discover] Fix the list for text-based queries
jughosta Nov 4, 2022
9646189
Merge remote-tracking branch 'upstream/main' into 135678-unified-fiel…
jughosta Nov 7, 2022
b03dc22
[Discover] Address feedback decisions
jughosta Nov 7, 2022
f95ca8f
[Discover] Update tests
jughosta Nov 7, 2022
a6a425d
[Discover] Update tests
jughosta Nov 7, 2022
a1ce598
[Discover] Update tests
jughosta Nov 7, 2022
2aa04bb
[Discover] Update tests
jughosta Nov 7, 2022
5ce748a
[Discover] Decopule fields list from search responses as much as poss…
jughosta Nov 7, 2022
ac45d91
[Discover] Improve scroll position
jughosta Nov 7, 2022
d6e2fc2
[Discover] Remove redundant code
jughosta Nov 7, 2022
f86b1d1
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 7, 2022
7646eaa
[Discover] Fix types
jughosta Nov 7, 2022
a7e1f4e
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 7, 2022
6063a2a
[Discover] Fix flaky test
jughosta Nov 7, 2022
b43fc9a
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 8, 2022
bc71a63
[Discover] Fix product tour step
jughosta Nov 8, 2022
8496420
[Discover] Improve tests
jughosta Nov 8, 2022
fe33f8c
[Discover] Memorize the date range
jughosta Nov 8, 2022
1e1a29b
[Discover] Switch to debounce to handle date range changes on rerende…
jughosta Nov 8, 2022
1f8b074
Revert "[Discover] Switch to debounce to handle date range changes on…
jughosta Nov 8, 2022
40c25a1
[Discover] Fix the issue with everchanging timefilter
jughosta Nov 8, 2022
ae8599c
[Discover] Update tests
jughosta Nov 9, 2022
bb97068
[Discover] Add tooltips
jughosta Nov 9, 2022
ce8b29f
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 9, 2022
e9fd527
[Discover] Simplify
jughosta Nov 9, 2022
dbacb1f
[Discover] Fix stuck jest tests
jughosta Nov 9, 2022
fdefefa
Revert "[Discover] Simplify"
jughosta Nov 9, 2022
2d601b9
[Discover] Add more tests
jughosta Nov 9, 2022
911ae87
[Discover] Fix types in tests
jughosta Nov 9, 2022
11f9ce2
[Discover] Add more tests
jughosta Nov 9, 2022
327be22
[Discover] Add more tests
jughosta Nov 9, 2022
14b1b66
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 9, 2022
e36cdea
[Discover] Add more tests
jughosta Nov 9, 2022
87249f6
[Discover] Add more tests
jughosta Nov 9, 2022
0387c85
[Discover] Update tooltips and fix loading state for text-based view
jughosta Nov 10, 2022
c19aed6
[Discover] Unify how props are passed
jughosta Nov 10, 2022
25cbc6e
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 10, 2022
5d19232
[Discover] Switch to useReducer for sidebar state management
jughosta Nov 10, 2022
6a43c36
[Discover] Update tests
jughosta Nov 10, 2022
0b4b550
[Discover] Update security tests
jughosta Nov 10, 2022
cdacac2
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 10, 2022
63762f0
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 14, 2022
eba96e6
[Discover] Disable auto fetching of existence info
jughosta Nov 14, 2022
d5fb4c3
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 14, 2022
34c2e9e
[Discover] Add reducer tests. Optimize selected fields calculation.
jughosta Nov 14, 2022
dddc675
[Discover] Remove now redundant refetching
jughosta Nov 14, 2022
3e8d652
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 14, 2022
c3d0869
[Discover] Add functional tests
jughosta Nov 14, 2022
7ac4a61
[Discover] Add more functional tests
jughosta Nov 14, 2022
31ad88b
[Discover] Add more functional tests
jughosta Nov 14, 2022
995b240
[Discover] Fix for functional tests
jughosta Nov 15, 2022
5051bdc
[Discover] Add more functional tests
jughosta Nov 15, 2022
4997908
[Discover] Add more functional tests
jughosta Nov 15, 2022
d9660de
[Discover] Add more functional tests
jughosta Nov 15, 2022
5924441
[Discover] Add more functional tests
jughosta Nov 15, 2022
4db348e
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 15, 2022
40e467c
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 15, 2022
09d2f74
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 17, 2022
3750b1f
[Discover] Update codeowners file with tests path
jughosta Nov 17, 2022
c480c4b
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 17, 2022
604d916
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 17, 2022
d51a153
Update x-pack/plugins/lens/public/datasources/form_based/field_item.tsx
jughosta Nov 18, 2022
1657b06
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 18, 2022
e93ae7d
[Discover] Improve performance
jughosta Nov 18, 2022
5e18565
Merge remote-tracking branch 'upstream/main' into 135678-unified-fiel…
jughosta Nov 21, 2022
e943687
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
kibanamachine Nov 21, 2022
c75cae3
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 22, 2022
5718800
Merge remote-tracking branch 'upstream/main' into 135678-unified-fiel…
jughosta Nov 23, 2022
9b6f3e0
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 23, 2022
0020e6f
[Discover] Unify date range memorization
jughosta Nov 23, 2022
b52f10a
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 23, 2022
3cf67e4
[Discover] Restore collator options
jughosta Nov 23, 2022
ae66008
[Discover] Remove logs
jughosta Nov 23, 2022
f1605a3
[Discover] Address PR comments
jughosta Nov 24, 2022
5ef5bb1
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 24, 2022
81ba57e
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 28, 2022
569ae1b
[Discover] Fix when New is pressed
jughosta Nov 28, 2022
8fd5e8d
[Discover] Fix Popluar fields (exclude subfields)
jughosta Nov 28, 2022
25ae000
[Discover] Fix Available fields (exclude subfields) when searched fro…
jughosta Nov 28, 2022
fffd5ce
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Nov 28, 2022
79ac33b
[Discover] Fix tests
jughosta Nov 28, 2022
611b747
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
stratoula Nov 30, 2022
1d46c8a
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Dec 1, 2022
82f62a0
[Discover] Consider pinned filters too in No fields message
jughosta Dec 1, 2022
6bacfb2
Merge branch 'main' into 135678-unified-field-list-sections-in-discov…
jughosta Dec 1, 2022
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/src/plugins/discover/ @elastic/kibana-data-discovery
/src/plugins/saved_search/ @elastic/kibana-data-discovery
/x-pack/plugins/discover_enhanced/ @elastic/kibana-data-discovery
/x-pack/test/functional/apps/discover/ @elastic/kibana-data-discovery
/test/functional/apps/discover/ @elastic/kibana-data-discovery
/test/functional/apps/context/ @elastic/kibana-data-discovery
/test/api_integration/apis/unified_field_list/ @elastic/kibana-data-discovery
Expand Down
43 changes: 24 additions & 19 deletions src/plugins/discover/public/__mocks__/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ import { dataViewMock } from './data_view';
import { dataViewComplexMock } from './data_view_complex';
import { dataViewWithTimefieldMock } from './data_view_with_timefield';

export const dataViewsMock = {
getCache: async () => {
return [dataViewMock];
},
get: async (id: string) => {
if (id === 'the-data-view-id') {
return Promise.resolve(dataViewMock);
} else if (id === 'invalid-data-view-id') {
return Promise.reject('Invald');
}
},
updateSavedObject: jest.fn(),
getIdsWithTitle: jest.fn(() => {
return Promise.resolve([dataViewMock, dataViewComplexMock, dataViewWithTimefieldMock]);
}),
createFilter: jest.fn(),
create: jest.fn(),
clearInstanceCache: jest.fn(),
} as unknown as jest.Mocked<DataViewsContract>;
export function createDiscoverDataViewsMock() {
return {
getCache: async () => {
return [dataViewMock];
},
get: async (id: string) => {
if (id === 'the-data-view-id') {
return Promise.resolve(dataViewMock);
} else if (id === 'invalid-data-view-id') {
return Promise.reject('Invald');
}
},
updateSavedObject: jest.fn(),
getIdsWithTitle: jest.fn(() => {
return Promise.resolve([dataViewMock, dataViewComplexMock, dataViewWithTimefieldMock]);
}),
createFilter: jest.fn(),
create: jest.fn(),
clearInstanceCache: jest.fn(),
getFieldsForIndexPattern: jest.fn((dataView) => dataView.fields),
} as unknown as jest.Mocked<DataViewsContract>;
}

export const dataViewsMock = createDiscoverDataViewsMock();
225 changes: 123 additions & 102 deletions src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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 { EUI_CHARTS_THEME_LIGHT } from '@elastic/eui/dist/eui_charts_theme';
import { DiscoverServices } from '../build_services';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
Expand All @@ -20,117 +21,137 @@ import {
SORT_DEFAULT_ORDER_SETTING,
HIDE_ANNOUNCEMENTS,
} from '../../common';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import { UI_SETTINGS, calculateBounds } from '@kbn/data-plugin/public';
import { TopNavMenu } from '@kbn/navigation-plugin/public';
import { FORMATS_UI_SETTINGS } from '@kbn/field-formats-plugin/common';
import { LocalStorageMock } from './local_storage_mock';
import { chartPluginMock } from '@kbn/charts-plugin/public/mocks';
import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks';
import { dataViewsMock } from './data_views';
import { Observable, of } from 'rxjs';
const dataPlugin = dataPluginMock.createStartContract();
const expressionsPlugin = expressionsPluginMock.createStartContract();
import { LocalStorageMock } from './local_storage_mock';
import { createDiscoverDataViewsMock } from './data_views';

export function createDiscoverServicesMock(): DiscoverServices {
const dataPlugin = dataPluginMock.createStartContract();
const expressionsPlugin = expressionsPluginMock.createStartContract();

dataPlugin.query.filterManager.getFilters = jest.fn(() => []);
dataPlugin.query.filterManager.getUpdates$ = jest.fn(() => of({}) as unknown as Observable<void>);
dataPlugin.query.filterManager.getFilters = jest.fn(() => []);
dataPlugin.query.filterManager.getUpdates$ = jest.fn(() => of({}) as unknown as Observable<void>);
dataPlugin.query.timefilter.timefilter.createFilter = jest.fn();
dataPlugin.query.timefilter.timefilter.getAbsoluteTime = jest.fn(() => ({
from: '2021-08-31T22:00:00.000Z',
to: '2022-09-01T09:16:29.553Z',
}));
dataPlugin.query.timefilter.timefilter.getTime = jest.fn(() => {
return { from: 'now-15m', to: 'now' };
});
dataPlugin.query.timefilter.timefilter.calculateBounds = jest.fn(calculateBounds);
dataPlugin.query.getState = jest.fn(() => ({
query: { query: '', language: 'lucene' },
filters: [],
}));
dataPlugin.dataViews = createDiscoverDataViewsMock();

export const discoverServiceMock = {
core: coreMock.createStart(),
chrome: chromeServiceMock.createStartContract(),
history: () => ({
location: {
search: '',
return {
core: coreMock.createStart(),
charts: chartPluginMock.createSetupContract(),
chrome: chromeServiceMock.createStartContract(),
history: () => ({
location: {
search: '',
},
listen: jest.fn(),
}),
data: dataPlugin,
docLinks: docLinksServiceMock.createStartContract(),
capabilities: {
visualize: {
show: true,
},
discover: {
save: false,
},
advancedSettings: {
save: true,
},
},
listen: jest.fn(),
}),
data: dataPlugin,
docLinks: docLinksServiceMock.createStartContract(),
capabilities: {
visualize: {
show: true,
fieldFormats: fieldFormatsMock,
filterManager: dataPlugin.query.filterManager,
inspector: {
open: jest.fn(),
},
discover: {
save: false,
uiSettings: {
get: jest.fn((key: string) => {
if (key === 'fields:popularLimit') {
return 5;
} else if (key === DEFAULT_COLUMNS_SETTING) {
return ['default_column'];
} else if (key === UI_SETTINGS.META_FIELDS) {
return [];
} else if (key === DOC_HIDE_TIME_COLUMN_SETTING) {
return false;
} else if (key === CONTEXT_STEP_SETTING) {
return 5;
} else if (key === SORT_DEFAULT_ORDER_SETTING) {
return 'desc';
} else if (key === FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE) {
return false;
} else if (key === SAMPLE_SIZE_SETTING) {
return 250;
} else if (key === SAMPLE_ROWS_PER_PAGE_SETTING) {
return 150;
} else if (key === MAX_DOC_FIELDS_DISPLAYED) {
return 50;
} else if (key === HIDE_ANNOUNCEMENTS) {
return false;
}
}),
isDefault: (key: string) => {
return true;
},
},
advancedSettings: {
save: true,
http: {
basePath: '/',
},
},
fieldFormats: fieldFormatsMock,
filterManager: dataPlugin.query.filterManager,
inspector: {
open: jest.fn(),
},
uiSettings: {
get: jest.fn((key: string) => {
if (key === 'fields:popularLimit') {
return 5;
} else if (key === DEFAULT_COLUMNS_SETTING) {
return ['default_column'];
} else if (key === UI_SETTINGS.META_FIELDS) {
return [];
} else if (key === DOC_HIDE_TIME_COLUMN_SETTING) {
return false;
} else if (key === CONTEXT_STEP_SETTING) {
return 5;
} else if (key === SORT_DEFAULT_ORDER_SETTING) {
return 'desc';
} else if (key === FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE) {
return false;
} else if (key === SAMPLE_SIZE_SETTING) {
return 250;
} else if (key === SAMPLE_ROWS_PER_PAGE_SETTING) {
return 150;
} else if (key === MAX_DOC_FIELDS_DISPLAYED) {
return 50;
} else if (key === HIDE_ANNOUNCEMENTS) {
return false;
}
}),
isDefault: (key: string) => {
return true;
dataViewEditor: {
userPermissions: {
editDataView: () => true,
},
},
dataViewFieldEditor: {
openEditor: jest.fn(),
userPermissions: {
editIndexPattern: jest.fn(),
},
},
navigation: {
ui: { TopNavMenu, AggregateQueryTopNavMenu: TopNavMenu },
},
},
http: {
basePath: '/',
},
dataViewEditor: {
userPermissions: {
editDataView: () => true,
metadata: {
branch: 'test',
},
},
dataViewFieldEditor: {
openEditor: jest.fn(),
userPermissions: {
editIndexPattern: jest.fn(),
theme: {
useChartsTheme: jest.fn(() => EUI_CHARTS_THEME_LIGHT.theme),
useChartsBaseTheme: jest.fn(() => EUI_CHARTS_THEME_LIGHT.theme),
},
},
navigation: {
ui: { TopNavMenu, AggregateQueryTopNavMenu: TopNavMenu },
},
metadata: {
branch: 'test',
},
theme: {
useChartsTheme: jest.fn(() => EUI_CHARTS_THEME_LIGHT.theme),
useChartsBaseTheme: jest.fn(() => EUI_CHARTS_THEME_LIGHT.theme),
},
storage: new LocalStorageMock({}) as unknown as Storage,
addBasePath: jest.fn(),
toastNotifications: {
addInfo: jest.fn(),
addWarning: jest.fn(),
addDanger: jest.fn(),
addSuccess: jest.fn(),
},
expressions: expressionsPlugin,
savedObjectsTagging: {},
dataViews: dataViewsMock,
timefilter: { createFilter: jest.fn() },
locator: {
useUrl: jest.fn(() => ''),
navigate: jest.fn(),
getUrl: jest.fn(() => Promise.resolve('')),
},
contextLocator: { getRedirectUrl: jest.fn(() => '') },
singleDocLocator: { getRedirectUrl: jest.fn(() => '') },
} as unknown as DiscoverServices;
storage: new LocalStorageMock({}) as unknown as Storage,
addBasePath: jest.fn(),
toastNotifications: {
addInfo: jest.fn(),
addWarning: jest.fn(),
addDanger: jest.fn(),
addSuccess: jest.fn(),
},
expressions: expressionsPlugin,
savedObjectsTagging: {},
dataViews: dataPlugin.dataViews,
timefilter: dataPlugin.query.timefilter.timefilter,
locator: {
useUrl: jest.fn(() => ''),
navigate: jest.fn(),
getUrl: jest.fn(() => Promise.resolve('')),
},
contextLocator: { getRedirectUrl: jest.fn(() => '') },
singleDocLocator: { getRedirectUrl: jest.fn(() => '') },
} as unknown as DiscoverServices;
}

export const discoverServiceMock = createDiscoverServicesMock();
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ discover-app {
overflow: hidden;
}

.dscPageBody__sidebar {
position: relative;
}

.dscPageContent__wrapper {
padding: $euiSizeS $euiSizeS $euiSizeS 0;
overflow: hidden; // Ensures horizontal scroll of table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
DataTotalHits$,
RecordRawType,
} from '../../hooks/use_saved_search';
import { discoverServiceMock } from '../../../../__mocks__/services';
import { createDiscoverServicesMock } from '../../../../__mocks__/services';
import { FetchStatus } from '../../../types';
import { RequestAdapter } from '@kbn/inspector-plugin/common';
import { DiscoverSidebar } from '../sidebar/discover_sidebar';
Expand Down Expand Up @@ -118,14 +118,11 @@ async function mountComponent(
) {
const searchSourceMock = createSearchSourceMock({});
const services = {
...discoverServiceMock,
...createDiscoverServicesMock(),
storage: new LocalStorageMock({
[SIDEBAR_CLOSED_KEY]: prevSidebarClosed,
}) as unknown as Storage,
} as unknown as DiscoverServices;
services.data.query.timefilter.timefilter.getAbsoluteTime = () => {
return { from: '2020-05-14T11:05:13.590', to: '2020-05-14T11:20:13.590' };
};

const dataViewList = [dataView];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function DiscoverLayout({
history={history}
/>
<EuiFlexGroup className="dscPageBody__contents" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiFlexItem grow={false} className="dscPageBody__sidebar">
<SidebarMemoized
columns={columns}
documents$={savedSearchData$.documents$}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
DataTotalHits$,
RecordRawType,
} from '../../hooks/use_saved_search';
import { discoverServiceMock } from '../../../../__mocks__/services';
import { createDiscoverServicesMock } from '../../../../__mocks__/services';
import { FetchStatus } from '../../../types';
import { KibanaContextProvider, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import { buildDataTableRecord } from '../../../../utils/build_data_record';
Expand Down Expand Up @@ -110,10 +110,7 @@ const mountComponent = async ({
savedSearch?: SavedSearch;
resetSavedSearch?: () => void;
} = {}) => {
let services = discoverServiceMock;
services.data.query.timefilter.timefilter.getAbsoluteTime = () => {
return { from: '2020-05-14T11:05:13.590', to: '2020-05-14T11:20:13.590' };
};
let services = createDiscoverServicesMock();

if (storage) {
services = { ...services, storage };
Expand Down
Loading