Skip to content

Commit

Permalink
Stricter typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
awahab07 committed Jan 5, 2022
1 parent e096cc0 commit 4fce3da
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(
Expand Down Expand Up @@ -85,23 +87,23 @@ export const MonitorManagementList = ({
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.monitorType', {
defaultMessage: 'Monitor type',
}),
render: ({ type }: Partial<MonitorFields>) => type,
render: ({ type }: SyntheticsMonitor) => type,
},
{
align: 'left' as const,
field: 'attributes',
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.tags', {
defaultMessage: 'Tags',
}),
render: ({ tags }: Partial<MonitorFields>) => (tags ? <MonitorTags tags={tags} /> : null),
render: ({ tags }: SyntheticsMonitor) => (tags ? <MonitorTags tags={tags} /> : null),
},
{
align: 'left' as const,
field: 'attributes',
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.locations', {
defaultMessage: 'Locations',
}),
render: ({ locations }: Partial<MonitorFields>) =>
render: ({ locations }: SyntheticsMonitor) =>
locations ? <MonitorLocations locations={locations} /> : null,
},
{
Expand All @@ -110,16 +112,15 @@ export const MonitorManagementList = ({
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.schedule', {
defaultMessage: 'Schedule',
}),
render: ({ schedule }: Partial<MonitorFields>) =>
`@every ${schedule?.number}${schedule?.unit}`,
render: ({ schedule }: SyntheticsMonitor) => `@every ${schedule?.number}${schedule?.unit}`,
},
{
align: 'left' as const,
field: 'attributes',
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.URL', {
defaultMessage: 'URL',
}),
render: (attributes: Partial<MonitorFields>) => attributes.urls || attributes.hosts,
render: (attributes: MonitorFields) => attributes.urls || attributes.hosts,
truncateText: true,
},
{
Expand All @@ -128,12 +129,8 @@ export const MonitorManagementList = ({
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.enabled', {
defaultMessage: 'Enabled',
}),
render: (_, savedObject: SyntheticsMonitorSavedObject) => (
<MonitorEnabled
id={savedObject.id}
monitor={savedObject.attributes}
setRefresh={setRefresh}
/>
render: (attributes: SyntheticsMonitor, record: SyntheticsMonitorSavedObject) => (
<MonitorEnabled id={record.id} monitor={attributes} setRefresh={setRefresh} />
),
},
{
Expand Down

0 comments on commit 4fce3da

Please sign in to comment.