diff --git a/x-pack/plugins/reporting/common/types.d.ts b/x-pack/plugins/reporting/common/types.d.ts
new file mode 100644
index 0000000000000..34f0bc9ac8a36
--- /dev/null
+++ b/x-pack/plugins/reporting/common/types.d.ts
@@ -0,0 +1,7 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+export { ConfigType } from '../server/config';
diff --git a/x-pack/plugins/reporting/constants.ts b/x-pack/plugins/reporting/constants.ts
index 5756d29face12..8079c5b1d9887 100644
--- a/x-pack/plugins/reporting/constants.ts
+++ b/x-pack/plugins/reporting/constants.ts
@@ -7,13 +7,6 @@
export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY =
'xpack.reporting.jobCompletionNotifications';
-export const JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG = {
- jobCompletionNotifier: {
- interval: 10000,
- intervalErrorMultiplier: 5,
- },
-};
-
// Routes
export const API_BASE_URL = '/api/reporting';
export const API_LIST_URL = `${API_BASE_URL}/jobs`;
diff --git a/x-pack/plugins/reporting/index.d.ts b/x-pack/plugins/reporting/index.d.ts
index 26d661e29bd94..77faf837e6505 100644
--- a/x-pack/plugins/reporting/index.d.ts
+++ b/x-pack/plugins/reporting/index.d.ts
@@ -4,15 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import {
- CoreSetup,
- CoreStart,
- HttpSetup,
- Plugin,
- PluginInitializerContext,
- NotificationsStart,
-} from '../../../src/core/public';
-
export type JobId = string;
export type JobStatus =
| 'completed'
@@ -21,9 +12,6 @@ export type JobStatus =
| 'processing'
| 'failed';
-export type HttpService = HttpSetup;
-export type NotificationsService = NotificationsStart;
-
export interface SourceJob {
_id: JobId;
_source: {
diff --git a/x-pack/plugins/reporting/public/components/report_listing.test.tsx b/x-pack/plugins/reporting/public/components/report_listing.test.tsx
index 380a3b3295b9f..787279e6caf9b 100644
--- a/x-pack/plugins/reporting/public/components/report_listing.test.tsx
+++ b/x-pack/plugins/reporting/public/components/report_listing.test.tsx
@@ -47,12 +47,24 @@ const toasts = {
addDanger: jest.fn(),
} as any;
+const mockPollConfig = {
+ jobCompletionNotifier: {
+ interval: 5000,
+ intervalErrorMultiplier: 3,
+ },
+ jobsRefresh: {
+ interval: 5000,
+ intervalErrorMultiplier: 3,
+ },
+};
+
describe('ReportListing', () => {
it('Report job listing with some items', () => {
const wrapper = mountWithIntl(
@@ -74,6 +86,7 @@ describe('ReportListing', () => {
}
+ pollConfig={mockPollConfig}
redirect={jest.fn()}
toasts={toasts}
/>
diff --git a/x-pack/plugins/reporting/public/components/report_listing.tsx b/x-pack/plugins/reporting/public/components/report_listing.tsx
index d8ed050fec6c6..f85c479c28e3a 100644
--- a/x-pack/plugins/reporting/public/components/report_listing.tsx
+++ b/x-pack/plugins/reporting/public/components/report_listing.tsx
@@ -16,14 +16,15 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { get } from 'lodash';
import moment from 'moment';
-import { Component, Fragment, default as React } from 'react';
+import { Component, default as React, Fragment } from 'react';
import { Subscription } from 'rxjs';
import { ApplicationStart, ToastsSetup } from 'src/core/public';
import { ILicense, LicensingPluginSetup } from '../../../licensing/public';
import { Poller } from '../../common/poller';
-import { JobStatuses, JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG } from '../../constants';
+import { JobStatuses } from '../../constants';
import { checkLicense } from '../lib/license_check';
import { JobQueueEntry, ReportingAPIClient } from '../lib/reporting_api_client';
+import { ClientConfigType } from '../plugin';
import {
ReportDeleteButton,
ReportDownloadButton,
@@ -53,6 +54,7 @@ export interface Props {
intl: InjectedIntl;
apiClient: ReportingAPIClient;
license$: LicensingPluginSetup['license$'];
+ pollConfig: ClientConfigType['poll'];
redirect: ApplicationStart['navigateToApp'];
toasts: ToastsSetup;
}
@@ -167,12 +169,10 @@ class ReportListingUi extends Component {
functionToPoll: () => {
return this.fetchJobs();
},
- pollFrequencyInMillis:
- JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG.jobCompletionNotifier.interval,
+ pollFrequencyInMillis: this.props.pollConfig.jobsRefresh.interval,
trailing: false,
continuePollingOnError: true,
- pollFrequencyErrorMultiplier:
- JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG.jobCompletionNotifier.intervalErrorMultiplier,
+ pollFrequencyErrorMultiplier: this.props.pollConfig.jobsRefresh.intervalErrorMultiplier,
});
this.poller.start();
this.licenseSubscription = this.props.license$.subscribe(this.licenseHandler);
diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.ts b/x-pack/plugins/reporting/public/lib/stream_handler.ts
index 3c121f1712685..eed6d5dd141e7 100644
--- a/x-pack/plugins/reporting/public/lib/stream_handler.ts
+++ b/x-pack/plugins/reporting/public/lib/stream_handler.ts
@@ -4,30 +4,23 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { i18n } from '@kbn/i18n';
import * as Rx from 'rxjs';
import { catchError, map } from 'rxjs/operators';
-import { i18n } from '@kbn/i18n';
+import { NotificationsSetup } from 'src/core/public';
import {
JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY,
JOB_STATUS_COMPLETED,
JOB_STATUS_FAILED,
JOB_STATUS_WARNINGS,
} from '../../constants';
-
-import {
- JobId,
- JobSummary,
- JobStatusBuckets,
- NotificationsService,
- SourceJob,
-} from '../../index.d';
-
+import { JobId, JobStatusBuckets, JobSummary, SourceJob } from '../../index.d';
import {
- getSuccessToast,
getFailureToast,
+ getGeneralErrorToast,
+ getSuccessToast,
getWarningFormulasToast,
getWarningMaxSizeToast,
- getGeneralErrorToast,
} from '../components';
import { ReportingAPIClient } from './reporting_api_client';
@@ -47,7 +40,7 @@ function summarizeJob(src: SourceJob): JobSummary {
}
export class ReportingNotifierStreamHandler {
- constructor(private notifications: NotificationsService, private apiClient: ReportingAPIClient) {}
+ constructor(private notifications: NotificationsSetup, private apiClient: ReportingAPIClient) {}
/*
* Use Kibana Toast API to show our messages
diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.tsx
index 08ba10ff69207..c40e7ad373eaf 100644
--- a/x-pack/plugins/reporting/public/plugin.tsx
+++ b/x-pack/plugins/reporting/public/plugin.tsx
@@ -4,44 +4,42 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import * as Rx from 'rxjs';
+import { i18n } from '@kbn/i18n';
+import { I18nProvider } from '@kbn/i18n/react';
import React from 'react';
import ReactDOM from 'react-dom';
+import * as Rx from 'rxjs';
import { catchError, filter, map, mergeMap, takeUntil } from 'rxjs/operators';
-import { i18n } from '@kbn/i18n';
+import {
+ CoreSetup,
+ CoreStart,
+ NotificationsSetup,
+ Plugin,
+ PluginInitializerContext,
+} from 'src/core/public';
import { ManagementSetup } from 'src/plugins/management/public';
-import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public';
-import { I18nProvider } from '@kbn/i18n/react';
import { UiActionsSetup } from 'src/plugins/ui_actions/public';
-
-import { ReportListing } from './components/report_listing';
-import { getGeneralErrorToast } from './components';
-
-import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler';
-import { ReportingAPIClient } from './lib/reporting_api_client';
-import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action';
-import { csvReportingProvider } from './share_context_menu/register_csv_reporting';
-import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting';
-
-import { LicensingPluginSetup } from '../../licensing/public';
+import { JobId, JobStatusBuckets } from '../';
import { CONTEXT_MENU_TRIGGER } from '../../../../src/plugins/embeddable/public';
-import { SharePluginSetup } from '../../../../src/plugins/share/public';
-
import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
} from '../../../../src/plugins/home/public';
+import { SharePluginSetup } from '../../../../src/plugins/share/public';
+import { LicensingPluginSetup } from '../../licensing/public';
+import { ConfigType } from '../common/types';
+import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants';
+import { getGeneralErrorToast } from './components';
+import { ReportListing } from './components/report_listing';
+import { ReportingAPIClient } from './lib/reporting_api_client';
+import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler';
+import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action';
+import { csvReportingProvider } from './share_context_menu/register_csv_reporting';
+import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting';
-import {
- JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG,
- JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY,
-} from '../constants';
-
-import { JobId, JobStatusBuckets, NotificationsService } from '..';
-
-const {
- jobCompletionNotifier: { interval: JOBS_REFRESH_INTERVAL },
-} = JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG;
+export interface ClientConfigType {
+ poll: ConfigType['poll'];
+}
function getStored(): JobId[] {
const sessionValue = sessionStorage.getItem(JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY);
@@ -49,7 +47,7 @@ function getStored(): JobId[] {
}
function handleError(
- notifications: NotificationsService,
+ notifications: NotificationsSetup,
err: Error
): Rx.Observable {
notifications.toasts.addDanger(
@@ -64,18 +62,19 @@ function handleError(
return Rx.of({ completed: [], failed: [] });
}
-export class ReportingPublicPlugin implements Plugin {
+export class ReportingPublicPlugin implements Plugin {
+ private config: ClientConfigType;
private readonly stop$ = new Rx.ReplaySubject(1);
-
private readonly title = i18n.translate('xpack.reporting.management.reportingTitle', {
defaultMessage: 'Reporting',
});
-
private readonly breadcrumbText = i18n.translate('xpack.reporting.breadcrumb', {
defaultMessage: 'Reporting',
});
- constructor(initializerContext: PluginInitializerContext) {}
+ constructor(initializerContext: PluginInitializerContext) {
+ this.config = initializerContext.config.get();
+ }
public setup(
core: CoreSetup,
@@ -130,6 +129,7 @@ export class ReportingPublicPlugin implements Plugin {
@@ -163,8 +163,9 @@ export class ReportingPublicPlugin implements Plugin {
const { http, notifications } = core;
const apiClient = new ReportingAPIClient(http);
const streamHandler = new StreamHandler(notifications, apiClient);
+ const { interval } = this.config.poll.jobsRefresh;
- Rx.timer(0, JOBS_REFRESH_INTERVAL)
+ Rx.timer(0, interval)
.pipe(
takeUntil(this.stop$), // stop the interval when stop method is called
map(() => getStored()), // read all pending job IDs from session storage
diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts
index f0a0a093aa8c0..a0d7618322c65 100644
--- a/x-pack/plugins/reporting/server/config/index.ts
+++ b/x-pack/plugins/reporting/server/config/index.ts
@@ -10,6 +10,7 @@ import { ConfigSchema, ConfigType } from './schema';
export { createConfig$ } from './create_config';
export const config: PluginConfigDescriptor = {
+ exposeToBrowser: { poll: true },
schema: ConfigSchema,
deprecations: ({ unused }) => [
unused('capture.browser.chromium.maxScreenshotDimension'),