From 4fce3da5db1be702e8c266d31c06e0c16bf0d6a1 Mon Sep 17 00:00:00 2001 From: Abdul Zahid Date: Mon, 27 Dec 2021 23:30:21 +0100 Subject: [PATCH] Stricter typing. https://github.com/elastic/uptime/issues/415 --- .../monitor_list/monitor_list.tsx | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx index 65ecc767aa1cb..75c94c2d07d1e 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx @@ -9,11 +9,12 @@ import { i18n } from '@kbn/i18n'; import { EuiBasicTable, EuiPanel, EuiSpacer, EuiLink } from '@elastic/eui'; import { SyntheticsMonitorSavedObject } from '../../../../common/types'; import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; -import { MonitorFields } from '../../../../common/runtime_types'; +import { MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types'; import { UptimeSettingsContext } from '../../../contexts'; import { Actions } from './actions'; import { MonitorLocations } from './monitor_locations'; import { MonitorTags } from './tags'; +import { MonitorEnabled } from './monitor_enabled'; import * as labels from '../../overview/monitor_list/translations'; interface Props { @@ -33,7 +34,8 @@ export const MonitorManagementList = ({ setPageSize, setPageIndex, }: Props) => { - const { monitors, total, perPage, page: pageIndex } = list as MonitorManagementListState['list']; + const { total, perPage, page: pageIndex } = list as MonitorManagementListState['list']; + const monitors = list.monitors as SyntheticsMonitorSavedObject[]; const { basePath } = useContext(UptimeSettingsContext); const pagination = useMemo( @@ -85,7 +87,7 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.monitorType', { defaultMessage: 'Monitor type', }), - render: ({ type }: Partial) => type, + render: ({ type }: SyntheticsMonitor) => type, }, { align: 'left' as const, @@ -93,7 +95,7 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.tags', { defaultMessage: 'Tags', }), - render: ({ tags }: Partial) => (tags ? : null), + render: ({ tags }: SyntheticsMonitor) => (tags ? : null), }, { align: 'left' as const, @@ -101,7 +103,7 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.locations', { defaultMessage: 'Locations', }), - render: ({ locations }: Partial) => + render: ({ locations }: SyntheticsMonitor) => locations ? : null, }, { @@ -110,8 +112,7 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.schedule', { defaultMessage: 'Schedule', }), - render: ({ schedule }: Partial) => - `@every ${schedule?.number}${schedule?.unit}`, + render: ({ schedule }: SyntheticsMonitor) => `@every ${schedule?.number}${schedule?.unit}`, }, { align: 'left' as const, @@ -119,7 +120,7 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.URL', { defaultMessage: 'URL', }), - render: (attributes: Partial) => attributes.urls || attributes.hosts, + render: (attributes: MonitorFields) => attributes.urls || attributes.hosts, truncateText: true, }, { @@ -128,12 +129,8 @@ export const MonitorManagementList = ({ name: i18n.translate('xpack.uptime.monitorManagement.monitorList.enabled', { defaultMessage: 'Enabled', }), - render: (_, savedObject: SyntheticsMonitorSavedObject) => ( - + render: (attributes: SyntheticsMonitor, record: SyntheticsMonitorSavedObject) => ( + ), }, {