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] Persist hide chart option to local storage #114534

Merged
merged 14 commits into from
Oct 14, 2021

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Oct 11, 2021

Summary

Release Notes: Remember most recent "hide chart" setting

Fixes: #112466
This PR stores the save/hide chart option to local storage.

Whenever a saved object is loaded, that setting takes precedence over whatever is in a local storage. When a user manually toggles a chart, that preference is stored in the local storage. It will be used from that point on any time when creating a "new" saved search or switching between index patterns.

Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support

  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
    - [ ] Any UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)
    - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)
    - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
    - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)
  • This was checked for cross-browser compatibility

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@majagrubic
Copy link
Contributor Author

majagrubic commented Oct 11, 2021

@elasticmachine merge upstream

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic added v8.0.0 v7.16.0 Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) release_note:enhancement labels Oct 13, 2021
@majagrubic majagrubic marked this pull request as ready for review October 13, 2021 11:09
@majagrubic majagrubic requested a review from a team as a code owner October 13, 2021 11:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@timroes
Copy link
Contributor

timroes commented Oct 13, 2021

With this change the localStorage setting will get priority over the one saved in saved searches, when the chart is hidden. I would vote for having the state saved in the saved object always getting priority over your local state when loading a saved search.

Example: Save a saved search with a shown chart, toggle to a different index pattern, hide the chart now, load the previously saved search: The saved search appears, but the chart is hidden (despite the saved object had a hiddenChart: false in it.

My preferred behavior would be: whenever a saved object is loaded we use that setting. Whenever a user manually toggle a chart, store that new one in the local storage, use the local storage setting anytime when creating a "new" saved search or switching between index patterns, but not when loading a previously saved search.

@kertal @dmitriynj what are your thoughts around that?

@kertal
Copy link
Member

kertal commented Oct 13, 2021

I would vote for having the state saved in the saved object always getting priority over your local state when loading a saved search.

yes, saved search setting should get priority over local state 👍. local storage persistence should be used for human interaction, and users will be pleased, I'm sure

@kertal kertal added the Feature:Discover Discover Application label Oct 13, 2021
@majagrubic majagrubic marked this pull request as draft October 13, 2021 16:42
@majagrubic majagrubic marked this pull request as ready for review October 13, 2021 19:30
@majagrubic
Copy link
Contributor Author

lmk if this is more inline with what you described

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM, works as expected, tested a-la-carte with Safari, Chrome, Firefox. It's nice useful add-on , a little detail that improves UX in Discover 👍

});

after(async () => {
await kibanaServer.uiSettings.unset('timepicker:timeDefaults');
Copy link
Member

Choose a reason for hiding this comment

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

'timepicker:timeDefaults' do we need to reset this? since it has not been set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I thought this was unsetting the default time in Discover 🤦‍♀️

@kertal
Copy link
Member

kertal commented Oct 14, 2021

Additional note: think adding a bit more description to the PR , how it behaves when saved searches are load would be useful

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 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
discover 328.7KB 328.9KB +149.0B

History

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

@majagrubic majagrubic merged commit 45a0032 into elastic:master Oct 14, 2021
@majagrubic majagrubic deleted the save-chart-preferences branch October 14, 2021 17:22
majagrubic pushed a commit to majagrubic/kibana that referenced this pull request Oct 14, 2021
* Persist hide chart to local storage

* [Discover] Persist hide chart option to local storage

* Fix state

* Fix dependency check

* Set chart state to undefined

* Update unit test

* Do not override saved search preferences

* Fix missing import

* Add a functional test

* Add a functional test

* Fix functional test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
majagrubic pushed a commit that referenced this pull request Oct 14, 2021
)

* Persist hide chart to local storage

* [Discover] Persist hide chart option to local storage

* Fix state

* Fix dependency check

* Set chart state to undefined

* Update unit test

* Do not override saved search preferences

* Fix missing import

* Add a functional test

* Add a functional test

* Fix functional test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
artem-shelkovnikov pushed a commit to artem-shelkovnikov/kibana that referenced this pull request Oct 20, 2021
* Persist hide chart to local storage

* [Discover] Persist hide chart option to local storage

* Fix state

* Fix dependency check

* Set chart state to undefined

* Update unit test

* Do not override saved search preferences

* Fix missing import

* Add a functional test

* Add a functional test

* Fix functional test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store enabled/disabled state of the chart at the top of Discover
5 participants