Skip to content

Commit

Permalink
[Uptime] Use React.lazy for alert type registration (#66829)
Browse files Browse the repository at this point in the history
* Use React.lazy for alert type registration.

* Add typing to TLS alert component.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
justinkambic and elasticmachine authored May 19, 2020
1 parent a8b1a6b commit b15578c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ interface Props {
};
}

export const AlertMonitorStatus = ({
export const AlertMonitorStatus: React.FC<Props> = ({
autocomplete,
enabled,
numTimes,
setAlertParams,
timerange,
}: Props) => {
}) => {
const { filters, locations } = useSelector(selectMonitorStatusAlert);
return (
<AlertMonitorStatusComponent
Expand All @@ -41,3 +41,6 @@ export const AlertMonitorStatus = ({
/>
);
};

// eslint-disable-next-line import/no-default-export
export { AlertMonitorStatus as default };
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { AlertTlsComponent } from '../alert_tls';
import { setAlertFlyoutVisible } from '../../../../state/actions';
import { selectDynamicSettings } from '../../../../state/selectors';

export const AlertTls = () => {
export const AlertTls: React.FC<{}> = () => {
const dispatch = useDispatch();
const setFlyoutVisible = useCallback((value: boolean) => dispatch(setAlertFlyoutVisible(value)), [
dispatch,
Expand All @@ -24,3 +24,6 @@ export const AlertTls = () => {
/>
);
};

// eslint-disable-next-line import/no-default-export
export { AlertTls as default };
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { isRight } from 'fp-ts/lib/Either';
import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
import { AlertTypeInitializer } from '.';
import { StatusCheckExecutorParamsType } from '../../../common/runtime_types';
import { AlertMonitorStatus } from '../../components/overview/alerts/alerts_containers';
import { MonitorStatusTitle } from './monitor_status_title';
import { CLIENT_ALERT_TYPES } from '../../../common/constants';
import { MonitorStatusTranslations } from './translations';
Expand Down Expand Up @@ -57,6 +56,10 @@ export const validate = (alertParams: any) => {

const { defaultActionMessage } = MonitorStatusTranslations;

const AlertMonitorStatus = React.lazy(() =>
import('../../components/overview/alerts/alerts_containers/alert_monitor_status')
);

export const initMonitorStatusAlertType: AlertTypeInitializer = ({
autocomplete,
}): AlertTypeModel => ({
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/uptime/public/lib/alert_types/tls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
import { CLIENT_ALERT_TYPES } from '../../../common/constants';
import { TlsTranslations } from './translations';
import { AlertTypeInitializer } from '.';
import { AlertTls } from '../../components/overview/alerts/alerts_containers/alert_tls';

const { name, defaultActionMessage } = TlsTranslations;

export const initTlsAlertType: AlertTypeInitializer = (): AlertTypeModel => ({
id: CLIENT_ALERT_TYPES.TLS,
iconClass: 'uptimeApp',
alertParamsExpression: () => <AlertTls />,
alertParamsExpression: React.lazy(() =>
import('../../components/overview/alerts/alerts_containers/alert_tls')
),
name,
validate: () => ({ errors: {} }),
defaultActionMessage,
Expand Down

0 comments on commit b15578c

Please sign in to comment.