Skip to content

Commit

Permalink
Merge pull request #3549 from wazuh/bugfix/3522_added-time-subscripti…
Browse files Browse the repository at this point in the history
…on-discover

Added time subscription in discover component
  • Loading branch information
mpRegalado committed Aug 10, 2021
2 parents 1f01f71 + 87c3723 commit 7a0b2fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Moved the filterManager subscription to the hook useFilterManager [#3517](https://github.com/wazuh/wazuh-kibana-app/pull/3517)
- Change filter from is to is one of in custom searchbar [#3529](https://github.com/wazuh/wazuh-kibana-app/pull/3529)
- Refactored as module tabs and buttons are rendered [#3494](https://github.com/wazuh/wazuh-kibana-app/pull/3494)
- Added time subscription to Discover component [#3549](https://github.com/wazuh/wazuh-kibana-app/pull/3549)

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions public/components/common/modules/discover/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const Discover = compose(
super(props);
this.KibanaServices = getDataPlugin();
this.timefilter = this.KibanaServices.query.timefilter.timefilter;
this.timeSubscription = null;
this.state = {
sort: {},
selectedTechnique: '',
Expand Down Expand Up @@ -161,6 +162,12 @@ export const Discover = compose(
async componentDidMount() {
this._isMount = true;
try {
this.timeSubscription = this.timefilter.getTimeUpdate$().subscribe(() => {
this.setState({
dateRange: this.timefilter.getTime(),
dateRangeHistory: this.timefilter._history,
});
});
this.setState({ columns: this.getColumns() }); //initial columns
await this.getIndexPattern();
await this.getAlerts();
Expand All @@ -182,6 +189,7 @@ export const Discover = compose(

componentWillUnmount() {
this._isMount = false;
this.timeSubscription && this.timeSubscription.unsubscribe();
}

async componentDidUpdate(prevProps, prevState) {
Expand Down

0 comments on commit 7a0b2fd

Please sign in to comment.