Skip to content

Commit d7da2c8

Browse files
[Uptime] Use React.lazy for alert type registration (#66829) (#67054)
* Use React.lazy for alert type registration. * Add typing to TLS alert component. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent f1a98c6 commit d7da2c8

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ interface Props {
2121
};
2222
}
2323

24-
export const AlertMonitorStatus = ({
24+
export const AlertMonitorStatus: React.FC<Props> = ({
2525
autocomplete,
2626
enabled,
2727
numTimes,
2828
setAlertParams,
2929
timerange,
30-
}: Props) => {
30+
}) => {
3131
const { filters, locations } = useSelector(selectMonitorStatusAlert);
3232
return (
3333
<AlertMonitorStatusComponent
@@ -41,3 +41,6 @@ export const AlertMonitorStatus = ({
4141
/>
4242
);
4343
};
44+
45+
// eslint-disable-next-line import/no-default-export
46+
export { AlertMonitorStatus as default };

x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_tls.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AlertTlsComponent } from '../alert_tls';
1010
import { setAlertFlyoutVisible } from '../../../../state/actions';
1111
import { selectDynamicSettings } from '../../../../state/selectors';
1212

13-
export const AlertTls = () => {
13+
export const AlertTls: React.FC<{}> = () => {
1414
const dispatch = useDispatch();
1515
const setFlyoutVisible = useCallback((value: boolean) => dispatch(setAlertFlyoutVisible(value)), [
1616
dispatch,
@@ -24,3 +24,6 @@ export const AlertTls = () => {
2424
/>
2525
);
2626
};
27+
28+
// eslint-disable-next-line import/no-default-export
29+
export { AlertTls as default };

x-pack/plugins/uptime/public/lib/alert_types/monitor_status.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { isRight } from 'fp-ts/lib/Either';
1111
import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
1212
import { AlertTypeInitializer } from '.';
1313
import { StatusCheckExecutorParamsType } from '../../../common/runtime_types';
14-
import { AlertMonitorStatus } from '../../components/overview/alerts/alerts_containers';
1514
import { MonitorStatusTitle } from './monitor_status_title';
1615
import { CLIENT_ALERT_TYPES } from '../../../common/constants';
1716
import { MonitorStatusTranslations } from './translations';
@@ -57,6 +56,10 @@ export const validate = (alertParams: any) => {
5756

5857
const { defaultActionMessage } = MonitorStatusTranslations;
5958

59+
const AlertMonitorStatus = React.lazy(() =>
60+
import('../../components/overview/alerts/alerts_containers/alert_monitor_status')
61+
);
62+
6063
export const initMonitorStatusAlertType: AlertTypeInitializer = ({
6164
autocomplete,
6265
}): AlertTypeModel => ({

x-pack/plugins/uptime/public/lib/alert_types/tls.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
99
import { CLIENT_ALERT_TYPES } from '../../../common/constants';
1010
import { TlsTranslations } from './translations';
1111
import { AlertTypeInitializer } from '.';
12-
import { AlertTls } from '../../components/overview/alerts/alerts_containers/alert_tls';
1312

1413
const { name, defaultActionMessage } = TlsTranslations;
1514

1615
export const initTlsAlertType: AlertTypeInitializer = (): AlertTypeModel => ({
1716
id: CLIENT_ALERT_TYPES.TLS,
1817
iconClass: 'uptimeApp',
19-
alertParamsExpression: () => <AlertTls />,
18+
alertParamsExpression: React.lazy(() =>
19+
import('../../components/overview/alerts/alerts_containers/alert_tls')
20+
),
2021
name,
2122
validate: () => ({ errors: {} }),
2223
defaultActionMessage,

0 commit comments

Comments
 (0)