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

[Dashboard] fix custom time ranges not applied to panel until global query context changes #155458

Merged
merged 18 commits into from
Apr 26, 2023

Conversation

ThomThomson
Copy link
Contributor

@ThomThomson ThomThomson commented Apr 20, 2023

Fixes #155409

#152516 incorrectly attempted to resolve #151221. #152516 updated shouldFetch$ to only check searchSessionId to determine if re-fetching is required. This logic did not work when custom time ranges are applied to panels since custom time ranges do not require new search session id yet the time range changed.

This PR reverts shouldFetch$ logic of only checking searchSessionId to determine if re-fetching is required.

Instead, this PR moves searchSessionId out of input and into dashboard instance state. That way, input updates, such as query, do not trigger additional input updates. The PR also updates seachSessionId logic from async to sync so that dashboard can update seachSessionId on input changes prior to child embeddables updating to parent input changes. This avoids the double fetch and allows children to only have a single input update on query state change.

There was a functional test, panel_time_range, that should have caught the regression but that test had a bug in it. The assertion that the custom time range was applied looked like expect(await testSubjects.exists('emptyPlaceholder')) which will never fail the test because the last part of the expect is missing. Instead, the statements should be expect(await testSubjects.exists('emptyPlaceholder')).to.be(true). These updates to the functional test would have caught the regression (I verified this by making these changes on main and running the test. They do indeed fail).

… parent input subscription, remove session only check from should fetch logic
@ThomThomson ThomThomson added Feature:Dashboard Dashboard related features Feature:Embedding Embedding content via iFrame Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:critical This issue should be addressed immediately due to a critical level of impact on the product. labels Apr 20, 2023
@nreese
Copy link
Contributor

nreese commented Apr 24, 2023

@elasticmachine merge upstream

@nreese nreese force-pushed the searchSession/cleanup branch from b171d38 to dbd7286 Compare April 24, 2023 21:47
@nreese nreese force-pushed the searchSession/cleanup branch from 2474fae to 88daae1 Compare April 25, 2023 14:18
@nreese nreese changed the title [Dashboard] Refetch Logic Cleanup [Dashboard] fix custom time ranges not applied to panel until global query context changes Apr 25, 2023
@nreese nreese marked this pull request as ready for review April 25, 2023 18:16
@nreese nreese requested a review from a team as a code owner April 25, 2023 18:16
@nreese nreese requested a review from a team as a code owner April 25, 2023 18:16
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Contributor

@Heenawter Heenawter left a comment

Choose a reason for hiding this comment

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

Tested locally + code review. Left a couple very-very minor nits/questions but otherwise looks great! 🎉

Comment on lines +62 to +71
if (!diffingFunction) {
return fastIsEqual(diffFunctionProps.currentValue, diffFunctionProps.lastValue);
}

if (diffingFunction?.prototype?.name === 'AsyncFunction') {
throw new Error(
`The function for key "${key}" is async, must use isKeyEqualAsync for asynchronous functions`
);
}
return diffingFunction(propsAsNever);
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: Hmm.... I wonder if we could make it clearer when we use isKeyEqualAsync versus isKeyEqual (synchronous) - either with a comment or perhaps by making the naming clearer? Like, isKeyEqualAsync -> unsavedChangesIsKeyEqual and isKeyEqual -> shouldRefreshIsKeyEqual... Not sure if that's too specific

@nreese nreese requested a review from a team as a code owner April 25, 2023 21:40
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 434.5KB 434.7KB +177.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
embeddable 75.7KB 75.6KB -57.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 395 398 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 475 478 +3
total +5

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @nreese @ThomThomson

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Data Discovery changes LGTM 👍

Is it expected that a custom time range is not applied when opening a saved search panel data in Discover via "Open in Discover" menu option? Nevermind, not related to this PR. Opened an issue #155852

@nreese nreese merged commit 049c510 into elastic:main Apr 26, 2023
@kibanamachine kibanamachine added v8.8.0 backport:skip This commit does not require backporting labels Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Dashboard Dashboard related features Feature:Embedding Embedding content via iFrame impact:critical This issue should be addressed immediately due to a critical level of impact on the product. loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.8.0
Projects
None yet
8 participants