Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Lazy-load alert triggers #68806

Merged
merged 1 commit into from
Jun 10, 2020
Merged
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 @@ -116,3 +116,8 @@ export function ErrorRateAlertTrigger(props: Props) {
/>
);
}

// Default export is required for React.lazy loading
//
// eslint-disable-next-line import/no-default-export
export default ErrorRateAlertTrigger;
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,8 @@ export function TransactionDurationAlertTrigger(props: Props) {
/>
);
}

// Default export is required for React.lazy loading
//
// eslint-disable-next-line import/no-default-export
export default TransactionDurationAlertTrigger;
32 changes: 17 additions & 15 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,38 @@
*/

import { i18n } from '@kbn/i18n';
import { lazy } from 'react';
import { ConfigSchema } from '.';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the churn here; reordered imports with option-shift-o.

import {
AppMountParameters,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Plugin,
PluginInitializerContext,
} from '../../../../src/core/public';
import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public';

import {
PluginSetupContract as AlertingPluginPublicSetup,
PluginStartContract as AlertingPluginPublicStart,
} from '../../alerts/public';
import { FeaturesPluginSetup } from '../../features/public';
import {
DataPublicPluginSetup,
DataPublicPluginStart,
} from '../../../../src/plugins/data/public';
import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import {
PluginSetupContract as AlertingPluginPublicSetup,
PluginStartContract as AlertingPluginPublicStart,
} from '../../alerts/public';
import { FeaturesPluginSetup } from '../../features/public';
import { LicensingPluginSetup } from '../../licensing/public';
import {
TriggersAndActionsUIPublicPluginSetup,
TriggersAndActionsUIPublicPluginStart,
} from '../../triggers_actions_ui/public';
import { ConfigSchema } from '.';
import { createCallApmApi } from './services/rest/createCallApmApi';
import { featureCatalogueEntry } from './featureCatalogueEntry';
import { AlertType } from '../common/alert_types';
import { ErrorRateAlertTrigger } from './components/shared/ErrorRateAlertTrigger';
import { TransactionDurationAlertTrigger } from './components/shared/TransactionDurationAlertTrigger';
import { featureCatalogueEntry } from './featureCatalogueEntry';
import { createCallApmApi } from './services/rest/createCallApmApi';
import { createStaticIndexPattern } from './services/rest/index_pattern';
import { setHelpExtension } from './setHelpExtension';
import { toggleAppLinkInNav } from './toggleAppLinkInNav';
import { setReadonlyBadge } from './updateBadge';
import { createStaticIndexPattern } from './services/rest/index_pattern';

export type ApmPluginSetup = void;
export type ApmPluginStart = void;
Expand Down Expand Up @@ -112,7 +110,9 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
defaultMessage: 'Error rate',
}),
iconClass: 'bell',
alertParamsExpression: ErrorRateAlertTrigger,
alertParamsExpression: lazy(() =>
import('./components/shared/ErrorRateAlertTrigger')
),
validate: () => ({
errors: [],
}),
Expand All @@ -125,7 +125,9 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
defaultMessage: 'Transaction duration',
}),
iconClass: 'bell',
alertParamsExpression: TransactionDurationAlertTrigger,
alertParamsExpression: lazy(() =>
import('./components/shared/TransactionDurationAlertTrigger')
),
validate: () => ({
errors: [],
}),
Expand Down