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

Fix Security Events table query filter #6102

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All notable changes to the Wazuh app project will be documented in this file.
### Fixed

- Fixed a problem with the agent menu header when the side menu is docked [#5840](https://github.com/wazuh/wazuh-dashboard-plugins/pull/5840)
- Fixed how the query filters apply on the Security Alerts table [#6102](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6102)

### Removed

Expand Down
32 changes: 0 additions & 32 deletions plugins/main/public/components/common/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,6 @@
*/
import { getDataPlugin } from '../../../kibana-services';
import { useState, useEffect } from 'react';
import { ModulesHelper } from '../modules/modules-helper';
import _ from 'lodash';

export function useQuery(): [
{
language: 'kuery' | 'lucene';
query: string;
},
(query: any) => void
] {
const [query, setQuery] = useState({ language: 'kuery', query: '' });
useEffect(() => {
let subscription;
ModulesHelper.getDiscoverScope().then((scope) => {
setQuery(scope.state.query);
subscription = scope.$watchCollection('fetchStatus', () => {
if (!_.isEqual(query, scope.state.query)) {
setQuery(scope.state.query);
}
});
});
return () => {
subscription && subscription();
};
}, []);
const updateQuery = (query) => {
ModulesHelper.getDiscoverScope().then((scope) => {
scope.state.query = query;
});
};
return [query, updateQuery];
}

export const useQueryManager = () => {
const [query, setQuery] = useState(getDataPlugin().query.queryString.getQuery());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Find more information about this on the LICENSE file.
*/
import React from 'react';
import { useFilterManager, useQuery, useRefreshAngularDiscover } from '../../common/hooks';
import { useFilterManager, useQueryManager, useRefreshAngularDiscover } from '../../common/hooks';
import { Discover } from '../../common/modules/discover';
import { useAllowedAgents } from '../../common/hooks/useAllowedAgents';

Expand All @@ -37,7 +37,7 @@ export const SecurityAlerts = ({
],
useAgentColumns = true,
}) => {
const [query] = useQuery();
const [query] = useQueryManager();
const { filterManager } = useFilterManager();
const refreshAngularDiscover = useRefreshAngularDiscover();

Expand Down
Loading