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

Fixed query filter of TSC. #2945

Merged
merged 3 commits into from
Feb 5, 2021
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
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());
}