Skip to content

Commit 28aff3b

Browse files
Merge branch 'master' into issue-xxx-np-management
2 parents e9cb504 + 2598d15 commit 28aff3b

File tree

60 files changed

+689
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+689
-477
lines changed

.github/workflows/pr-project-assigner.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
[
1616
{ "label": "Team:AppArch", "projectName": "kibana-app-arch", "columnId": 6173897 },
1717
{ "label": "Feature:Lens", "projectName": "Lens", "columnId": 6219362 },
18-
{ "label": "Team:Platform", "projectName": "kibana-platform", "columnId": 5514360 },
19-
{"label": "Team:Canvas", "projectName": "canvas", "columnId": 6187580}
18+
{ "label": "Team:Canvas", "projectName": "canvas", "columnId": 6187580 }
2019
]
2120
ghToken: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<kbn-management-app>
2-
<div id="management-landing"></div>
2+
<div id="management-landing" data-test-subj="management-landing"></div>
33
</kbn-management-app>

src/plugins/management/public/management_app.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ManagementApp {
3434
readonly basePath: string;
3535
readonly order: number;
3636
readonly mount: ManagementSectionMount;
37-
protected enabledStatus: boolean = true;
37+
private enabledStatus = true;
3838

3939
constructor(
4040
{ id, title, basePath, order = 100, mount }: CreateManagementApp,
@@ -54,6 +54,11 @@ export class ManagementApp {
5454
title,
5555
mount: async ({}, params) => {
5656
let appUnmount: Unmount;
57+
if (!this.enabledStatus) {
58+
const [coreStart] = await getStartServices();
59+
coreStart.application.navigateToApp('kibana#/management');
60+
return () => {};
61+
}
5762
async function setBreadcrumbs(crumbs: ChromeBreadcrumb[]) {
5863
const [coreStart] = await getStartServices();
5964
coreStart.chrome.setBreadcrumbs([

test/plugin_functional/plugins/management_test_plugin/public/plugin.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ export class ManagementTestPlugin
6262
};
6363
},
6464
});
65+
66+
testSection!
67+
.registerApp({
68+
id: 'test-management-disabled',
69+
title: 'Management Test Disabled',
70+
mount(params) {
71+
params.setBreadcrumbs([{ text: 'Management Test Disabled' }]);
72+
ReactDOM.render(<div>This is a secret that should never be seen!</div>, params.element);
73+
74+
return () => {
75+
ReactDOM.unmountComponentAtNode(params.element);
76+
};
77+
},
78+
})
79+
.disable();
80+
6581
return {};
6682
}
6783

test/plugin_functional/test_suites/management/management_plugin.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,13 @@ export default function({ getService, getPageObjects }) {
3636
await testSubjects.click('test-management-link-basepath');
3737
await testSubjects.existOrFail('test-management-link-one');
3838
});
39+
40+
it('should redirect when app is disabled', async () => {
41+
await PageObjects.common.navigateToActualUrl(
42+
'kibana',
43+
'management/test-section/test-management-disabled'
44+
);
45+
await testSubjects.existOrFail('management-landing');
46+
});
3947
});
4048
}

x-pack/legacy/plugins/reporting/index.ts

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,20 @@
77
import { resolve } from 'path';
88
import { i18n } from '@kbn/i18n';
99
import { Legacy } from 'kibana';
10-
import { IUiSettingsClient } from 'src/core/server';
11-
import { XPackMainPlugin } from '../xpack_main/server/xpack_main';
1210
import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants';
13-
// @ts-ignore untyped module defintition
14-
import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status';
15-
import { registerRoutes } from './server/routes';
16-
import {
17-
LevelLogger,
18-
checkLicenseFactory,
19-
getExportTypesRegistry,
20-
runValidations,
21-
} from './server/lib';
22-
import { createBrowserDriverFactory } from './server/browsers';
23-
import { registerReportingUsageCollector } from './server/usage';
2411
import { ReportingConfigOptions, ReportingPluginSpecOptions } from './types.d';
2512
import { config as reportingConfig } from './config';
26-
import { logConfiguration } from './log_configuration';
13+
import {
14+
LegacySetup,
15+
ReportingPlugin,
16+
ReportingSetupDeps,
17+
reportingPluginFactory,
18+
} from './server/plugin';
2719

