Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useKibana } from '../../../common/lib/kibana';

export const TopValuesPopover = React.memo(() => {
const { pathname } = useLocation();
const { browserFields, indexPattern } = useSourcererDataView(getScopeFromPath(pathname));
const { browserFields, sourcererDataView } = useSourcererDataView(getScopeFromPath(pathname));
const {
services: { topValuesPopover },
} = useKibana();
Expand Down Expand Up @@ -44,7 +44,7 @@ export const TopValuesPopover = React.memo(() => {
showLegend
scopeId={data.scopeId}
toggleTopN={onClose}
indexPattern={indexPattern}
dataViewSpec={sourcererDataView}
browserFields={browserFields}
/>
</EuiWrappingPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
const {
browserFields,
dataViewId,
indexPattern,
sourcererDataView,
selectedPatterns,
sourcererDataView,
dataViewId: selectedDataViewId,
loading: isLoadingIndexPattern,
} = useSourcererDataView(sourcererScope);
Expand Down Expand Up @@ -271,12 +270,12 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
dataProviders: [],
filters: globalFilters,
from: start,
indexPattern,
indexPattern: sourcererDataView,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it makes sense to rename parameter as sourceDataView as well?

kqlMode: 'filter',
kqlQuery: query,
to: end,
}),
[esQueryConfig, browserFields, globalFilters, start, indexPattern, query, end]
[esQueryConfig, browserFields, globalFilters, start, sourcererDataView, query, end]
);

const canQueryTimeline = useMemo(
Expand Down Expand Up @@ -318,7 +317,7 @@ const StatefulEventsViewerComponent: React.FC<EventsViewerProps & PropsFromRedux
id: tableId,
indexNames: indexNames ?? selectedPatterns,
limit: itemsPerPage,
runtimeMappings: sourcererDataView?.runtimeFieldMap as RunTimeMappings,
runtimeMappings: sourcererDataView.runtimeFieldMap as RunTimeMappings,
skip: !canQueryTimeline,
sort: sortField,
startDate: start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const InsightEditorComponent = ({
onCancel,
}: EuiMarkdownEditorUiPluginEditorProps<InsightComponentProps & { relativeTimerange: string }>) => {
const isEditMode = node != null;
const { indexPattern } = useSourcererDataView(SourcererScopeName.default);
const { sourcererDataView } = useSourcererDataView(SourcererScopeName.default);
const {
unifiedSearch: {
ui: { FiltersBuilderLazy },
Expand Down Expand Up @@ -400,7 +400,7 @@ const InsightEditorComponent = ({
);
}, [labelController.field.value, providers, dataView]);
const filtersStub = useMemo(() => {
const index = indexPattern && indexPattern.getName ? indexPattern.getName() : '*';
const index = sourcererDataView.name ?? '*';
return [
{
$state: {
Expand All @@ -414,7 +414,7 @@ const InsightEditorComponent = ({
},
},
];
}, [indexPattern]);
}, [sourcererDataView]);
const isPlatinum = useLicense().isAtLeast('platinum');

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const useInsightQuery = ({
}: UseInsightQuery): UseInsightQueryResult => {
const { uiSettings } = useKibana().services;
const esQueryConfig = useMemo(() => getEsQueryConfig(uiSettings), [uiSettings]);
const { browserFields, selectedPatterns, indexPattern, dataViewId } = useSourcererDataView(
const { browserFields, selectedPatterns, sourcererDataView, dataViewId } = useSourcererDataView(
SourcererScopeName.timeline
);
const [hasError, setHasError] = useState(false);
Expand All @@ -51,7 +51,7 @@ export const useInsightQuery = ({
const parsedCombinedQueries = combineQueries({
config: esQueryConfig,
dataProviders,
indexPattern,
indexPattern: sourcererDataView,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before regarding renaming parameter.

browserFields,
filters,
kqlQuery: {
Expand All @@ -66,7 +66,7 @@ export const useInsightQuery = ({
setHasError(true);
return null;
}
}, [browserFields, dataProviders, esQueryConfig, hasError, indexPattern, filters]);
}, [browserFields, dataProviders, esQueryConfig, hasError, sourcererDataView, filters]);

const [dataLoadingState, { events, totalCount }] = useTimelineEvents({
dataViewId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mount } from 'enzyme';
import React from 'react';
import { waitFor } from '@testing-library/react';
import { mockBrowserFields } from '../../containers/source/mock';
import { mockGlobalState, TestProviders, mockIndexPattern, createMockStore } from '../../mock';
import { mockGlobalState, TestProviders, createMockStore, mockDataViewSpec } from '../../mock';
import type { State } from '../../store';

import type { Props } from './top_n';
Expand Down Expand Up @@ -145,7 +145,7 @@ const store = createMockStore(state);
const testProps = {
browserFields: mockBrowserFields,
field,
indexPattern: mockIndexPattern,
indexPattern: mockDataViewSpec,
scopeId: TableId.hostsPageEvents,
toggleTopN: jest.fn(),
onFilterAdded: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import React, { useMemo } from 'react';
import type { ConnectedProps } from 'react-redux';
import { connect } from 'react-redux';

import type { DataViewBase, Filter, Query } from '@kbn/es-query';
import { getEsQueryConfig } from '@kbn/data-plugin/common';
import type { Filter, Query } from '@kbn/es-query';
import { type DataViewSpec, getEsQueryConfig } from '@kbn/data-plugin/common';
import { isActiveTimeline } from '../../../helpers';
import { InputsModelId } from '../../store/inputs/constants';
import { useGlobalTime } from '../../containers/use_global_time';
Expand Down Expand Up @@ -77,7 +77,7 @@ const connector = connect(makeMapStateToProps);
export interface OwnProps {
browserFields: BrowserFields;
field: string;
indexPattern: DataViewBase;
dataViewSpec?: DataViewSpec;
scopeId?: string;
toggleTopN: () => void;
onFilterAdded?: () => void;
Expand All @@ -97,7 +97,7 @@ const StatefulTopNComponent: React.FC<Props> = ({
browserFields,
dataProviders,
field,
indexPattern,
dataViewSpec: indexPattern,
globalFilters = EMPTY_FILTERS,
globalQuery = EMPTY_QUERY,
kqlMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { mount } from 'enzyme';
import React from 'react';
import { waitFor } from '@testing-library/react';

import { TestProviders, mockIndexPattern } from '../../mock';
import { TestProviders, mockDataViewSpec } from '../../mock';

import { allEvents, defaultOptions } from './helpers';
import type { Props as TopNProps } from './top_n';
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('TopN', () => {
field,
filters: [],
from: '2020-04-14T00:31:47.695Z',
indexPattern: mockIndexPattern,
indexPattern: mockDataViewSpec,
options: defaultOptions,
query,
setAbsoluteRangeDatePickerTarget: InputsModelId.global,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { EuiButtonIcon, EuiSuperSelect } from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import styled from 'styled-components';

import type { DataViewBase, Filter, Query } from '@kbn/es-query';
import type { Filter, Query } from '@kbn/es-query';
import type { DataViewSpec } from '@kbn/data-plugin/common';
import type { GlobalTimeArgs } from '../../containers/use_global_time';
import { EventsByDataset } from '../../../overview/components/events_by_dataset';
import { SignalsByCategory } from '../../../overview/components/signals_by_category';
Expand Down Expand Up @@ -48,7 +49,7 @@ export interface Props extends Pick<GlobalTimeArgs, 'from' | 'to' | 'deleteQuery
defaultView: TimelineEventsType;
field: AlertsStackByField;
filters: Filter[];
indexPattern: DataViewBase;
indexPattern?: DataViewSpec;
options: TopNOption[];
paddingSize?: 's' | 'm' | 'l' | 'none';
query: Query;
Expand Down Expand Up @@ -118,7 +119,7 @@ const TopNComponent: React.FC<Props> = ({
filters={applicableFilters}
from={from}
headerChildren={headerChildren}
indexPattern={indexPattern}
dataViewSpec={indexPattern}
onlyField={field}
paddingSize={paddingSize}
query={query}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('../../../../../../sourcerer/containers', () => ({
dataViewId: 'security-solution-my-test',
indicesExist: true,
selectedPatterns: ['signal-index'],
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('../../../../../../sourcerer/containers', () => ({
dataViewId: 'security-solution-my-test',
indicesExist: true,
selectedPatterns: ['signal-index'],
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jest.mock('../../../../../../sourcerer/containers', () => ({
dataViewId: 'security-solution-my-test',
indicesExist: true,
selectedPatterns: ['signal-index'],
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jest.mock('../../../../../../sourcerer/containers', () => ({
dataViewId: 'security-solution-my-test',
indicesExist: true,
selectedPatterns: ['signal-index'],
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jest.mock('../../../../../sourcerer/containers', () => ({
selectedPatterns: ['auditbeat-mytest-*'],
dataViewId: 'security-solution-my-test',
indicesExist: true,
sourcererDataView: {},
}),
}));

Expand Down
Loading