mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Security Solution] Remove active patterns from Sourcerer (#190020)
## Summary Another round of field removal, this time I am replacing the `activePatterns` field with `dataView.title` based logic for active pattern retrieval. This is mostly about upgrade flow for sourcerer going from stack v7 to 8.
This commit is contained in:
parent
51df0599aa
commit
d1c4bb33fb
7 changed files with 20 additions and 22 deletions
|
@ -49,7 +49,6 @@ describe('useThreatIntelligenceDetails', () => {
|
|||
dataViewId: '',
|
||||
loading: false,
|
||||
indicesExist: true,
|
||||
patternList: [],
|
||||
selectedPatterns: [],
|
||||
indexPattern: { fields: [], title: '' },
|
||||
sourcererDataView: undefined,
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
import type { ReactWrapper } from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import { SourcererScopeName } from '../store/model';
|
||||
import { type SelectedDataView, SourcererScopeName } from '../store/model';
|
||||
import { Sourcerer } from '.';
|
||||
import { sourcererActions, sourcererModel } from '../store';
|
||||
import { createMockStore, mockGlobalState, TestProviders } from '../../common/mock';
|
||||
|
@ -74,9 +74,13 @@ const { id, patternList, title } = mockGlobalState.sourcerer.defaultDataView;
|
|||
const patternListNoSignals = sortWithExcludesAtEnd(
|
||||
patternList.filter((p) => p !== mockGlobalState.sourcerer.signalIndexName)
|
||||
);
|
||||
const sourcererDataView = {
|
||||
const sourcererDataView: Partial<SelectedDataView> = {
|
||||
indicesExist: true,
|
||||
loading: false,
|
||||
sourcererDataView: {
|
||||
title:
|
||||
'apm-*-transaction*,auditbeat-*,endgame-*,filebeat-*,logs-*,packetbeat-*,traces-apm*,winlogbeat-*,-*elastic-cloud-logs-*',
|
||||
},
|
||||
};
|
||||
|
||||
describe('Sourcerer component', () => {
|
||||
|
|
|
@ -149,12 +149,19 @@ export const Sourcerer = React.memo<SourcererComponentProps>(({ scope: scopeId }
|
|||
}
|
||||
}, [isDetectionsSourcerer, isTimelineSourcerer, pollForSignalIndex]);
|
||||
|
||||
const { activePatterns, indicesExist, loading } = useSourcererDataView(scopeId);
|
||||
const { indicesExist, loading, sourcererDataView } = useSourcererDataView(scopeId);
|
||||
|
||||
const activePatterns = useMemo(
|
||||
() => (sourcererDataView?.title || '')?.split(',').filter(Boolean) as string[],
|
||||
[sourcererDataView?.title]
|
||||
);
|
||||
|
||||
const [missingPatterns, setMissingPatterns] = useState<string[]>(
|
||||
activePatterns && activePatterns.length > 0
|
||||
? sourcererMissingPatterns.filter((p) => activePatterns.includes(p))
|
||||
: []
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (activePatterns && activePatterns.length > 0) {
|
||||
setMissingPatterns(sourcererMissingPatterns.filter((p) => activePatterns.includes(p)));
|
||||
|
|
|
@ -10,7 +10,7 @@ import type { ReactWrapper } from 'enzyme';
|
|||
import { mount } from 'enzyme';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
import { initialSourcererState, SourcererScopeName } from '../store/model';
|
||||
import { initialSourcererState, type SelectedDataView, SourcererScopeName } from '../store/model';
|
||||
import { Sourcerer } from '.';
|
||||
import { sourcererActions, sourcererModel } from '../store';
|
||||
import { createMockStore, mockGlobalState, TestProviders } from '../../common/mock';
|
||||
|
@ -74,9 +74,12 @@ const { id, patternList } = mockGlobalState.sourcerer.defaultDataView;
|
|||
const patternListNoSignals = sortWithExcludesAtEnd(
|
||||
patternList.filter((p) => p !== mockGlobalState.sourcerer.signalIndexName)
|
||||
);
|
||||
const sourcererDataView = {
|
||||
const sourcererDataView: Partial<SelectedDataView> = {
|
||||
indicesExist: true,
|
||||
loading: false,
|
||||
sourcererDataView: {
|
||||
title: 'myFakebeat-*',
|
||||
},
|
||||
};
|
||||
|
||||
describe('No data', () => {
|
||||
|
|
|
@ -109,7 +109,6 @@ describe('Sourcerer integration tests', () => {
|
|||
|
||||
(useSourcererDataView as jest.Mock).mockReturnValue({
|
||||
...sourcererDataView,
|
||||
activePatterns: ['myFakebeat-*'],
|
||||
});
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
|
|
@ -56,5 +56,4 @@ export const mockSourcererScope: SelectedDataView = {
|
|||
indicesExist: true,
|
||||
loading: false,
|
||||
dataViewId: mockGlobalState.sourcerer.defaultDataView.id,
|
||||
patternList: mockPatterns,
|
||||
};
|
||||
|
|
|
@ -97,21 +97,8 @@ export interface SelectedDataView {
|
|||
indicesExist: boolean;
|
||||
/** is an update being made to the data view */
|
||||
loading: boolean;
|
||||
/**
|
||||
* @deprecated use sourcererDataView.title or sourcererDataView.matchedIndices
|
||||
* all active & inactive patterns from SourcererDataView['title']
|
||||
*/
|
||||
patternList: string[];
|
||||
/**
|
||||
* @deprecated use sourcererDataView.title or sourcererDataView.matchedIndices
|
||||
* all selected patterns from SourcererScope['selectedPatterns'] */
|
||||
/* all selected patterns from SourcererScope['selectedPatterns'] */
|
||||
selectedPatterns: SourcererScope['selectedPatterns'];
|
||||
/**
|
||||
* @deprecated use sourcererDataView.title or sourcererDataView.matchedIndices
|
||||
* active patterns when dataViewId == null
|
||||
*/
|
||||
activePatterns?: string[];
|
||||
|
||||
/**
|
||||
* Easier to add this additional data rather than
|
||||
* try to extend the SelectedDataView type from DataView.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue