Skip to content

Commit

Permalink
Merge pull request #2945 from wazuh/bugfix/kql-filter-on-tsc
Browse files Browse the repository at this point in the history
Fixed query filter of TSC.
  • Loading branch information
frankeros authored Feb 5, 2021
2 parents dbb3e52 + bd9dab5 commit 39dedb8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ All notable changes to the Wazuh app project will be documented in this file.
- Allow access to Agents section with agent:group action permission [#2933](https://github.com/wazuh/wazuh-kibana-app/issues/2933)
- Fixed filters does not work on modals with search bar [#2935](https://github.com/wazuh/wazuh-kibana-app/pull/2935)
- Fix wrong package name in deploy new agent [#2942](https://github.com/wazuh/wazuh-kibana-app/issues/2942)
- Fixed number agents not show on pie onMouseEvent [#2890](https://github.com/wazuh/wazuh-kibana-app/issues/2890)
- Fixed off Kibana Query Language in search bar of Controls/Inventory modules. [#2945](https://github.com/wazuh/wazuh-kibana-app/pull/2945)
- Fixed number of agents do not show on the pie chart tooltip in agents preview [#2890](https://github.com/wazuh/wazuh-kibana-app/issues/2890)

## Wazuh v4.0.4 - Kibana 7.10.0 , 7.10.2 - Revision 4017
Expand Down
11 changes: 6 additions & 5 deletions public/components/common/hocs/withKibanaContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* Find more information about this on the LICENSE file.
*/
import React, {useState} from 'react';
import { useIndexPattern, useFilterManager, useTimeFilter, useQuery } from '../hooks';
import { useIndexPattern, useFilterManager, useTimeFilter } from '../hooks';
import { IIndexPattern, FilterManager, Query, TimeRange } from '../../../../../../src/plugins/data/public';
import { useQueryManager } from "../hooks/use-query";

interface withKibanaContextProps {
indexPattern?: IIndexPattern
Expand All @@ -26,16 +27,16 @@ export interface withKibanaContextExtendsProps {
timeHistory: TimeRange[]
setTimeFilter(timeRange:TimeRanges): void
query: Query
setQuery(query:Query): void
setQuery(query:Query): void
}


export const withKibanaContext = <T extends object>(Component:React.FunctionComponent<T>) => {
function hoc(props:T & withKibanaContextProps ):React.FunctionComponentElement<T & withKibanaContextExtendsProps> {
const indexPattern = props.indexPattern ? props.indexPattern : useIndexPattern();
const filterManager = props.filterManager ? props.filterManager : useFilterManager();
const [query, setQuery] = props.query ? useState(props.query) : useQuery();
const {timeFilter, timeHistory, setTimeFilter } = useTimeFilter();
const [query, setQuery] = props.query ? useState(props.query) : useQueryManager();
const { timeFilter, timeHistory, setTimeFilter } = useTimeFilter();
return <Component {...props}
indexPattern={indexPattern}
filterManager={filterManager}
Expand All @@ -49,4 +50,4 @@ export const withKibanaContext = <T extends object>(Component:React.FunctionComp
hoc.displayName = `withKibanaContext-${Component.displayName}`;

return hoc
}
}
9 changes: 7 additions & 2 deletions public/components/common/hooks/use-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Find more information about this on the LICENSE file.
*/
import { getDataPlugin } from '../../../kibana-services';
import { useState, useEffect } from 'react';
import { ModulesHelper } from '../modules/modules-helper';

Expand All @@ -30,8 +31,12 @@ export function useQuery(): [{
const updateQuery = (query) => {
ModulesHelper.getDiscoverScope()
.then(scope => {
scope.updateQuery({query});
scope.state.query = query;
})
}
return [ query, updateQuery ];
}
}

export const useQueryManager = () => {
return useState(getDataPlugin().query.queryString.getQuery());
}

0 comments on commit 39dedb8

Please sign in to comment.