mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Reporting] Initial Export types plugin (#158479)
## Summary Closes https://github.com/elastic/kibana/issues/158512 - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios Co-authored-by: Tim Sullivan <tsullivan@users.noreply.github.com>
This commit is contained in:
parent
1c1f016010
commit
3746b73f5c
18 changed files with 138 additions and 5 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -521,6 +521,7 @@ packages/kbn-repo-source-classifier @elastic/kibana-operations
|
|||
packages/kbn-repo-source-classifier-cli @elastic/kibana-operations
|
||||
packages/kbn-reporting/common @elastic/appex-sharedux
|
||||
x-pack/examples/reporting_example @elastic/appex-sharedux
|
||||
x-pack/plugins/reporting_export_types @elastic/appex-sharedux
|
||||
x-pack/plugins/reporting @elastic/appex-sharedux
|
||||
x-pack/test/plugin_functional/plugins/resolver_test @elastic/security-solution
|
||||
examples/response_stream @elastic/ml-ui
|
||||
|
|
|
@ -677,6 +677,10 @@ Elastic.
|
|||
|An awesome Kibana reporting plugin
|
||||
|
||||
|
||||
|{kib-repo}blob/{branch}/x-pack/plugins/reporting_export_types/README.md[reportingExportTypes]
|
||||
|This plugin is intended to be a central point for the export types of reporting to convene before hitting the reporting plugin.
|
||||
|
||||
|
||||
|{kib-repo}blob/{branch}/x-pack/plugins/rollup/README.md[rollup]
|
||||
|Welcome to the Kibana rollup plugin! This plugin provides Kibana support for Elasticsearch's rollup feature. Please refer to the Elasticsearch documentation to understand rollup indices and how to create rollup jobs.
|
||||
|
||||
|
|
|
@ -524,6 +524,7 @@
|
|||
"@kbn/repo-packages": "link:packages/kbn-repo-packages",
|
||||
"@kbn/reporting-common": "link:packages/kbn-reporting/common",
|
||||
"@kbn/reporting-example-plugin": "link:x-pack/examples/reporting_example",
|
||||
"@kbn/reporting-export-types-plugin": "link:x-pack/plugins/reporting_export_types",
|
||||
"@kbn/reporting-plugin": "link:x-pack/plugins/reporting",
|
||||
"@kbn/resolver-test-plugin": "link:x-pack/test/plugin_functional/plugins/resolver_test",
|
||||
"@kbn/response-stream-plugin": "link:examples/response_stream",
|
||||
|
|
|
@ -1036,6 +1036,8 @@
|
|||
"@kbn/reporting-common/*": ["packages/kbn-reporting/common/*"],
|
||||
"@kbn/reporting-example-plugin": ["x-pack/examples/reporting_example"],
|
||||
"@kbn/reporting-example-plugin/*": ["x-pack/examples/reporting_example/*"],
|
||||
"@kbn/reporting-export-types-plugin": ["x-pack/plugins/reporting_export_types"],
|
||||
"@kbn/reporting-export-types-plugin/*": ["x-pack/plugins/reporting_export_types/*"],
|
||||
"@kbn/reporting-plugin": ["x-pack/plugins/reporting"],
|
||||
"@kbn/reporting-plugin/*": ["x-pack/plugins/reporting/*"],
|
||||
"@kbn/resolver-test-plugin": ["x-pack/test/plugin_functional/plugins/resolver_test"],
|
||||
|
|
|
@ -12,6 +12,7 @@ let mockReportingPlugin: ReportingStart;
|
|||
beforeEach(() => {
|
||||
mockReportingPlugin = {
|
||||
usesUiCapabilities: () => false,
|
||||
registerExportTypes: () => {},
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -87,6 +88,7 @@ it('Provides a feature declaration ', () => {
|
|||
it(`Calls on Reporting whether to include Generate PDF as a sub-feature`, () => {
|
||||
mockReportingPlugin = {
|
||||
usesUiCapabilities: () => true,
|
||||
registerExportTypes: () => {},
|
||||
};
|
||||
expect(getCanvasFeature({ reporting: mockReportingPlugin })).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
|
|
@ -127,6 +127,7 @@ export class ReportingCore {
|
|||
|
||||
this.getContract = () => ({
|
||||
usesUiCapabilities: () => config.roles.enabled === false,
|
||||
registerExportTypes: (id) => id,
|
||||
});
|
||||
|
||||
this.executing = new Set();
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('POST /diagnose/browser', () => {
|
|||
httpSetup.registerRouteHandlerContext<ReportingRequestHandlerContext, 'reporting'>(
|
||||
reportingSymbol,
|
||||
'reporting',
|
||||
() => ({ usesUiCapabilities: () => false })
|
||||
() => ({ usesUiCapabilities: () => false, registerExportTypes: jest.fn() })
|
||||
);
|
||||
|
||||
const docLinksSetupMock = docLinksServiceMock.createSetupContract();
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('POST /diagnose/screenshot', () => {
|
|||
httpSetup.registerRouteHandlerContext<ReportingRequestHandlerContext, 'reporting'>(
|
||||
reportingSymbol,
|
||||
'reporting',
|
||||
() => ({ usesUiCapabilities: () => false })
|
||||
() => ({ usesUiCapabilities: () => false, registerExportTypes: jest.fn() })
|
||||
);
|
||||
|
||||
core = await createMockReportingCore(
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('POST /api/reporting/generate', () => {
|
|||
httpSetup.registerRouteHandlerContext<ReportingRequestHandlerContext, 'reporting'>(
|
||||
reportingSymbol,
|
||||
'reporting',
|
||||
() => ({ usesUiCapabilities: jest.fn() })
|
||||
() => ({ usesUiCapabilities: jest.fn(), registerExportTypes: jest.fn() })
|
||||
);
|
||||
|
||||
const mockSetupDeps = createMockPluginSetup({
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('GET /api/reporting/jobs/download', () => {
|
|||
httpSetup.registerRouteHandlerContext<ReportingRequestHandlerContext, 'reporting'>(
|
||||
reportingSymbol,
|
||||
'reporting',
|
||||
() => ({ usesUiCapabilities: jest.fn() })
|
||||
() => ({ usesUiCapabilities: jest.fn(), registerExportTypes: jest.fn() })
|
||||
);
|
||||
|
||||
mockSetupDeps = createMockPluginSetup({
|
||||
|
|
|
@ -34,6 +34,7 @@ import type { BaseParams, BasePayload, UrlOrUrlLocatorTuple } from '../common/ty
|
|||
import type { ReportingConfigType } from './config';
|
||||
import type { ReportingCore } from './core';
|
||||
import type { ReportTaskParams } from './lib/tasks';
|
||||
import { ExportTypesRegistry } from './lib';
|
||||
|
||||
/**
|
||||
* Plugin Setup Contract
|
||||
|
@ -43,6 +44,7 @@ export interface ReportingSetup {
|
|||
* Used to inform plugins if Reporting config is compatible with UI Capabilities / Application Sub-Feature Controls
|
||||
*/
|
||||
usesUiCapabilities: () => boolean;
|
||||
registerExportTypes: ExportTypesRegistry['register'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
3
x-pack/plugins/reporting_export_types/README.md
Executable file
3
x-pack/plugins/reporting_export_types/README.md
Executable file
|
@ -0,0 +1,3 @@
|
|||
# exportTypePlugin
|
||||
|
||||
This plugin is intended to be a central point for the export types of reporting to convene before hitting the reporting plugin.
|
25
x-pack/plugins/reporting_export_types/kibana.jsonc
Normal file
25
x-pack/plugins/reporting_export_types/kibana.jsonc
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"type": "plugin",
|
||||
"id": "@kbn/reporting-export-types-plugin",
|
||||
"owner": "@elastic/appex-sharedux",
|
||||
"description": "Currently PDF, PNG or CSV export types for the reporting plugin",
|
||||
"plugin": {
|
||||
"id": "reportingExportTypes",
|
||||
"server": true,
|
||||
"browser": false,
|
||||
"configPath": [
|
||||
"xpack",
|
||||
"reporting"
|
||||
],
|
||||
"requiredPlugins": [
|
||||
"reporting"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"security",
|
||||
"spaces",
|
||||
"usageCollection"
|
||||
],
|
||||
"requiredBundles": [
|
||||
]
|
||||
}
|
||||
}
|
18
x-pack/plugins/reporting_export_types/server/index.ts
Normal file
18
x-pack/plugins/reporting_export_types/server/index.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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 { PluginInitializerContext, Logger } from '@kbn/core/server';
|
||||
import { ExportTypesPlugin } from './plugin';
|
||||
|
||||
// This exports static code and TypeScript types,
|
||||
// as well as, Kibana Platform `plugin()` initializer.
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext, logger: Logger) {
|
||||
return new ExportTypesPlugin(initializerContext, logger);
|
||||
}
|
||||
|
||||
export type { ExportTypesPluginSetup, ExportTypesPluginStart } from './types';
|
40
x-pack/plugins/reporting_export_types/server/plugin.ts
Normal file
40
x-pack/plugins/reporting_export_types/server/plugin.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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 { PluginInitializerContext, CoreSetup, CoreStart, Plugin, Logger } from '@kbn/core/server';
|
||||
|
||||
import { ConfigSchema } from '@kbn/reporting-plugin/server/config';
|
||||
import { ExportTypesPluginSetup, ExportTypesPluginStart } from './types';
|
||||
|
||||
export class ExportTypesPlugin
|
||||
implements Plugin<{}, {}, ExportTypesPluginSetup, ExportTypesPluginStart>
|
||||
{
|
||||
exportTypes = [
|
||||
// new CsvExportType(),
|
||||
// new PdfExportType(),
|
||||
// new PngExportType(),
|
||||
];
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext<typeof ConfigSchema>, logger: Logger) {
|
||||
logger = initializerContext.logger.get();
|
||||
}
|
||||
|
||||
public setup(core: CoreSetup, pluginsSetup: ExportTypesPluginSetup) {
|
||||
const { reporting } = pluginsSetup;
|
||||
this.exportTypes.forEach((eType) => {
|
||||
reporting.registerExportTypes(eType);
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
||||
public start(core: CoreStart, plugins: ExportTypesPluginStart) {
|
||||
this.exportTypes.forEach((eType) => {});
|
||||
return {};
|
||||
}
|
||||
|
||||
public stop() {}
|
||||
}
|
14
x-pack/plugins/reporting_export_types/server/types.ts
Normal file
14
x-pack/plugins/reporting_export_types/server/types.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 type { ReportingSetup, ReportingStart } from '@kbn/reporting-plugin/server/types';
|
||||
|
||||
export interface ExportTypesPluginSetup {
|
||||
reporting: ReportingSetup;
|
||||
}
|
||||
export interface ExportTypesPluginStart {
|
||||
reporting: ReportingStart;
|
||||
}
|
16
x-pack/plugins/reporting_export_types/tsconfig.json
Normal file
16
x-pack/plugins/reporting_export_types/tsconfig.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types"
|
||||
},
|
||||
"include": [
|
||||
"common/**/*",
|
||||
"server/**/*",
|
||||
"../../../typings/**/*"
|
||||
],
|
||||
"kbn_references": [
|
||||
"@kbn/core",
|
||||
"@kbn/reporting-plugin",
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
|
@ -4819,6 +4819,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/reporting-export-types-plugin@link:x-pack/plugins/reporting_export_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/reporting-plugin@link:x-pack/plugins/reporting":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
@ -9496,7 +9500,7 @@
|
|||
dependencies:
|
||||
"@types/yargs-parser" "*"
|
||||
|
||||
"@types/yargs@^17.0.8", "@types/yargs@^17.0.10":
|
||||
"@types/yargs@^17.0.10", "@types/yargs@^17.0.8":
|
||||
version "17.0.24"
|
||||
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.24.tgz#b3ef8d50ad4aa6aecf6ddc97c580a00f5aa11902"
|
||||
integrity sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue