Skip to content

Commit

Permalink
[Security Solution] Remove indexFields from security data view type (#…
Browse files Browse the repository at this point in the history
…188932)

## Summary

Remove `indexFields` from `SourcererDataView` as we can pull this info
from native DataViewSpec.
  • Loading branch information
lgestc authored Aug 5, 2024
1 parent 477d07f commit 66130a3
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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`],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('getSourcererDataView', () => {
loading: false,
id: 'test-id',
title: 'test-pattern',
indexFields: {},
fields: {},
patternList: ['test-pattern'],
dataView: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(','),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: [],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/timelines/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ export interface FieldCategory {
export type BrowserFields = Record<FieldCategoryName, FieldCategory>;

export const EMPTY_BROWSER_FIELDS = {};
export const EMPTY_INDEX_FIELDS: FieldSpec[] = [];

0 comments on commit 66130a3

Please sign in to comment.