Skip to content

Commit

Permalink
[Security Solution] Remove experimental sourcerer (#189881)
Browse files Browse the repository at this point in the history
## Summary

Given that we are no longer considering replacing our sourcerer
component with Discover one, I am removing the experimental flag + some
boilerplate code around it.
  • Loading branch information
lgestc authored Aug 6, 2024
1 parent 9fa7fd5 commit 0eea85e
Show file tree
Hide file tree
Showing 22 changed files with 6 additions and 757 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { IS_DRAGGING_CLASS_NAME } from '@kbn/securitysolution-t-grid';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template';
import { ExpandableFlyoutProvider } from '@kbn/expandable-flyout';
import { DataViewPickerProvider } from '../../../sourcerer/experimental/containers/dataview_picker_provider';
import { AttackDiscoveryTour } from '../../../attack_discovery/tour';
import { URL_PARAM_KEY } from '../../../common/hooks/use_url_state';
import { SecuritySolutionFlyout, TimelineFlyout } from '../../../flyout';
Expand Down Expand Up @@ -104,12 +103,10 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionTemplateW
component="div"
grow={true}
>
<DataViewPickerProvider>
<ExpandableFlyoutProvider urlKey={isPreview ? undefined : URL_PARAM_KEY.flyout}>
{children}
<SecuritySolutionFlyout />
</ExpandableFlyoutProvider>
</DataViewPickerProvider>
<ExpandableFlyoutProvider urlKey={isPreview ? undefined : URL_PARAM_KEY.flyout}>
{children}
<SecuritySolutionFlyout />
</ExpandableFlyoutProvider>

{didMount && <AttackDiscoveryTour />}
</KibanaPageTemplate.Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { initialGroupingState } from '../store/grouping/reducer';
import type { SourcererState } from '../../sourcerer/store';
import { EMPTY_RESOLVER } from '../../resolver/store/helpers';
import { getMockDiscoverInTimelineState } from './mock_discover_state';
import { initialState as dataViewPickerInitialState } from '../../sourcerer/experimental/redux/reducer';

const mockFieldMap: DataViewSpec['fields'] = Object.fromEntries(
mockIndexFields.map((field) => [field.name, field])
Expand Down Expand Up @@ -512,7 +511,6 @@ export const mockGlobalState: State = {
*/
management: mockManagementState as ManagementState,
discover: getMockDiscoverInTimelineState(),
dataViewPicker: dataViewPickerInitialState,
notes: {
entities: {
'1': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useSourcererDataView } from '../../sourcerer/containers';
import { renderHook } from '@testing-library/react-hooks';
import { initialGroupingState } from './grouping/reducer';
import { initialAnalyzerState } from '../../resolver/store/helpers';
import { initialState as dataViewPickerInitialState } from '../../sourcerer/experimental/redux/reducer';
import { initialNotesState } from '../../notes/store/notes.slice';

jest.mock('../hooks/use_selector');
Expand Down Expand Up @@ -72,7 +71,6 @@ describe('createInitialState', () => {
{
analyzer: initialAnalyzerState,
},
dataViewPickerInitialState,
initialNotesState
);

Expand Down Expand Up @@ -112,7 +110,6 @@ describe('createInitialState', () => {
{
analyzer: initialAnalyzerState,
},
dataViewPickerInitialState,
initialNotesState
);
const { result } = renderHook(() => useSourcererDataView(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ import type { GroupState } from './grouping/types';
import { analyzerReducer } from '../../resolver/store/reducer';
import { securitySolutionDiscoverReducer } from './discover/reducer';
import type { AnalyzerState } from '../../resolver/types';
import {
type DataviewPickerState,
reducer as dataviewPickerReducer,
} from '../../sourcerer/experimental/redux/reducer';
import type { NotesState } from '../../notes/store/notes.slice';
import { notesReducer } from '../../notes/store/notes.slice';

Expand Down Expand Up @@ -73,7 +69,6 @@ export const createInitialState = (
dataTableState: DataTableState,
groupsState: GroupState,
analyzerState: AnalyzerState,
dataviewPickerState: DataviewPickerState,
notesState: NotesState
): State => {
const initialPatterns = {
Expand Down Expand Up @@ -136,7 +131,6 @@ export const createInitialState = (
internal: undefined,
savedSearch: undefined,
},
dataViewPicker: dataviewPickerState,
notes: notesState,
};

Expand All @@ -156,7 +150,6 @@ export const createReducer: (
sourcerer: sourcererReducer,
globalUrlParam: globalUrlParamReducer,
dataTable: dataTableReducer,
dataViewPicker: dataviewPickerReducer,
groups: groupsReducer,
analyzer: analyzerReducer,
discover: securitySolutionDiscoverReducer,
Expand Down
8 changes: 0 additions & 8 deletions x-pack/plugins/security_solution/public/common/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ import { dataAccessLayerFactory } from '../../resolver/data_access_layer/factory
import { sourcererActions } from '../../sourcerer/store';
import { createMiddlewares } from './middlewares';
import { addNewTimeline } from '../../timelines/store/helpers';
import {
reducer as dataViewPickerReducer,
initialState as dataViewPickerState,
} from '../../sourcerer/experimental/redux/reducer';
import { listenerMiddleware } from '../../sourcerer/experimental/redux/listeners';
import { initialNotesState } from '../../notes/store/notes.slice';

let store: Store<State, Action> | null = null;
Expand Down Expand Up @@ -176,22 +171,19 @@ export const createStoreFactory = async (
dataTableInitialState,
groupsInitialState,
analyzerInitialState,
dataViewPickerState,
initialNotesState
);

const rootReducer = {
...subPlugins.explore.store.reducer,
timeline: timelineReducer,
...subPlugins.management.store.reducer,
dataViewPicker: dataViewPickerReducer,
};

return createStore(initialState, rootReducer, coreStart, storage, [
...(subPlugins.management.store.middleware ?? []),
...(subPlugins.explore.store.middleware ?? []),
...[resolverMiddlewareFactory(dataAccessLayerFactory(coreStart)) ?? []],
listenerMiddleware.middleware,
]);
};

Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/security_solution/public/common/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import type { GlobalUrlParam } from './global_url_param';
import type { GroupState } from './grouping/types';
import type { SecuritySolutionDiscoverState } from './discover/model';
import type { AnalyzerState } from '../../resolver/types';
import { type DataviewPickerState } from '../../sourcerer/experimental/redux/reducer';
import type { NotesState } from '../../notes/store/notes.slice';

export type State = HostsPluginState &
Expand All @@ -39,7 +38,6 @@ export type State = HostsPluginState &
sourcerer: SourcererState;
globalUrlParam: GlobalUrlParam;
discover: SecuritySolutionDiscoverState;
dataViewPicker: DataviewPickerState;
} & DataTableState &
GroupState &
AnalyzerState & { notes: NotesState };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { getDataViewStateFromIndexFields } from '../../common/containers/source/
import { useFetchIndex } from '../../common/containers/source';
import type { State } from '../../common/store/types';
import { sortWithExcludesAtEnd } from '../../../common/utils/sourcerer';
import { useUnstableSecuritySolutionDataView } from '../experimental/use_unstable_security_solution_data_view';

export const useSourcererDataView = (
scopeId: SourcererScopeName = SourcererScopeName.default
Expand Down Expand Up @@ -116,7 +115,7 @@ export const useSourcererDataView = (
return dataViewBrowserFields;
}, [sourcererDataView.fields, sourcererDataView.patternList]);

const stableSourcererValues = useMemo(
return useMemo(
() => ({
browserFields: browserFields(),
dataViewId: sourcererDataView.id,
Expand Down Expand Up @@ -145,10 +144,4 @@ export const useSourcererDataView = (
legacyPatterns.length,
]
);

return useUnstableSecuritySolutionDataView(
scopeId,
// NOTE: data view derived from current implementation is used as a fallback
stableSourcererValues
);
};

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0eea85e

Please sign in to comment.