From 380b50ee949da71e245b782abaf9085ca97204c0 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 18 Dec 2019 13:52:07 -0500 Subject: [PATCH] Clean up types and hook usage to comply with kibana eslint rules. --- .../__tests__/__snapshots__/ping_list.test.tsx.snap | 2 +- .../ping_list/__tests__/ping_list.test.tsx | 1 - .../components/functional/ping_list/ping_list.tsx | 13 +------------ .../legacy/plugins/uptime/public/pages/monitor.tsx | 8 ++++---- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap index a2e31a0f33d39f..692675baa89502 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap @@ -145,7 +145,7 @@ exports[`PingList component renders sorted list without errors 1`] = ` "render": [Function], }, Object { - "align": "center", + "align": "right", "field": "http.response.status_code", "name": "Response code", "render": [Function], diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx index 43adc4da85f32f..ba07d6c63b36cd 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx @@ -207,7 +207,6 @@ describe('PingList component', () => { onPageCountChange={jest.fn()} onSelectedLocationChange={(loc: EuiComboBoxOptionProps[]) => {}} onSelectedStatusChange={jest.fn()} - onUpdateApp={jest.fn()} pageSize={30} selectedOption="down" selectedLocation={AllLocationOption.value} diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx index 79814437dcd3b3..927ac71818bb6c 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx @@ -21,9 +21,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { get } from 'lodash'; import moment from 'moment'; -import React, { Fragment, useEffect, useState } from 'react'; -// @ts-ignore formatNumber -import { formatNumber } from '@elastic/eui/lib/services/format'; +import React, { Fragment, useState } from 'react'; import { Ping, PingResults } from '../../../../common/graphql/types'; import { convertMicrosecondsToMilliseconds as microsToMillis } from '../../../lib/helper'; import { UptimeGraphQLQueryProps, withUptimeGraphQL } from '../../higher_order'; @@ -40,7 +38,6 @@ interface PingListProps { onSelectedStatusChange: (status: string | undefined) => void; onSelectedLocationChange: (location: any) => void; onPageCountChange: (itemCount: number) => void; - onUpdateApp: () => void; pageSize: number; selectedOption: string; selectedLocation: string | undefined; @@ -76,17 +73,12 @@ export const PingListComponent = ({ onPageCountChange, onSelectedLocationChange, onSelectedStatusChange, - onUpdateApp, pageSize, selectedOption, selectedLocation, }: Props) => { const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState({}); - useEffect(() => { - onUpdateApp(); - }, [onUpdateApp, selectedOption]); - const statusOptions = [ { text: i18n.translate('xpack.uptime.pingList.statusOptions.allStatusOptionLabel', { @@ -181,9 +173,6 @@ export const PingListComponent = ({ render: (error: string) => error ?? '-', }, ]; - useEffect(() => { - onUpdateApp(); - }, [onUpdateApp, selectedOption]); let pings: Ping[] = []; if (data && data.allPings && data.allPings.pings) { pings = data.allPings.pings; diff --git a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx index 85458e973e6cc7..8c5649f680fcb5 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx @@ -103,10 +103,10 @@ export const MonitorPage = ({ - updateUrlParams({ selectedPingStatus: selectedStatus || '' }) - } - onUpdateApp={refreshApp} + onSelectedStatusChange={(selectedStatus: string | undefined) => { + updateUrlParams({ selectedPingStatus: selectedStatus || '' }); + refreshApp(); + }} pageSize={pingListPageCount} selectedOption={selectedPingStatus} selectedLocation={selectedLocation}