kibana/x-pack/plugins/timelines/public/plugin.ts
Xavier Mouligneau 16af3e95cb
[RAC] Remove rbac on security solution side (#110472)
* wip to remove rbac

* Revert "[Cases] Include rule registry client for updating alert statuses (#108588)"

This reverts commit 1fd7038b34.

This leaves the rule registry mock changes

* remove rbac on Trend/Count alert

* update detection api for status

* remove @kbn-alerts packages

* fix leftover

* Switching cases to leverage update by query for alert status

* Adding missed files

* fix bad logic

* updating tests for use_alerts_privileges

* remove index alias/fields

* fix types

* fix plugin to get the right index names

* left over of alis on template

* forget to use current user for create/read route index

* updated alerts page to not show table when no privileges and updates to tests

* fix bug when switching between o11y and security solution

* updates tests and move to use privileges page when user tries to access alerts without proper access

* updating jest tests

* pairing with yara

* bring back kbn-alerts after discussion with the team

* fix types

* fix index field for o11y

* fix bug with updating index priv state

* fix i18n issue and update api docs

* fix refresh on alerts

* fix render view on alerts

* updating tests and checking for null in alerts page to not show no privileges page before load

* fix details rules

Co-authored-by: Jonathan Buttner <jonathan.buttner@elastic.co>
Co-authored-by: Yara Tercero <yara.tercero@elastic.co>
2021-09-01 04:23:44 -04:00

128 lines
3.9 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { Store } from 'redux';
import { Storage } from '../../../../src/plugins/kibana_utils/public';
import type {
CoreSetup,
Plugin,
PluginInitializerContext,
CoreStart,
} from '../../../../src/core/public';
import type { LastUpdatedAtProps, LoadingPanelProps, FieldBrowserProps } from './components';
import {
getLastUpdatedLazy,
getLoadingPanelLazy,
getTGridLazy,
getFieldsBrowserLazy,
getAddToCaseLazy,
getAddToExistingCaseButtonLazy,
getAddToNewCaseButtonLazy,
getAddToCasePopoverLazy,
} from './methods';
import type { TimelinesUIStart, TGridProps, TimelinesStartPlugins } from './types';
import { tGridReducer } from './store/t_grid/reducer';
import { useDraggableKeyboardWrapper } from './components/drag_and_drop/draggable_keyboard_wrapper_hook';
import { useAddToTimeline, useAddToTimelineSensor } from './hooks/use_add_to_timeline';
import { getHoverActions } from './components/hover_actions';
export class TimelinesPlugin implements Plugin<void, TimelinesUIStart> {
constructor(private readonly initializerContext: PluginInitializerContext) {}
private _store: Store | undefined;
private _storage = new Storage(localStorage);
public setup(core: CoreSetup) {}
public start(core: CoreStart, { data }: TimelinesStartPlugins): TimelinesUIStart {
const config = this.initializerContext.config.get<{ enabled: boolean }>();
if (!config.enabled) {
return {} as TimelinesUIStart;
}
return {
getHoverActions: () => {
return getHoverActions(this._store!);
},
getTGrid: (props: TGridProps) => {
if (props.type === 'standalone' && this._store) {
const { getState } = this._store;
const state = getState();
if (state && state.app) {
this._store = undefined;
}
}
return getTGridLazy(props, {
store: this._store,
storage: this._storage,
setStore: this.setStore.bind(this),
data,
});
},
getTGridReducer: () => {
return tGridReducer;
},
getLoadingPanel: (props: LoadingPanelProps) => {
return getLoadingPanelLazy(props);
},
getLastUpdated: (props: LastUpdatedAtProps) => {
return getLastUpdatedLazy(props);
},
getFieldBrowser: (props: FieldBrowserProps) => {
return getFieldsBrowserLazy(props, {
store: this._store!,
});
},
getUseAddToTimeline: () => {
return useAddToTimeline;
},
getUseAddToTimelineSensor: () => {
return useAddToTimelineSensor;
},
getUseDraggableKeyboardWrapper: () => {
return useDraggableKeyboardWrapper;
},
setTGridEmbeddedStore: (store: Store) => {
this.setStore(store);
},
getAddToCaseAction: (props) => {
return getAddToCaseLazy(props, {
store: this._store!,
storage: this._storage,
setStore: this.setStore.bind(this),
});
},
getAddToCasePopover: (props) => {
return getAddToCasePopoverLazy(props, {
store: this._store!,
storage: this._storage,
setStore: this.setStore.bind(this),
});
},
getAddToExistingCaseButton: (props) => {
return getAddToExistingCaseButtonLazy(props, {
store: this._store!,
storage: this._storage,
setStore: this.setStore.bind(this),
});
},
getAddToNewCaseButton: (props) => {
return getAddToNewCaseButtonLazy(props, {
store: this._store!,
storage: this._storage,
setStore: this.setStore.bind(this),
});
},
};
}
private setStore(store: Store) {
this._store = store;
}
public stop() {}
}