[Security Solution] Remove indexFields from security data view type (#188932)

## Summary

Remove `indexFields` from `SourcererDataView` as we can pull this info
from native DataViewSpec.
This commit is contained in:
Luke G 2024-08-05 13:46:41 +02:00 committed by GitHub
parent 477d07f7fc
commit 66130a3cad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 6 additions and 16 deletions

View file

@ -13,4 +13,4 @@ export type {
IndexFieldsStrategyResponse,
BrowserFields,
} from '@kbn/timelines-plugin/common';
export { EMPTY_BROWSER_FIELDS, EMPTY_INDEX_FIELDS } from '@kbn/timelines-plugin/common';
export { EMPTY_BROWSER_FIELDS } from '@kbn/timelines-plugin/common';

View file

@ -100,7 +100,6 @@ describe('source/index.tsx', () => {
const { type: sourceType, payload } = mockDispatch.mock.calls[1][0];
expect(sourceType).toEqual('x-pack/security_solution/local/sourcerer/SET_DATA_VIEW');
expect(payload.id).toEqual('neato');
expect(payload.indexFields).toHaveLength(mocksSource.indexFields.length);
});
it('should reuse the result for dataView info when cleanCache not passed', async () => {

View file

@ -6,7 +6,7 @@
*/
import { TableId } from '@kbn/securitysolution-data-table';
import type { DataViewSpec, FieldSpec } from '@kbn/data-views-plugin/public';
import type { DataViewSpec } from '@kbn/data-views-plugin/public';
import { ReqStatus } from '../../notes/store/notes.slice';
import { HostsFields } from '../../../common/api/search_strategy/hosts/model/sort';
import { InputsModelId } from '../store/inputs/constants';
@ -60,7 +60,6 @@ export const mockSourcererState: SourcererState = {
...initialSourcererState.defaultDataView,
browserFields: mockBrowserFields,
id: DEFAULT_DATA_VIEW_ID,
indexFields: mockIndexFields as FieldSpec[],
fields: mockFieldMap,
loading: false,
patternList: [...DEFAULT_INDEX_PATTERN, `${DEFAULT_SIGNALS_INDEX}-spacename`],

View file

@ -192,7 +192,7 @@ export const usePickIndexPatterns = ({
async (newSelectedDataViewId: string, isAlerts?: boolean) => {
if (
kibanaDataViews.some(
(kdv) => kdv.id === newSelectedDataViewId && kdv.indexFields.length === 0
(kdv) => kdv.id === newSelectedDataViewId && Object.keys(kdv?.fields || {}).length === 0
)
) {
try {

View file

@ -32,7 +32,6 @@ describe('getSourcererDataView', () => {
loading: false,
id: 'test-id',
title: 'test-pattern',
indexFields: {},
fields: {},
patternList: ['test-pattern'],
dataView: {

View file

@ -24,7 +24,6 @@ export const getSourcererDataView = async (
loading: false,
id: dataViewData.id ?? '',
title: dataView.getIndexPattern(),
indexFields: dataView.fields,
fields: dataViewData.fields,
patternList,
dataView: dataViewData,

View file

@ -121,7 +121,7 @@ export const useSourcererDataView = (
browserFields: browserFields(),
dataViewId: sourcererDataView.id,
indexPattern: {
fields: sourcererDataView.indexFields,
fields: Object.values(sourcererDataView.fields || {}),
title: selectedPatterns.join(','),
getName: () => selectedPatterns.join(','),
},

View file

@ -6,7 +6,7 @@
*/
import type { BrowserFields } from '@kbn/timelines-plugin/common';
import { EMPTY_BROWSER_FIELDS, EMPTY_INDEX_FIELDS } from '@kbn/timelines-plugin/common';
import { EMPTY_BROWSER_FIELDS } from '@kbn/timelines-plugin/common';
import type { DataViewSpec } from '@kbn/data-views-plugin/public';
import type { RuntimeFieldSpec, RuntimePrimitiveTypes } from '@kbn/data-views-plugin/common';
import type { SecuritySolutionDataViewBase } from '../../common/types';
@ -69,10 +69,6 @@ export interface SourcererDataView extends KibanaDataView {
* category, description, format
* indices the field is included in etc*/
browserFields: BrowserFields;
/**
* @deprecated use sourcererDataView.fields
* comes from dataView.fields.toSpec() */
indexFields: SecuritySolutionDataViewBase['fields'];
fields: DataViewSpec['fields'] | undefined;
/** set when data view fields are fetched */
loading: boolean;
@ -166,7 +162,6 @@ export const initSourcererScope: Omit<SourcererScope, 'id'> = {
export const initDataView: SourcererDataView & { id: string; error?: unknown } = {
browserFields: EMPTY_BROWSER_FIELDS,
id: '',
indexFields: EMPTY_INDEX_FIELDS,
fields: undefined,
loading: false,
patternList: [],

View file

@ -66,4 +66,4 @@ export type {
PaginationInputPaginated,
} from './search_strategy';
export { Direction, EntityType, EMPTY_BROWSER_FIELDS, EMPTY_INDEX_FIELDS } from './search_strategy';
export { Direction, EntityType, EMPTY_BROWSER_FIELDS } from './search_strategy';

View file

@ -81,4 +81,3 @@ export interface FieldCategory {
export type BrowserFields = Record<FieldCategoryName, FieldCategory>;
export const EMPTY_BROWSER_FIELDS = {};
export const EMPTY_INDEX_FIELDS: FieldSpec[] = [];