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

[ML] Fix data visualizer grid failing if one of the fields failed and not updating when refreshed #115644

Merged
merged 241 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 222 commits
Commits
Show all changes
241 commits
Select commit Hold shift + click to select a range
c7a35e6
[ML] Initial embed
qn895 Jul 19, 2021
5b48b41
[ML] Initial embed props
qn895 Jul 20, 2021
a080199
[ML] Add top nav link to data viz
qn895 Jul 20, 2021
c570d42
Add visible fields
qn895 Jul 21, 2021
b2dd8cb
Add add data service to register links
qn895 Jul 22, 2021
28d54d0
Renames, refactor, use constants
qn895 Jul 22, 2021
4128150
Renames, refactor, use constants
qn895 Jul 22, 2021
9fbffbf
Update tests and mocks
qn895 Jul 25, 2021
71833e0
Merge remote-tracking branch 'upstream/master' into ml-dv-in-discover
qn895 Jul 26, 2021
eaa2563
Embeddable
qn895 Jul 26, 2021
df58def
Update hook to update upon time udpate
qn895 Jul 26, 2021
66760b0
Merge remote-tracking branch 'upstream/master' into ml-dv-link-from-d…
qn895 Jul 27, 2021
e9e18b7
Add filter support to query
qn895 Jul 27, 2021
60aaa39
Refactor filter utilities
qn895 Jul 27, 2021
95ee436
Merge in embeddable
qn895 Jul 27, 2021
e65edcf
Add filter support for embeddable
qn895 Jul 27, 2021
19eaa69
Fix saved search data undefined
qn895 Jul 27, 2021
9215bcc
Prototype aggregated view/document view switcher
qn895 Jul 27, 2021
76f9ad6
Prototype flyout
qn895 Jul 27, 2021
0e4bacb
Prototype save document view option in storage
qn895 Jul 27, 2021
c40ec0a
Fix filter and query conflict with saved search
qn895 Jul 28, 2021
8f88ffd
Minor styling edits
qn895 Jul 28, 2021
cd4baee
[ML] Initial embed
qn895 Jul 19, 2021
dedbbec
[ML] Initial embed props
qn895 Jul 20, 2021
f5a563f
Add embeddable 1
qn895 Jul 20, 2021
215a983
Add visible fields
qn895 Jul 21, 2021
e76781c
Embeddable 2
qn895 Jul 22, 2021
eb827fa
Add filter support to query
qn895 Jul 27, 2021
b39328d
Refactor filter utilities
qn895 Jul 27, 2021
51b43bd
Add filter support for embeddable
qn895 Jul 27, 2021
41030b3
Fix saved search data undefined
qn895 Jul 27, 2021
7f26d96
Prototype aggregated view/document view switcher
qn895 Jul 27, 2021
ad49939
Prototype flyout
qn895 Jul 27, 2021
25ac180
Prototype save document view option in storage
qn895 Jul 27, 2021
534c70b
Fix filter and query conflict with saved search
qn895 Jul 28, 2021
c09314e
Minor styling edits
qn895 Jul 28, 2021
3581df1
Fix missing code after conflicts
qn895 Jul 29, 2021
a9169d7
Remove dv locator and flyout
qn895 Jul 29, 2021
545221b
Make types happy
qn895 Jul 29, 2021
5fe3c5f
Fix types
qn895 Jul 29, 2021
212869a
Rename toggle option
qn895 Jul 29, 2021
cb3f492
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Jul 30, 2021
e7a2b5c
Merge upstream/main into branch
qn895 Aug 6, 2021
eaccec9
Resolve conflicts
qn895 Aug 6, 2021
2489ebd
Merge upstream/main into branch
qn895 Aug 31, 2021
d5c9378
Merge upstream/main into branch
qn895 Aug 31, 2021
2a234fc
[ML] Reduce size of chart
qn895 Aug 31, 2021
f5b44e0
[ML] Unbold name, switch icons of show distributions
qn895 Aug 31, 2021
d1e35d9
[ML] Make size consistent
qn895 Aug 31, 2021
a366559
[ML] Make page size 25
qn895 Aug 31, 2021
e843dcd
[ML] Switch to arrow right and down
qn895 Sep 1, 2021
2e69576
[ML] Make legend font smaller
qn895 Sep 1, 2021
cc6ea0b
[ML] Add user setting
qn895 Sep 1, 2021
42c1105
[ML] Add show preview by default setting
qn895 Sep 1, 2021
680259a
[ML] Match icon
qn895 Sep 1, 2021
42af191
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 2, 2021
578f49c
Add panels around the subcontent
qn895 Sep 3, 2021
5e5d13a
Add preference for aggregated vs doc
qn895 Sep 7, 2021
f353324
Fix types
qn895 Sep 7, 2021
ce47830
Merge upstream/main into branch
qn895 Sep 7, 2021
222ea5a
Fix types, add constants for adv settings
qn895 Sep 8, 2021
8d6d358
Change to data view type
qn895 Sep 8, 2021
c81a056
Temp fix for Kibana/EUI table overflow issue
qn895 Sep 8, 2021
abd8d1e
Modify line height so text is not cut off, modify widths for varying …
qn895 Sep 8, 2021
fda1711
Different width padders for different screens
qn895 Sep 8, 2021
a0e457f
Fix CI
qn895 Sep 8, 2021
3bb9c66
Fix CI
qn895 Sep 8, 2021
d23b9c4
Merge latest, move button to the right
qn895 Sep 8, 2021
96d112f
Fix width for bar charts previews
qn895 Sep 9, 2021
d36b30c
Fix toggle buttons, fix maps
qn895 Sep 9, 2021
b67f1ba
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 9, 2021
76aed63
Delete unused file
qn895 Sep 9, 2021
6a7b1ba
Fix boolean styling
qn895 Sep 13, 2021
f12711a
Change to enum, discover mode
qn895 Sep 13, 2021
b0f7d16
Hide field stats
qn895 Sep 13, 2021
bed2cd6
Hide field stats
qn895 Sep 13, 2021
f29765b
Persist show mini preview/distribution settings
qn895 Sep 13, 2021
d0d2289
Remove window size, use size observer instead
qn895 Sep 13, 2021
eb9683c
Default to document view
qn895 Sep 13, 2021
92f18bd
Remove bold, switch icon
qn895 Sep 13, 2021
d810f94
Set fixed width for top values, reduce font size in table
qn895 Sep 13, 2021
db97adf
Fix custom url tests
qn895 Sep 13, 2021
a347d83
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 13, 2021
9d52065
Update width styling for panels
qn895 Sep 13, 2021
b3bb224
Fix missing flag for Discover sidebar, jest tests
qn895 Sep 14, 2021
006aead
Fix max width
qn895 Sep 14, 2021
ae2c0c3
Workaround for sorting
qn895 Sep 14, 2021
45da099
Merge upstream/main into branch
qn895 Sep 15, 2021
3ac2293
Fix import
qn895 Sep 15, 2021
ed496bf
Fix styling
qn895 Sep 15, 2021
8fc42e2
Make height uniform, center alignment, fix map and keyword map not sa…
qn895 Sep 16, 2021
cd0e898
Revert "Make height uniform, center alignment, fix map and keyword ma…
qn895 Sep 16, 2021
cad924a
Revert "Make height uniform, center alignment, fix map and keyword ma…
qn895 Sep 16, 2021
84c4e64
Uniform height, left aligned, flex grid
qn895 Sep 16, 2021
70c3f9d
Switch top values to have labels
qn895 Sep 16, 2021
3acf891
Center content
qn895 Sep 16, 2021
1c7d4b8
Replace fixed widths with percentage
qn895 Sep 16, 2021
3517608
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 16, 2021
6eceb57
Fix table missing field types
qn895 Sep 16, 2021
b8a31ea
Add dashboard embeddable and filter support
qn895 Sep 16, 2021
90c8259
Fix file data viz styling and tests, lean up imports, remove hard cod…
qn895 Sep 16, 2021
a9db750
Add search panel/kql filter bar
qn895 Sep 17, 2021
b743a96
Temporarily fix scrolling
qn895 Sep 20, 2021
3459f02
New kql filters for data visualizer
qn895 Sep 20, 2021
ed1d4e5
Set map height so it will fit the sampler shard size text
qn895 Sep 20, 2021
22a35c0
Use eui progress labels
qn895 Sep 20, 2021
88e2e51
Merge upstream/main into branch
qn895 Sep 20, 2021
71df070
Fix spacer
qn895 Sep 20, 2021
c16cb8f
Add beta badge
qn895 Sep 20, 2021
52b8ab8
Temporarily fix scrolling
qn895 Sep 20, 2021
00c3499
Fix grow for Top Values for
qn895 Sep 21, 2021
f65f5a6
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 21, 2021
d1f0251
Fix top values getting cut off
qn895 Sep 21, 2021
a75b11f
[ML] Redesign DV with panels, resize widths responsively, add filter …
qn895 Sep 22, 2021
22389df
[ML] Update functional tests to reflect new arrow icons
qn895 Sep 22, 2021
cd9f681
[ML] Add filter buttons and KQL bars
qn895 Sep 22, 2021
5bfb9e2
[ML] Update filter bar onChange behavior
qn895 Sep 22, 2021
16298ab
[ML] Update top values filter onChange behavior
qn895 Sep 22, 2021
0a412da
[ML] Update search filters when opening saved search
qn895 Sep 22, 2021
a956d89
[ML] Clean up
qn895 Sep 22, 2021
cf25f85
[ML] Remove fit content for height
qn895 Sep 22, 2021
f78c0e0
[ML] Fix boolean legend
qn895 Sep 22, 2021
436d849
[ML] Fix header section when browser width is small to large and when…
qn895 Sep 22, 2021
1e0ebb5
[ML] Hide expander icon when dimension is xs or s & css fixes
qn895 Sep 22, 2021
06c2d40
[ML] Delete embeddables because they are not use
qn895 Sep 22, 2021
67811eb
Merge remote-tracking branch 'upstream/master' into ml-dv-redesign
qn895 Sep 22, 2021
ba1cad7
[ML] Rename view mode, refactor to separate hook, add error prompt if…
qn895 Sep 22, 2021
f0964c0
Merge remote-tracking branch 'upstream/master' into ml-dv-redesign
qn895 Sep 23, 2021
fc32cd9
[ML] Make doc count 0 for empty fields, update t/f test
qn895 Sep 23, 2021
6c91692
[ML] Add unit testing for search utils
qn895 Sep 23, 2021
d7ddcf3
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 23, 2021
4188620
Merge design responsive changes from 112870
qn895 Sep 23, 2021
5f2a228
Fix missing unsubscribe for embeddable output
qn895 Sep 23, 2021
747aa40
Remove redundant onAddFilter for this PR, fix width
qn895 Sep 23, 2021
110eeef
Rename Field Stats to Field stats to match convention
qn895 Sep 23, 2021
af5b98a
[ML] Fix expand all/collapse all behavior to override individual setting
qn895 Sep 23, 2021
fb9ec32
[ML] Fix functional tests should be 0/0%
qn895 Sep 23, 2021
024a2a7
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 24, 2021
f4a51d6
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Sep 27, 2021
0fd5389
Merge upstream/main into branch
qn895 Sep 28, 2021
c591dc2
[ML] Fix docs content spacing, rename classnames, add filters to Disc…
qn895 Sep 28, 2021
58e68b9
[ML] Fix doc count for fields that exists but have no stats
qn895 Sep 28, 2021
e92dc2a
[ML] Fix icon styling to match Discover but have text/keyword/histogram
qn895 Sep 28, 2021
b9c981f
[ML] Fix doc count for fields that exists but have no stats
qn895 Sep 28, 2021
4645ff3
[ML] Rename classnames to BEM style
qn895 Sep 28, 2021
35bdf50
Merge upstream/main into branch
qn895 Sep 30, 2021
6835aee
Resolve latest changes
qn895 Sep 30, 2021
9f52584
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Oct 4, 2021
c52f948
Merge upstream/main into branch
qn895 Oct 6, 2021
0aef3a3
Add in place ss
qn895 Sep 27, 2021
4019b5d
Refactor helper functions
qn895 Sep 27, 2021
2759e57
Refactor helper functions
qn895 Oct 4, 2021
6e5095a
Add error log
qn895 Oct 5, 2021
b159e29
Migrate overall stats to data's search
qn895 Oct 6, 2021
4a4df4c
Better handle errors
qn895 Oct 7, 2021
3d40532
Fix url so restore session brings back correct view
qn895 Oct 7, 2021
50b8642
Add progress bar
qn895 Oct 7, 2021
e3ea604
Merge branch 'master' into ml-discover-embeddable-integration
kibanamachine Oct 11, 2021
570972d
[ML] Add tests for data viz in Discover
qn895 Oct 8, 2021
dfa2bc5
Merge remote-tracking branch 'upstream/master' into wip-dv-ss
qn895 Oct 11, 2021
6ae6ba6
[ML] Change to combinelatest
qn895 Oct 11, 2021
fe9cd16
Update tests & dashboard behavior to reflect new advanced settings
qn895 Oct 11, 2021
e60b1d5
Merge remote-tracking branch 'upstream/master' into ml-discover-embed…
qn895 Oct 11, 2021
cad14c2
Update telemetry
qn895 Oct 11, 2021
122c6ca
Remove workaround after eui bump fix
qn895 Oct 11, 2021
932e27c
Merge branch 'master' into ml-discover-embeddable-integration
kibanamachine Oct 12, 2021
b6d9df8
Remove dataloader
qn895 Oct 12, 2021
d7b2de1
Snapshot
qn895 Oct 12, 2021
cf65db4
Migrate search to client side
qn895 Oct 12, 2021
02465b0
Consolidate types
qn895 Oct 12, 2021
86c9115
Change back to forkjoin instead of combinelatest for overallstats
qn895 Oct 12, 2021
99fc665
Fix missing bool clause
qn895 Oct 13, 2021
152b637
Merge upstream/main into branch
qn895 Oct 13, 2021
f9f89ad
Add login
qn895 Oct 13, 2021
b3ab9fa
Fix saved search attributes broken with latest changes
qn895 Oct 13, 2021
bec05dc
Merge upstream/main into branch
qn895 Oct 14, 2021
d70cfd3
Update tests
qn895 Oct 14, 2021
5024aa9
Merge upstream/main into branch
qn895 Oct 14, 2021
75486b7
Fix import
qn895 Oct 14, 2021
d704232
Match the no results found
qn895 Oct 14, 2021
90672ae
Merge upstream/main into branch
qn895 Oct 15, 2021
3b99fba
Reset field stats so it reloads when query is refreshed
qn895 Oct 15, 2021
56d6f3e
Reset field stats so it reloads when query is refreshed
qn895 Oct 15, 2021
8ee4777
Add doc stats
qn895 Oct 15, 2021
083211b
Merge to use hook completely
qn895 Oct 15, 2021
2e9a369
Merge to use hook completely
qn895 Oct 15, 2021
0ae56a9
Fix doc chart doesn't show up when page is first mounted
qn895 Oct 15, 2021
b9ea1a8
Fix Discover auto refresh previously didn't update
qn895 Oct 15, 2021
1a265f1
Merge branch 'ml-discover-embeddable-integration' into search-session
qn895 Oct 15, 2021
29ddc82
Merge upstream/main into branch
qn895 Oct 19, 2021
b63dd07
Fix query util to return search source's results right away. Fix texts.
qn895 Oct 19, 2021
888b834
Refactor documentStats
qn895 Oct 19, 2021
7e984ad
Merge branch 'ml-discover-embeddable-integration' into search-session
qn895 Oct 19, 2021
d9fc188
Merge remote-tracking branch 'upstream/master' into search-session
qn895 Oct 19, 2021
79b574f
Fix doc stats not showing upon page mount
qn895 Oct 19, 2021
db52aca
Fix types
qn895 Oct 19, 2021
9288736
Delete old files
qn895 Oct 19, 2021
9e6a342
Update tests & i18n
qn895 Oct 19, 2021
1e4a19e
Fix examples, tests
qn895 Oct 20, 2021
1a94698
Remove old files & routes
qn895 Oct 20, 2021
6e9fe98
Add telemetry, clean up, rename components for clarity
qn895 Oct 20, 2021
ddffbf8
Fix size of callout message
qn895 Oct 20, 2021
78cc667
Fix texts field
qn895 Oct 20, 2021
011cc88
Consolidate field type
qn895 Oct 20, 2021
48f93bd
Consolidate field type, add count to top values
qn895 Oct 20, 2021
a652b36
Fix table doesn't refresh whenever discover refresh
qn895 Oct 20, 2021
3c3e412
Clean up
qn895 Oct 20, 2021
a89be4f
Update tests
qn895 Oct 21, 2021
28d5276
Merge upstream/main into branch
qn895 Oct 21, 2021
d0903df
Remove progress on embedadble
qn895 Oct 21, 2021
ff32587
Merge upstream/main into branch
qn895 Oct 21, 2021
09df96e
Update snapshot
qn895 Oct 21, 2021
4347d91
Merge remote-tracking branch 'upstream/master' into dv-async-search-s…
qn895 Oct 25, 2021
d26711c
Clean up, consolidate searchOptions
qn895 Oct 25, 2021
f29e851
Merge upstream/main into branch
qn895 Oct 26, 2021
be3cc43
Fix new es client types
qn895 Oct 27, 2021
503955a
Merge remote-tracking branch 'upstream/master' into dv-async-search-s…
qn895 Oct 27, 2021
0f8d3d8
Fix types
qn895 Oct 27, 2021
93489c5
Fix loading state in Discover
qn895 Oct 27, 2021
996feaf
Remove unused services, Change switchMap to map, mergeMap -> switchMa…
qn895 Oct 27, 2021
ae6d265
Fix missing filters
qn895 Oct 27, 2021
8f5c5b1
Merge remote-tracking branch 'upstream/master' into dv-async-search-s…
qn895 Oct 28, 2021
8da7712
Fix message of table to show searching instead of no items found
qn895 Oct 28, 2021
30826da
Fix dashboard saved search source persisting time range
qn895 Oct 28, 2021
5a427f7
Merge remote-tracking branch 'upstream/main' into dv-async-search-sup…
qn895 Nov 1, 2021
241f3b4
[ML] Fix table message state
qn895 Nov 2, 2021
1447263
Merge branch 'main' into dv-async-search-support
kibanamachine Nov 3, 2021
107aece
[ML] Fix to not fetch field stats if cardinality is 0
qn895 Nov 3, 2021
cd65afc
[ML] Fix locator missing view mode
qn895 Nov 3, 2021
93016de
[ML] Quit right away if field doesn't exist in docs
qn895 Nov 3, 2021
817fe2d
[ML] Change to use batch and only retry with individual field if failed
qn895 Nov 4, 2021
41e7cb6
[ML] Batch requests for speed and retry failures for resiliency
qn895 Nov 4, 2021
ccb0469
No need to fetch field stats if overall stats haven't completed
qn895 Nov 5, 2021
f88e1f4
Merge upstream/main into branch
qn895 Nov 5, 2021
8b3d4c3
Wait on overallStats to complete
qn895 Nov 5, 2021
3d2d8b8
Fix types after merge
qn895 Nov 5, 2021
e48b539
Merge remote-tracking branch 'upstream/main' into dv-async-search-sup…
qn895 Nov 7, 2021
4370b44
Fix payload size too big 413, num of requests
qn895 Nov 5, 2021
0ca94c6
Merge upstream/main into branch
qn895 Nov 8, 2021
c811d4d
Merge remote-tracking branch 'upstream/main' into dv-async-search-sup…
qn895 Nov 8, 2021
9ea2537
Update field icon to using kbn/react-field package
qn895 Nov 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import './discover_layout.scss';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
EuiSpacer,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -16,7 +17,6 @@ import {
EuiPage,
EuiPageBody,
EuiPageContent,
EuiSpacer,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { METRIC_TYPE } from '@kbn/analytics';
Expand All @@ -43,8 +43,12 @@ import {
SavedSearchURLConflictCallout,
useSavedSearchAliasMatchRedirect,
} from '../../../../../saved_searches';
import { DiscoverDataVisualizerGrid } from '../../../../components/data_visualizer_grid';
import { FieldStatisticsTable } from '../../../../components/field_stats_table';
import { VIEW_MODE } from '../view_mode_toggle';
import {
DOCUMENTS_VIEW_CLICK,
FIELD_STATISTICS_VIEW_CLICK,
} from '../../../../components/field_stats_table/constants';

/**
* Local storage key for sidebar persistence state
Expand All @@ -54,7 +58,7 @@ export const SIDEBAR_CLOSED_KEY = 'discover:sidebarClosed';
const SidebarMemoized = React.memo(DiscoverSidebarResponsive);
const TopNavMemoized = React.memo(DiscoverTopNav);
const DiscoverChartMemoized = React.memo(DiscoverChart);
const DataVisualizerGridMemoized = React.memo(DiscoverDataVisualizerGrid);
const FieldStatisticsTableMemoized = React.memo(FieldStatisticsTable);

export function DiscoverLayout({
indexPattern,
Expand Down Expand Up @@ -95,8 +99,16 @@ export function DiscoverLayout({
const setDiscoverViewMode = useCallback(
(mode: VIEW_MODE) => {
stateContainer.setAppState({ viewMode: mode });

if (trackUiMetric) {
if (mode === VIEW_MODE.AGGREGATED_LEVEL) {
trackUiMetric(METRIC_TYPE.CLICK, FIELD_STATISTICS_VIEW_CLICK);
} else {
trackUiMetric(METRIC_TYPE.CLICK, DOCUMENTS_VIEW_CLICK);
}
}
},
[stateContainer]
[trackUiMetric, stateContainer]
);

const fetchCounter = useRef<number>(0);
Expand Down Expand Up @@ -315,7 +327,7 @@ export function DiscoverLayout({
stateContainer={stateContainer}
/>
) : (
<DataVisualizerGridMemoized
<FieldStatisticsTableMemoized
savedSearch={savedSearch}
services={services}
indexPattern={indexPattern}
Expand All @@ -324,6 +336,8 @@ export function DiscoverLayout({
columns={columns}
stateContainer={stateContainer}
onAddFilter={onAddFilter}
trackUiMetric={trackUiMetric}
savedSearchRefetch$={savedSearchRefetch$}
/>
)}
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const FieldInfoIcon: React.FC = memo(() => (
</EuiToolTip>
));

const DiscoverFieldTypeIcon: React.FC<{ field: IndexPatternField }> = memo(({ field }) => (
<FieldIcon type={field.type} label={getFieldTypeName(field.type)} scripted={field.scripted} />
));
const DiscoverFieldTypeIcon: React.FC<{ field: IndexPatternField }> = memo(({ field }) => {
// If it's a string type, we want to distinguish between keyword and text
const tempType = field.type === 'string' && field.esTypes ? field.esTypes[0] : field.type;
return <FieldIcon type={tempType} label={getFieldTypeName(tempType)} scripted={field.scripted} />;
});

const FieldName: React.FC<{ field: IndexPatternField }> = memo(({ field }) => {
const title =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { each, cloneDeep } from 'lodash';
import { cloneDeep, each } from 'lodash';
import { ReactWrapper } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
// @ts-expect-error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ export function getFieldTypeName(type: string) {
return i18n.translate('discover.fieldNameIcons.stringFieldAriaLabel', {
defaultMessage: 'String field',
});
case 'text':
return i18n.translate('discover.fieldNameIcons.textFieldAriaLabel', {
defaultMessage: 'Text field',
});
case 'keyword':
return i18n.translate('discover.fieldNameIcons.keywordFieldAriaLabel', {
defaultMessage: 'Keyword field',
});

case 'nested':
return i18n.translate('discover.fieldNameIcons.nestedFieldAriaLabel', {
defaultMessage: 'Nested field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,5 +411,7 @@ function createUrlGeneratorState({
}
: undefined,
useHash: false,
viewMode: appState.viewMode,
hideAggregatedPreview: appState.hideAggregatedPreview,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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.
*/

/** Telemetry related to field statistics table **/
export const FIELD_STATISTICS_LOADED = 'field_statistics_loaded';
export const FIELD_STATISTICS_VIEW_CLICK = 'field_statistics_view_click';
export const DOCUMENTS_VIEW_CLICK = 'documents_view_click';
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Filter } from '@kbn/es-query';
import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
import { IndexPatternField, IndexPattern, DataView, Query } from '../../../../../data/common';
import { DiscoverServices } from '../../../build_services';
import {
Expand All @@ -19,6 +20,8 @@ import {
} from '../../../../../embeddable/public';
import { SavedSearch } from '../../../saved_searches';
import { GetStateReturn } from '../../apps/main/services/discover_state';
import { FIELD_STATISTICS_LOADED } from './constants';
import { DataRefetch$ } from '../../apps/main/services/use_saved_search';

export interface DataVisualizerGridEmbeddableInput extends EmbeddableInput {
indexPattern: IndexPattern;
Expand All @@ -36,7 +39,7 @@ export interface DataVisualizerGridEmbeddableOutput extends EmbeddableOutput {
showDistributions?: boolean;
}

export interface DiscoverDataVisualizerGridProps {
export interface FieldStatisticsTableProps {
/**
* Determines which columns are displayed
*/
Expand Down Expand Up @@ -69,14 +72,24 @@ export interface DiscoverDataVisualizerGridProps {
* Filters query to update the table content
*/
filters?: Filter[];
/**
* State container with persisted settings
*/
stateContainer?: GetStateReturn;
/**
* Callback to add a filter to filter bar
*/
onAddFilter?: (field: IndexPatternField | string, value: string, type: '+' | '-') => void;
/**
* Metric tracking function
* @param metricType
* @param eventName
*/
trackUiMetric?: (metricType: UiCounterMetricType, eventName: string | string[]) => void;
savedSearchRefetch$?: DataRefetch$;
}

export const DiscoverDataVisualizerGrid = (props: DiscoverDataVisualizerGridProps) => {
export const FieldStatisticsTable = (props: FieldStatisticsTableProps) => {
const {
services,
indexPattern,
Expand All @@ -86,9 +99,10 @@ export const DiscoverDataVisualizerGrid = (props: DiscoverDataVisualizerGridProp
filters,
stateContainer,
onAddFilter,
trackUiMetric,
savedSearchRefetch$,
} = props;
const { uiSettings } = services;

const [embeddable, setEmbeddable] = useState<
| ErrorEmbeddable
| IEmbeddable<DataVisualizerGridEmbeddableInput, DataVisualizerGridEmbeddableOutput>
Expand All @@ -109,10 +123,16 @@ export const DiscoverDataVisualizerGrid = (props: DiscoverDataVisualizerGridProp
}
});

const refetch = savedSearchRefetch$?.subscribe(() => {
if (embeddable && !isErrorEmbeddable(embeddable)) {
embeddable.updateInput({ lastReloadRequestTime: Date.now() });
}
});
return () => {
sub?.unsubscribe();
refetch?.unsubscribe();
};
}, [embeddable, stateContainer]);
}, [embeddable, stateContainer, savedSearchRefetch$]);

useEffect(() => {
if (embeddable && !isErrorEmbeddable(embeddable)) {
Expand All @@ -135,17 +155,11 @@ export const DiscoverDataVisualizerGrid = (props: DiscoverDataVisualizerGridProp
embeddable.updateInput({
showPreviewByDefault,
});

embeddable.reload();
}
}, [showPreviewByDefault, uiSettings, embeddable]);

useEffect(() => {
return () => {
// Clean up embeddable upon unmounting
embeddable?.destroy();
};
}, [embeddable]);

useEffect(() => {
let unmounted = false;
const loadEmbeddable = async () => {
Expand Down Expand Up @@ -181,8 +195,15 @@ export const DiscoverDataVisualizerGrid = (props: DiscoverDataVisualizerGridProp
useEffect(() => {
if (embeddableRoot.current && embeddable) {
embeddable.render(embeddableRoot.current);

trackUiMetric?.(METRIC_TYPE.LOADED, FIELD_STATISTICS_LOADED);
}
}, [embeddable, embeddableRoot, uiSettings]);

return () => {
// Clean up embeddable upon unmounting
embeddable?.destroy();
};
}, [embeddable, embeddableRoot, uiSettings, trackUiMetric]);

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@

import React from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import {
DiscoverDataVisualizerGrid,
DiscoverDataVisualizerGridProps,
} from './data_visualizer_grid';
import { FieldStatisticsTable, FieldStatisticsTableProps } from './field_stats_table';

export function FieldStatsTableEmbeddable(renderProps: DiscoverDataVisualizerGridProps) {
export function FieldStatsTableSavedSearchEmbeddable(renderProps: FieldStatisticsTableProps) {
return (
<I18nProvider>
<DiscoverDataVisualizerGrid
<FieldStatisticsTable
savedSearch={renderProps.savedSearch}
services={renderProps.services}
indexPattern={renderProps.indexPattern}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
* Side Public License, v 1.
*/

export { DiscoverDataVisualizerGrid } from './data_visualizer_grid';
export { FieldStatisticsTable } from './field_stats_table';
export { FieldStatsTableSavedSearchEmbeddable } from './field_stats_table_saved_search_embeddable';
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { getDefaultSort } from '../apps/main/components/doc_table';
import { SortOrder } from '../apps/main/components/doc_table/components/table_header/helpers';
import { updateSearchSource } from './helpers/update_search_source';
import { VIEW_MODE } from '../apps/main/components/view_mode_toggle';
import { FieldStatsTableEmbeddable } from '../components/data_visualizer_grid/field_stats_table_embeddable';
import { FieldStatsTableSavedSearchEmbeddable } from '../components/field_stats_table';

export type SearchProps = Partial<DiscoverGridProps> &
Partial<DocTableProps> & {
Expand Down Expand Up @@ -391,7 +391,7 @@ export class SavedSearchEmbeddable
Array.isArray(searchProps.columns)
) {
ReactDOM.render(
<FieldStatsTableEmbeddable
<FieldStatsTableSavedSearchEmbeddable
services={searchProps.services}
indexPattern={searchProps.indexPattern}
columns={searchProps.columns}
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/discover/public/url_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { UrlGeneratorsDefinition } from '../../share/public';
import type { TimeRange, Filter, Query, QueryState, RefreshInterval } from '../../data/public';
import { esFilters } from '../../data/public';
import { setStateToKbnUrl } from '../../kibana_utils/public';
import { VIEW_MODE } from './application/apps/main/components/view_mode_toggle';

export const DISCOVER_APP_URL_GENERATOR = 'DISCOVER_APP_URL_GENERATOR';

Expand Down Expand Up @@ -75,6 +76,8 @@ export interface DiscoverUrlGeneratorState {
* id of the used saved query
*/
savedQuery?: string;
viewMode?: VIEW_MODE;
hideAggregatedPreview?: boolean;
}

interface Params {
Expand Down Expand Up @@ -104,6 +107,8 @@ export class DiscoverUrlGenerator
savedQuery,
sort,
interval,
viewMode,
hideAggregatedPreview,
}: DiscoverUrlGeneratorState): Promise<string> => {
const savedSearchPath = savedSearchId ? `view/${encodeURIComponent(savedSearchId)}` : '';
const appState: {
Expand All @@ -114,6 +119,8 @@ export class DiscoverUrlGenerator
interval?: string;
sort?: string[][];
savedQuery?: string;
viewMode?: VIEW_MODE;
hideAggregatedPreview?: boolean;
} = {};
const queryState: QueryState = {};

Expand All @@ -130,6 +137,8 @@ export class DiscoverUrlGenerator
if (filters && filters.length)
queryState.filters = filters?.filter((f) => esFilters.isFilterPinned(f));
if (refreshInterval) queryState.refreshInterval = refreshInterval;
if (viewMode) appState.viewMode = viewMode;
if (hideAggregatedPreview) appState.hideAggregatedPreview = hideAggregatedPreview;

let url = `${this.params.appBasePath}#/${savedSearchPath}`;
url = setStateToKbnUrl<QueryState>('_g', queryState, { useHash }, url);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading