Skip to content

Commit

Permalink
[BUG][Modules][Reports] Error when generating a report after changing…
Browse files Browse the repository at this point in the history
… the selected agent (#4240)

* fix(modules): fixed an error when changing the selected agent and generates a module report.

This problem was caused because the VisHandlers singleton contains the
visualization handlers that are used to get data of the filters applied
and sent to the plugin endpoint. The visualization handlers were removed
of the VisHandlers singleton when changing the selected agent. Due the
dahasboard is not recreated, the visualizations are not added again,
causing that when generating the report, it can't get the applied
filters of the visualizations handlers because the list was empty.

* changelog: add PR entry

* Update wz-visualize.js

Co-authored-by: Álex <[email protected]>
  • Loading branch information
Desvelao and AlexRuiz7 authored Jun 13, 2022
1 parent 83e9875 commit 921aefc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ All notable changes to the Wazuh app project will be documented in this file.

## Wazuh v4.3.5 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4306


### Fixed

- Fixed an error when generating a module report after changing the selected agent [#4240](https://github.com/wazuh/wazuh-kibana-app/pull/4240)

### Changed

- Changed the word Manager to Wazuh server from the phrases that appeared in "Deploy a new agent". [#4239](https://github.com/wazuh/wazuh-kibana-app/pull/4239)


## Wazuh v4.3.4 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4305

### Added
Expand Down
22 changes: 20 additions & 2 deletions public/components/visualize/wz-visualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,31 @@ export const WzVisualize = compose(
this.agentsStatus = false;
}

/**
* Reset the visualizations when the type of Dashboard is changed.
*
* There are 2 kinds of Dashboards:
* - General or overview --> When to agent is pinned.
* - Specific or per agent --> When there is an agent pinned.
*
* The visualizations are reset only when the type of Dashboard changes
* from a type to another, but aren't when the pinned agent changes.
*
* More info:
* https://github.com/wazuh/wazuh-kibana-app/issues/4230#issuecomment-1152161434
*
* @param {Object} prevProps
*/
async componentDidUpdate(prevProps) {
if (prevProps.isAgent !== this.props.isAgent) {
if (
(!prevProps.isAgent && this.props.isAgent) ||
(prevProps.isAgent && !this.props.isAgent)
) {
this._isMount &&
this.setState({
visualizations: !!this.props.isAgent ? agentVisualizations : visualizations,
});
typeof prevProps.isAgent !== 'undefined' && visHandler.removeAll();
visHandler.removeAll();
}
}

Expand Down

0 comments on commit 921aefc

Please sign in to comment.