Skip to content
Closed
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 @@ -438,6 +438,7 @@ export type ImportTimelineResultSchema = runtimeTypes.TypeOf<typeof importTimeli
export type TimelineEventsType = 'all' | 'raw' | 'alert' | 'signal' | 'custom' | 'eql';

export enum TimelineTabs {
discover = 'discover',
query = 'query',
graph = 'graph',
notes = 'notes',
Expand Down
14 changes: 13 additions & 1 deletion x-pack/plugins/security_solution/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
"requiredPlugins": [
"actions",
"alerting",
"charts",
"cases",
"cloud",
"cloudDefend",
"cloudSecurityPosture",
"dashboard",
"data",
"ecsDataQualityDashboard",
"fieldFormats",
"urlForwarding",
"navigation",
"dataViews",
"embeddable",
"eventLog",
Expand All @@ -38,11 +42,17 @@
"timelines",
"triggersActionsUi",
"uiActions",
"savedObjects",
"savedObjectsFinder",
"unifiedSearch",
"dataViewEditor",
"expressions",
"unifiedFieldList",
"files",
"controls",
"dataViews",
"savedObjectsManagement",
"unifiedHistogram",
],
"optionalPlugins": [
"cloudExperiments",
Expand All @@ -51,6 +61,7 @@
"ml",
"newsfeed",
"security",
"share",
"usageCollection",
"lists",
"home",
Expand All @@ -67,7 +78,8 @@
"usageCollection",
"lists",
"ml",
"unifiedSearch"
"unifiedSearch",
"savedSearch",
],
"extraPublicDirs": [
"common"
Expand Down
43 changes: 42 additions & 1 deletion x-pack/plugins/security_solution/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ import type {
Plugin as IPlugin,
} from '@kbn/core/public';
import { DEFAULT_APP_CATEGORIES, AppNavLinkStatus } from '@kbn/core/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { setStateToKbnUrl, Storage } from '@kbn/kibana-utils-plugin/public';
import { DiscoverSingleDocLocatorDefinition } from '@kbn/discover-plugin/public/application/doc/locator';
import { DiscoverContextAppLocatorDefinition } from '@kbn/discover-plugin/public/application/context/services/locator';
import { DiscoverAppLocatorDefinition } from '@kbn/discover-plugin/common/locator';
import {
setHeaderActionMenuMounter,
setScopedHistory,
syncHistoryLocations,
} from '@kbn/discover-plugin/public/kibana_services';
import type { DiscoverSingleDocLocator } from '@kbn/discover-plugin/public/application/doc/locator';
import type { DiscoverAppLocator } from '@kbn/discover-plugin/common/locator';
import type { DiscoverContextAppLocator } from '@kbn/discover-plugin/public/application/context/services/locator';
import type {
PluginSetup,
PluginStart,
Expand All @@ -30,6 +41,7 @@ import type {
StartedSubPlugins,
StartPluginsDependencies,
} from './types';
import { buildDiscoverServices } from './types';
import { initTelemetry, TelemetryService } from './common/lib/telemetry';
import { KibanaServices } from './common/lib/kibana/services';
import { SOLUTION_NAME } from './common/translations';
Expand Down Expand Up @@ -116,6 +128,10 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
private _store?: SecurityAppStore;
private _actionsRegistered?: boolean = false;

private locator?: DiscoverAppLocator;
private contextLocator?: DiscoverContextAppLocator;
private singleDocLocator?: DiscoverSingleDocLocator;

public setup(
core: CoreSetup<StartPluginsDependencies, PluginStart>,
plugins: SetupPlugins
Expand Down Expand Up @@ -145,6 +161,20 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
});
}

if (plugins.share) {
const useHash = core.uiSettings.get('state:storeInSessionStorage');
this.locator = plugins.share.url.locators.create(
new DiscoverAppLocatorDefinition({ useHash, setStateToKbnUrl })
);

this.contextLocator = plugins.share.url.locators.create(
new DiscoverContextAppLocatorDefinition({ useHash })
);
this.singleDocLocator = plugins.share.url.locators.create(
new DiscoverSingleDocLocatorDefinition()
);
}

/**
* `StartServices` which are needed by the `renderApp` function when mounting any of the subPlugin applications.
* This is a promise because these aren't available until the `start` lifecycle phase but they are referenced
Expand Down Expand Up @@ -172,6 +202,14 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
savedObjectsManagement: startPluginsDeps.savedObjectsManagement,
isSidebarEnabled$: this.isSidebarEnabled$,
telemetry: this.telemetry.start(),
...buildDiscoverServices(
coreStart,
startPluginsDeps,
this.initializerContext,
this.locator!,
this.contextLocator!,
this.singleDocLocator!
),
};
return services;
};
Expand All @@ -189,6 +227,9 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
mount: async (params: AppMountParameters) => {
// required to show the alert table inside cases
const { alertsTableConfigurationRegistry } = plugins.triggersActionsUi;
setScopedHistory(params.history);
setHeaderActionMenuMounter(params.setHeaderActionMenu);
syncHistoryLocations();
const { registerAlertsTableConfiguration } =
await this.lazyRegisterAlertsTableConfiguration();
registerAlertsTableConfiguration(alertsTableConfigurationRegistry, this.storage);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 React from 'react';
import { css } from '@emotion/react';
import { DiscoverMainRoute } from '@kbn/discover-plugin/public/application/main';

const DiscoverTabContent = () => {
return (
<div
css={css`
width: 100%;
overflow: scroll;
`}
>
<DiscoverMainRoute isDev={false} />
</div>
);
};

// eslint-disable-next-line import/no-default-export
export default DiscoverTabContent;
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const GraphTabContent = lazy(() => import('../graph_tab_content'));
const NotesTabContent = lazy(() => import('../notes_tab_content'));
const PinnedTabContent = lazy(() => import('../pinned_tab_content'));
const SessionTabContent = lazy(() => import('../session_tab_content'));
const DiscoverTabContent = lazy(() => import('../discover_tab_content'));

interface BasicTimelineTab {
renderCellValue: (props: CellValueElementProps) => React.ReactNode;
Expand Down Expand Up @@ -130,6 +131,13 @@ const PinnedTab: React.FC<{
));
PinnedTab.displayName = 'PinnedTab';

const DiscoverTab: React.FC = memo(() => (
<Suspense fallback={<EuiLoadingContent lines={10} />}>
<DiscoverTabContent />
</Suspense>
));
DiscoverTab.displayName = 'DiscoverTab';

type ActiveTimelineTabProps = BasicTimelineTab & { activeTimelineTab: TimelineTabs };

const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
Expand All @@ -143,6 +151,8 @@ const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
return <NotesTab timelineId={timelineId} />;
case TimelineTabs.session:
return <SessionTab timelineId={timelineId} />;
case TimelineTabs.discover:
return <DiscoverTab />;
default:
return null;
}
Expand Down Expand Up @@ -183,6 +193,12 @@ const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
timelineId={timelineId}
/>
</HideShowContainer>
<HideShowContainer
$isVisible={TimelineTabs.discover === activeTimelineTab}
data-test-subj={`timeline-tab-content-${TimelineTabs.discover}`}
>
<DiscoverTab />
</HideShowContainer>
{timelineType === TimelineType.default && (
<HideShowContainer
$isVisible={TimelineTabs.eql === activeTimelineTab}
Expand Down Expand Up @@ -309,6 +325,10 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
setActiveTab(TimelineTabs.session);
}, [setActiveTab]);

const setDiscoverAsActiveTab = useCallback(() => {
setActiveTab(TimelineTabs.discover);
}, [setActiveTab]);

useEffect(() => {
if (!graphEventId && activeTab === TimelineTabs.graph) {
setQueryAsActiveTab();
Expand Down Expand Up @@ -389,6 +409,15 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
</div>
)}
</StyledEuiTab>
<StyledEuiTab
data-test-subj={`timelineTabs-${TimelineTabs.discover}`}
onClick={setDiscoverAsActiveTab}
isSelected={activeTab === TimelineTabs.discover}
disabled={false}
key={TimelineTabs.discover}
>
<span>{i18n.DISCOVER_TAB}</span>
</StyledEuiTab>
</EuiTabs>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ export const SESSION_TAB = i18n.translate(
defaultMessage: 'Session View',
}
);

export const DISCOVER_TAB = i18n.translate(
'xpack.securitySolution.timeline.tabs.discoverTabTimelineTitle',
{
defaultMessage: 'Discover',
}
);
Loading