Skip to content

Commit 6c62ae4

Browse files
committed
fix raw alert event type
1 parent 3350099 commit 6c62ae4

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

x-pack/plugins/security_solution/public/common/containers/source/index.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { act, renderHook } from '@testing-library/react-hooks';
88

99
import { useWithSource, indicesExistOrDataTemporarilyUnavailable } from '.';
10+
import { NO_ALERT_INDEX } from '../../../../common/constants';
1011
import { mockBrowserFields, mockIndexFields, mocksSource } from './mock';
1112

1213
jest.mock('../../lib/kibana');
@@ -79,6 +80,17 @@ describe('Index Fields & Browser Fields', () => {
7980
});
8081
});
8182

83+
test('Make sure we are not querying for NO_ALERT_INDEX and it is not includes in the index pattern', async () => {
84+
const { result, waitForNextUpdate } = renderHook(() =>
85+
useWithSource('default', [NO_ALERT_INDEX])
86+
);
87+
88+
await waitForNextUpdate();
89+
return expect(result.current.indexPattern.title).toEqual(
90+
'apm-*-transaction*,auditbeat-*,endgame-*,filebeat-*,logs-*,packetbeat-*,winlogbeat-*'
91+
);
92+
});
93+
8294
describe('indicesExistOrDataTemporarilyUnavailable', () => {
8395
test('it returns true when undefined', () => {
8496
let undefVar;

x-pack/plugins/security_solution/public/common/containers/source/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useEffect, useMemo, useState } from 'react';
1111
import memoizeOne from 'memoize-one';
1212
import { IIndexPattern } from 'src/plugins/data/public';
1313

14-
import { DEFAULT_INDEX_KEY } from '../../../../common/constants';
14+
import { DEFAULT_INDEX_KEY, NO_ALERT_INDEX } from '../../../../common/constants';
1515
import { useUiSetting$ } from '../../lib/kibana';
1616

1717
import { IndexField, SourceQuery } from '../../../graphql/types';
@@ -126,8 +126,9 @@ export const useWithSource = (
126126
) => {
127127
const [configIndex] = useUiSetting$<string[]>(DEFAULT_INDEX_KEY);
128128
const defaultIndex = useMemo<string[]>(() => {
129-
if (indexToAdd != null && !isEmpty(indexToAdd)) {
130-
return onlyCheckIndexToAdd ? indexToAdd : [...configIndex, ...indexToAdd];
129+
const filterIndexAdd = (indexToAdd ?? []).filter((item) => item !== NO_ALERT_INDEX);
130+
if (!isEmpty(filterIndexAdd)) {
131+
return onlyCheckIndexToAdd ? filterIndexAdd : [...configIndex, ...filterIndexAdd];
131132
}
132133
return configIndex;
133134
}, [configIndex, indexToAdd, onlyCheckIndexToAdd]);
@@ -138,7 +139,7 @@ export const useWithSource = (
138139
errorMessage: null,
139140
indexPattern: getIndexFields(defaultIndex.join(), []),
140141
indicesExist: indicesExistOrDataTemporarilyUnavailable(undefined),
141-
loading: false,
142+
loading: true,
142143
});
143144

144145
const apolloClient = useApolloClient();
@@ -155,7 +156,7 @@ export const useWithSource = (
155156
try {
156157
const result = await apolloClient.query<SourceQuery.Query, SourceQuery.Variables>({
157158
query: sourceQuery,
158-
fetchPolicy: 'cache-first',
159+
fetchPolicy: 'cache-and-network',
159160
variables: {
160161
sourceId,
161162
defaultIndex,

0 commit comments

Comments
 (0)