[8.12] [Security Solution][Threat Intelligence] - fix broken KQL bar (#179153) (#179427)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Security Solution][Threat Intelligence] - fix broken KQL bar
(#179153)](https://github.com/elastic/kibana/pull/179153)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Philippe
Oberti","email":"philippe.oberti@elastic.co"},"sourceCommit":{"committedDate":"2024-03-26T12:23:36Z","message":"[Security
Solution][Threat Intelligence] - fix broken KQL bar
(#179153)","sha":"98f0cfe7ddb0e0c6d23f97b733f62766f52a101d","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat
Hunting:Investigations","v8.11.5","v8.14.0","v8.12.3","v8.13.1"],"title":"[Security
Solution][Threat Intelligence] - fix broken KQL
bar","number":179153,"url":"https://github.com/elastic/kibana/pull/179153","mergeCommit":{"message":"[Security
Solution][Threat Intelligence] - fix broken KQL bar
(#179153)","sha":"98f0cfe7ddb0e0c6d23f97b733f62766f52a101d"}},"sourceBranch":"main","suggestedTargetBranches":["8.11","8.12","8.13"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/179153","number":179153,"mergeCommit":{"message":"[Security
Solution][Threat Intelligence] - fix broken KQL bar
(#179153)","sha":"98f0cfe7ddb0e0c6d23f97b733f62766f52a101d"}},{"branch":"8.12","label":"v8.12.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.13","label":"v8.13.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Philippe Oberti <philippe.oberti@elastic.co>
This commit is contained in:
Kibana Machine 2024-03-27 09:31:32 -04:00 committed by GitHub
parent 8716575154
commit 523d3154e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 14 additions and 23 deletions

View file

@ -8,9 +8,9 @@
import React, { memo } from 'react';
import type { SecuritySolutionPluginContext } from '@kbn/threat-intelligence-plugin/public';
import { THREAT_INTELLIGENCE_BASE_PATH } from '@kbn/threat-intelligence-plugin/public';
import type { SourcererDataView } from '@kbn/threat-intelligence-plugin/public/types';
import type { Store } from 'redux';
import { useSelector } from 'react-redux';
import type { SelectedDataView } from '@kbn/threat-intelligence-plugin/public/types';
import { useUserPrivileges } from '../common/components/user_privileges';
import { useSetUrlParams } from '../management/components/artifact_list_page/hooks/use_set_url_params';
import { BlockListForm } from '../management/pages/blocklist/view/components/blocklist_form';
@ -46,7 +46,7 @@ const ThreatIntelligence = memo(() => {
getFiltersGlobalComponent: () => FiltersGlobal,
getPageWrapper: () => SecuritySolutionPageWrapper,
licenseService,
sourcererDataView: sourcererDataView as unknown as SourcererDataView,
sourcererDataView: sourcererDataView as unknown as SelectedDataView,
getUseInvestigateInTimeline: useInvestigateInTimeline,
blockList: {

View file

@ -6,7 +6,7 @@
*/
import React, { NamedExoticComponent } from 'react';
import { BlockListFlyoutProps, BlockListFormProps } from '../types';
import { BlockListFlyoutProps, BlockListFormProps, SelectedDataView } from '../types';
import { SecuritySolutionPluginContext } from '..';
export const getSecuritySolutionContextMock = (): SecuritySolutionPluginContext => ({
@ -31,7 +31,7 @@ export const getSecuritySolutionContextMock = (): SecuritySolutionPluginContext
selectedPatterns: [],
indexPattern: { fields: [], title: '' },
loading: false,
},
} as unknown as SelectedDataView,
securitySolutionStore: {
// @ts-ignore
dispatch: () => jest.fn(),

View file

@ -79,11 +79,7 @@ export const useAggregatedIndicators = ({
} = useKibana();
const userTimeZone = useTimeZone();
const userFormat = useDateFormat();
const {
sourcererDataView: { selectedPatterns },
} = useSourcererDataView();
const { selectedPatterns } = useSourcererDataView();
const { inspectorAdapters } = useInspector();
const [field, setField] = useState<EuiComboBoxOptionOption<string>>({

View file

@ -64,10 +64,7 @@ export const useIndicators = ({
data: { search: searchService },
},
} = useKibana();
const {
sourcererDataView: { selectedPatterns },
} = useSourcererDataView();
const { selectedPatterns } = useSourcererDataView();
const { inspectorAdapters } = useInspector();
const onChangeItemsPerPage = useCallback(

View file

@ -54,7 +54,7 @@ export const useSourcererDataView = () => {
return useMemo(
() => ({
sourcererDataView,
...sourcererDataView,
indexPatterns,
indexPattern: updatedPattern,
browserFields,

View file

@ -24,9 +24,7 @@ export const useIndicatorsTotalCount = () => {
const [count, setCount] = useState<number>(0);
const [isLoading, setIsLoading] = useState<boolean>(true);
const {
sourcererDataView: { selectedPatterns, loading: loadingDataView },
} = useSourcererDataView();
const { selectedPatterns, loading: loadingDataView } = useSourcererDataView();
useEffect(() => {
const query = {

View file

@ -83,7 +83,6 @@ const IndicatorsPageContent: VFC = () => {
<FiltersGlobal>
<QueryBar
queries={[indicatorChartQuery, indicatorListQuery]}
indexPattern={indexPattern}
sourcererDataView={sourcererDataView}
/>
</FiltersGlobal>

View file

@ -6,17 +6,16 @@
*/
import React, { useEffect, VFC } from 'react';
import type { DataViewSpec } from '@kbn/data-views-plugin/common';
import { useSecurityContext } from '../../../hooks/use_security_context';
import { SecuritySolutionDataViewBase, SourcererDataView } from '../../../types';
interface QueryBarProps {
indexPattern: SecuritySolutionDataViewBase;
queries: Array<{
id: string;
refetch: VoidFunction;
loading: boolean;
}>;
sourcererDataView: SourcererDataView | undefined;
sourcererDataView: DataViewSpec | undefined;
}
export const QueryBar: VFC<QueryBarProps> = ({ queries, sourcererDataView }) => {

View file

@ -10,6 +10,7 @@ import { CoreStart } from '@kbn/core/public';
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import {
DataViewField,
type DataViewSpec,
DataViewsPublicPluginStart,
FieldSpec,
} from '@kbn/data-views-plugin/public';
@ -64,7 +65,8 @@ export interface LicenseAware {
export type BrowserFields = Readonly<Record<string, Partial<BrowserField>>>;
export interface SourcererDataView {
export interface SelectedDataView {
sourcererDataView: DataViewSpec | undefined;
indexPattern: SecuritySolutionDataViewBase;
browserFields: BrowserFields;
selectedPatterns: string[];
@ -112,7 +114,7 @@ export interface SecuritySolutionPluginContext {
/**
* Gets Security Solution shared information like browerFields, indexPattern and selectedPatterns in DataView.
*/
sourcererDataView: SourcererDataView;
sourcererDataView: SelectedDataView;
/**
* Security Solution store