[8.9] [Discover] Refresh fields when entering Discover (#160195) (#161154)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Discover] Refresh fields when entering Discover
(#160195)](https://github.com/elastic/kibana/pull/160195)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2023-07-04T08:19:30Z","message":"[Discover]
Refresh fields when entering Discover (#160195)\n\n- Closes
https://github.com/elastic/kibana/issues/156556\r\n- Probably also
addresses\r\nhttps://github.com/elastic/kibana/issues/157239\r\n\r\n##
Summary\r\n\r\nThis PR allows to refresh fields list when revisiting
Discover page.\r\n\r\n## For testing\r\n\r\n1. Open discover\r\n2. In a
separate tab open Dev Tools and create documents which include\r\nnew
field names\r\n3. Press \"Refresh\" in the unified search bar on
Discover and notice that\r\nnew fields appear under Unmapped
section\r\n4. Navigate to another Kibana app (for example Home
page)\r\n5. Navigate back to Discover and notice that new fields are now
under\r\nAvailable section and have a proper
icon.","sha":"4819efa8eb16529db807043d36a1214070e10c79","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:prev-minor","v8.10.0"],"number":160195,"url":"https://github.com/elastic/kibana/pull/160195","mergeCommit":{"message":"[Discover]
Refresh fields when entering Discover (#160195)\n\n- Closes
https://github.com/elastic/kibana/issues/156556\r\n- Probably also
addresses\r\nhttps://github.com/elastic/kibana/issues/157239\r\n\r\n##
Summary\r\n\r\nThis PR allows to refresh fields list when revisiting
Discover page.\r\n\r\n## For testing\r\n\r\n1. Open discover\r\n2. In a
separate tab open Dev Tools and create documents which include\r\nnew
field names\r\n3. Press \"Refresh\" in the unified search bar on
Discover and notice that\r\nnew fields appear under Unmapped
section\r\n4. Navigate to another Kibana app (for example Home
page)\r\n5. Navigate back to Discover and notice that new fields are now
under\r\nAvailable section and have a proper
icon.","sha":"4819efa8eb16529db807043d36a1214070e10c79"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160195","number":160195,"mergeCommit":{"message":"[Discover]
Refresh fields when entering Discover (#160195)\n\n- Closes
https://github.com/elastic/kibana/issues/156556\r\n- Probably also
addresses\r\nhttps://github.com/elastic/kibana/issues/157239\r\n\r\n##
Summary\r\n\r\nThis PR allows to refresh fields list when revisiting
Discover page.\r\n\r\n## For testing\r\n\r\n1. Open discover\r\n2. In a
separate tab open Dev Tools and create documents which include\r\nnew
field names\r\n3. Press \"Refresh\" in the unified search bar on
Discover and notice that\r\nnew fields appear under Unmapped
section\r\n4. Navigate to another Kibana app (for example Home
page)\r\n5. Navigate back to Discover and notice that new fields are now
under\r\nAvailable section and have a proper
icon.","sha":"4819efa8eb16529db807043d36a1214070e10c79"}}]}] BACKPORT-->

Co-authored-by: Julia Rechkunova <julia.rechkunova@elastic.co>
This commit is contained in:
Kibana Machine 2023-07-04 07:27:11 -04:00 committed by GitHub
parent b94d041dc5
commit 64a465c8f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,7 +70,7 @@ export async function loadDataView({
let fetchedDataView: DataView | null = null;
// try to fetch adhoc data view first
try {
fetchedDataView = fetchId ? await dataViews.get(fetchId, false) : null;
fetchedDataView = fetchId ? await dataViews.get(fetchId, false, true) : null;
if (fetchedDataView && !fetchedDataView.isPersisted()) {
return {
list: dataViewList || [],
@ -88,7 +88,10 @@ export async function loadDataView({
let defaultDataView: DataView | null = null;
if (!fetchedDataView) {
try {
defaultDataView = await dataViews.getDefaultDataView({ displayErrors: false });
defaultDataView = await dataViews.getDefaultDataView({
displayErrors: false,
refreshFields: true,
});
} catch (e) {
//
}