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

Made index pattern selector appear without refreshing page #3598

Open
wants to merge 4 commits into
base: 4.2-7.10
Choose a base branch
from

Conversation

mpRegalado
Copy link
Member

@mpRegalado mpRegalado commented Sep 9, 2021

Previous behaviour

The index pattern selector did not show in the menu after it was created from within the app unless you either refreshed the page, exited and re-entered the app or opened the menu.

Current behaviour

Upon performing a health check, the wz menu updates its data and displays the selector for index patterns if it is needed. To achieve this, the following changes were required.

  • Redux store now handles the current index states
  • Pattern handler updates the redux store whenever there are changes
  • Wz menu reloads it's data whenever there are changes to the index patterns

To test

  • Given The app contains a single index pattern
  • And The browser is on app/wazuh#/settings?tab=configuration
  • And The user has edited and saved the index pattern
  • When The user executes the health check
  • Then An index pattern selector will appear in the menu

Closes #3579

- Redux store now handles the current index states
- Pattern handler updates the redux store whenever there are changes
- Wz menu reloads it's data whenever there are changes to the index patterns
@mpRegalado mpRegalado requested review from MauGaP, Desvelao and a team September 9, 2021 10:50
@mpRegalado mpRegalado self-assigned this Sep 9, 2021
@mpRegalado mpRegalado changed the base branch from master to 4.2-7.10 September 9, 2021 10:51
// Getting the list of index patterns
if (list) {
this.setState({
patternList: list,
Copy link
Member

@Desvelao Desvelao Sep 9, 2021

Choose a reason for hiding this comment

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

nitpick: If we move the list of valid index patterns to the Redux store, we should not use the component state for this case. Take into account this for renders or conditionals for display the index pattern selector, but it should use the values from the store instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in bff95d0

Copy link
Contributor

@CPAlejandro CPAlejandro left a comment

Choose a reason for hiding this comment

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

CR: LGTM!
Testing: It works perfectly, i have changed the text of index pattern configuration option and after execute Health-Check, it appears the index pattern selector, so LGTM!

// Getting the list of index patterns
if (list) {
this.setState({
currentSelectedPattern: AppState.getCurrentPattern(),
Copy link
Member

Choose a reason for hiding this comment

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

thought: Why the selected index pattern is saved as the state of the component? The lists of valid index patterns are saved in Redux with this PR if I am not wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a section of the code that remains unchanged, it only appears to be changed due to having executed the linter.
In any case, I believe the original intent for this code is to update the component when the selection has changed, and not when the list of available patterns has changed which is the purpose of this PR

Copy link
Member

@Desvelao Desvelao left a comment

Choose a reason for hiding this comment

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

LGTM!

Note: We should refactor at the next iterations, as the selected index pattern is managed, moving to Redux store instead of the component state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Index pattern selector not displayed
3 participants