2820
const kbToBase64Length = (kb: number) => {
2921
return Math.floor((kb * 1024 * 8) / 6);
3022
};
3123

32-
type LegacyPlugins = Legacy.Server['plugins'];
33-
34-
export interface ServerFacade {
35-
config: Legacy.Server['config'];
36-
info: Legacy.Server['info'];
37-
log: Legacy.Server['log'];
38-
plugins: {
39-
elasticsearch: LegacyPlugins['elasticsearch'];
40-
security: LegacyPlugins['security'];
41-
xpack_main: XPackMainPlugin & {
42-
status?: any;
43-
};
44-
};
45-
route: Legacy.Server['route'];
46-
savedObjects: Legacy.Server['savedObjects'];
47-
uiSettingsServiceFactory: Legacy.Server['uiSettingsServiceFactory'];
48-
fieldFormatServiceFactory: (uiConfig: IUiSettingsClient) => unknown;
49-
}
50-
5124
export const reporting = (kibana: any) => {
5225
return new kibana.Plugin({
5326
id: PLUGIN_ID,
@@ -93,7 +66,11 @@ export const reporting = (kibana: any) => {
9366
},
9467

9568
async init(server: Legacy.Server) {
96-
const serverFacade: ServerFacade = {
69+
const coreSetup = server.newPlatform.setup.core;
70+
const pluginsSetup: ReportingSetupDeps = {
71+
usageCollection: server.newPlatform.setup.plugins.usageCollection,
72+
};
73+
const __LEGACY: LegacySetup = {
9774
config: server.config,
9875
info: server.info,
9976
route: server.route.bind(server),
@@ -108,38 +85,9 @@ export const reporting = (kibana: any) => {
10885
fieldFormatServiceFactory: server.fieldFormatServiceFactory,
10986
log: server.log.bind(server),
11087
};
111-
const exportTypesRegistry = getExportTypesRegistry();
112-
113-
let isCollectorReady = false;
114-
// Register a function with server to manage the collection of usage stats
115-
const { usageCollection } = server.newPlatform.setup.plugins;
116-
registerReportingUsageCollector(
117-
usageCollection,
118-
serverFacade,
119-
() => isCollectorReady,
120-
exportTypesRegistry
121-
);
122-
123-
const logger = LevelLogger.createForServer(serverFacade, [PLUGIN_ID]);
124-
const browserDriverFactory = await createBrowserDriverFactory(serverFacade);
125-
126-
logConfiguration(serverFacade, logger);
127-
runValidations(serverFacade, logger, browserDriverFactory);
128-
129-
const { xpack_main: xpackMainPlugin } = serverFacade.plugins;
130-
mirrorPluginStatus(xpackMainPlugin, this);
131-
const checkLicense = checkLicenseFactory(exportTypesRegistry);
132-
(xpackMainPlugin as any).status.once('green', () => {
133-
// Register a function that is called whenever the xpack info changes,
134-
// to re-compute the license check results for this plugin
135-
xpackMainPlugin.info.feature(this.id).registerLicenseCheckResultsGenerator(checkLicense);
136-
});
137-
138-
// Post initialization of the above code, the collector is now ready to fetch its data
139-
isCollectorReady = true;
14088

141-
// Reporting routes
142-
registerRoutes(serverFacade, exportTypesRegistry, browserDriverFactory, logger);
89+
const plugin: ReportingPlugin = reportingPluginFactory(__LEGACY, this);
90+
await plugin.setup(coreSetup, pluginsSetup);
14391
},
14492

14593
deprecations({ unused }: any) {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { Legacy } from 'kibana';
8+
import { CoreSetup, CoreStart, Plugin } from 'src/core/server';
9+
import { IUiSettingsClient } from 'src/core/server';
10+
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
11+
import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
12+
// @ts-ignore
13+
import { mirrorPluginStatus } from '../../../server/lib/mirror_plugin_status';
14+
import { PLUGIN_ID } from '../common/constants';
15+
import { ReportingPluginSpecOptions } from '../types.d';
16+
import { registerRoutes } from './routes';
17+
import { LevelLogger, checkLicenseFactory, getExportTypesRegistry, runValidations } from './lib';
18+
import { createBrowserDriverFactory } from './browsers';
19+
import { registerReportingUsageCollector } from './usage';
20+
import { logConfiguration } from '../log_configuration';
21+
22+
// For now there is no exposed functionality to other plugins
23+
export type ReportingSetup = object;
24+
export type ReportingStart = object;
25+
26+
export interface ReportingSetupDeps {
27+
usageCollection: UsageCollectionSetup;
28+
}
29+
export type ReportingStartDeps = object;
30+
31+
type LegacyPlugins = Legacy.Server['plugins'];
32+
33+
export interface LegacySetup {
34+
config: Legacy.Server['config'];
35+
info: Legacy.Server['info'];
36+
log: Legacy.Server['log'];
37+
plugins: {
38+
elasticsearch: LegacyPlugins['elasticsearch'];
39+
security: LegacyPlugins['security'];
40+
xpack_main: XPackMainPlugin & {
41+
status?: any;
42+
};
43+
};
44+
route: Legacy.Server['route'];
45+
savedObjects: Legacy.Server['savedObjects'];
46+
uiSettingsServiceFactory: Legacy.Server['uiSettingsServiceFactory'];
47+
fieldFormatServiceFactory: (uiConfig: IUiSettingsClient) => unknown;
48+
}
49+
50+
export type ReportingPlugin = Plugin<
51+
ReportingSetup,
52+
ReportingStart,
53+
ReportingSetupDeps,
54+
ReportingStartDeps
55+
>;
56+
57+
/* We need a factory that returns an instance of the class because the class
58+
* implementation itself restricts against having Legacy dependencies passed
59+
* into `setup`. The factory parameters take the legacy dependencies, and the
60+
* `setup` method gets it from enclosure */
61+
export function reportingPluginFactory(
62+
__LEGACY: LegacySetup,
63+
legacyPlugin: ReportingPluginSpecOptions
64+
) {
65+
return new (class ReportingPlugin implements ReportingPlugin {
66+
public async setup(core: CoreSetup, plugins: ReportingSetupDeps): Promise<ReportingSetup> {
67+
const exportTypesRegistry = getExportTypesRegistry();
68+
69+
let isCollectorReady = false;
70+
// Register a function with server to manage the collection of usage stats
71+
const { usageCollection } = plugins;
72+
registerReportingUsageCollector(
73+
usageCollection,
74+
__LEGACY,
75+
() => isCollectorReady,
76+
exportTypesRegistry
77+
);
78+
79+
const logger = LevelLogger.createForServer(__LEGACY, [PLUGIN_ID]);
80+
const browserDriverFactory = await createBrowserDriverFactory(__LEGACY);
81+
82+
logConfiguration(__LEGACY, logger);
83+
runValidations(__LEGACY, logger, browserDriverFactory);
84+
85+
const { xpack_main: xpackMainPlugin } = __LEGACY.plugins;
86+
mirrorPluginStatus(xpackMainPlugin, legacyPlugin);
87+
const checkLicense = checkLicenseFactory(exportTypesRegistry);
88+
(xpackMainPlugin as any).status.once('green', () => {
89+
// Register a function that is called whenever the xpack info changes,
90+
// to re-compute the license check results for this plugin
91+
xpackMainPlugin.info.feature(PLUGIN_ID).registerLicenseCheckResultsGenerator(checkLicense);
92+
});
93+
94+
// Post initialization of the above code, the collector is now ready to fetch its data
95+
isCollectorReady = true;
96+
97+
// Reporting routes
98+
registerRoutes(__LEGACY, exportTypesRegistry, browserDriverFactory, logger);
99+
100+
return {};
101+
}
102+
103+
public start(core: CoreStart, plugins: ReportingStartDeps): ReportingStart {
104+
return {};
105+
}
106+
})();
107+
}

x-pack/legacy/plugins/reporting/types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { CancellationToken } from './common/cancellation_token';
1515
import { LevelLogger } from './server/lib/level_logger';
1616
import { HeadlessChromiumDriverFactory } from './server/browsers/chromium/driver_factory';
1717
import { BrowserType } from './server/browsers/types';
18-
import { ServerFacade } from './index';
18+
import { LegacySetup } from './server/plugin';
1919

2020
export type ReportingPlugin = object; // For Plugin contract
2121

@@ -69,6 +69,8 @@ interface GenerateExportTypePayload {
6969
* Legacy System
7070
*/
7171

72+
export type ServerFacade = LegacySetup;
73+
7274
export type ReportingPluginSpecOptions = Legacy.PluginSpecOptions;
7375

7476
export type EnqueueJobFn = <JobParamsType>(
@@ -353,5 +355,3 @@ export interface InterceptedRequest {
353355
frameId: string;
354356
resourceType: string;
355357
}
356-
357-
export { ServerFacade };

x-pack/legacy/plugins/siem/public/components/alerts_viewer/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { MatrixHistogramGqlQuery } from '../../containers/matrix_histogram/index
1616
const ID = 'alertsOverTimeQuery';
1717
export const alertsStackByOptions: MatrixHistogramOption[] = [
1818
{
19-
text: i18n.CATEGORY,
19+
text: 'event.category',
2020
value: 'event.category',
2121
},
2222
{
23-
text: i18n.MODULE,
23+
text: 'event.module',
2424
value: 'event.module',
2525
},
2626
];
@@ -54,7 +54,6 @@ export const AlertsView = ({
5454
<>
5555
<MatrixHistogramContainer
5656
dataKey={dataKey}
57-
deleteQuery={deleteQuery}
5857
defaultStackByOption={alertsStackByOptions[1]}
5958
endDate={endDate}
6059
errorMessage={i18n.ERROR_FETCHING_ALERTS_DATA}
@@ -68,7 +67,7 @@ export const AlertsView = ({
6867
stackByOptions={alertsStackByOptions}
6968
startDate={startDate}
7069
subtitle={getSubtitle}
71-
title={i18n.ALERTS_DOCUMENT_TYPE}
70+
title={i18n.ALERTS_GRAPH_TITLE}
7271
type={type}
7372
updateDateRange={updateDateRange}
7473
/>

x-pack/legacy/plugins/siem/public/components/alerts_viewer/translations.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ export const TOTAL_COUNT_OF_ALERTS = i18n.translate('xpack.siem.alertsView.total
1414
defaultMessage: 'alerts match the search criteria',
1515
});
1616

17-
export const ALERTS_TABLE_TITLE = i18n.translate('xpack.siem.alertsView.alertsDocumentType', {
17+
export const ALERTS_TABLE_TITLE = i18n.translate('xpack.siem.alertsView.alertsTableTitle', {
1818
defaultMessage: 'Alerts',
1919
});
2020

21+
export const ALERTS_GRAPH_TITLE = i18n.translate('xpack.siem.alertsView.alertsGraphTitle', {
22+
defaultMessage: 'Alert detection frequency',
23+
});
24+
2125
export const ALERTS_STACK_BY_MODULE = i18n.translate(
2226
'xpack.siem.alertsView.alertsStackByOptions.module',
2327
{

0 commit comments

Comments
 (0)