Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Remove pings graphql #59392

Merged
merged 60 commits into from
Apr 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
53a351e
WIP replacing GQL with redux/rest.
justinkambic Feb 24, 2020
e26f6fb
Finish implementing migration.
justinkambic Mar 5, 2020
0f9caf6
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 5, 2020
ecbe20a
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 10, 2020
48a9990
Introduce new connected component for ping list.
justinkambic Mar 11, 2020
0bae48a
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 11, 2020
76a0158
Replace GraphQL type with io-ts.
justinkambic Mar 13, 2020
b7fbc2b
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 16, 2020
aee6023
Update some broken tests.
justinkambic Mar 17, 2020
451c5a1
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 23, 2020
0370e86
Add test for new helper function.
justinkambic Mar 23, 2020
1a23bac
Write test snapshots.
justinkambic Mar 23, 2020
5e86c9f
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 24, 2020
999cc07
Migrate api tests from graphql to rest.
justinkambic Mar 24, 2020
69190d1
Update fixtures that rely on pings.
justinkambic Mar 25, 2020
4635af5
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 25, 2020
2cd661c
Move ping types to runtime_types folder with rest of io-ts files.
justinkambic Mar 25, 2020
db88cd1
Update Ping type location and imports, type checking.
justinkambic Mar 25, 2020
4937eef
Remove reliance on fixtures for ping functional API tests.
justinkambic Mar 25, 2020
d4b53c6
Fix broken unit tests.
justinkambic Mar 25, 2020
8df46a8
Fix broken types.
justinkambic Mar 25, 2020
d913fd1
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 25, 2020
6443af0
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 26, 2020
507dcf7
Remove local state storage from parent components.
justinkambic Mar 27, 2020
8083fb8
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 28, 2020
213e1c2
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 30, 2020
3ff868c
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Mar 31, 2020
c164fbd
Add functional test to cover Ping List functionality.
justinkambic Mar 31, 2020
69e9d49
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 1, 2020
46cc1e5
Fix monitor page functional test that was broken by merge conflicts.
justinkambic Apr 1, 2020
58b95f8
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 2, 2020
18bd154
Fix broken tests.
justinkambic Apr 2, 2020
ad0ffb6
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 2, 2020
b3b5b34
Fix broken API test.
justinkambic Apr 2, 2020
fae606d
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 3, 2020
f2126a7
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 6, 2020
f88bfaf
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 6, 2020
f407eb7
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 7, 2020
496aa53
Replace a test with a describe block that will pre-navigate all tests.
justinkambic Apr 8, 2020
4f23230
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 8, 2020
51e93cc
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 8, 2020
9f4423d
Delete unused reducer keys.
justinkambic Apr 8, 2020
bf8d347
Re-introduce loading to ping list reducer.
justinkambic Apr 8, 2020
9b7c6b0
Inroduce code that will cause PingList to re-fetch when refresh butto…
justinkambic Apr 8, 2020
6bb88e1
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 9, 2020
433bb74
Update expanded rows to support multiple concurrent expanded rows.
justinkambic Apr 9, 2020
0995904
Modify pingList reducer to have singular optional error field.
justinkambic Apr 9, 2020
adf02e3
Delete unnecessary helper code.
justinkambic Apr 10, 2020
b0ca803
Delete unused interface.
justinkambic Apr 10, 2020
1df28d6
Add runtime_type to parse getPings params, fix pagination index.
justinkambic Apr 10, 2020
55ac2aa
Add dedicated monitor type to runtime_types.
justinkambic Apr 10, 2020
a641bcf
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 10, 2020
7426fc7
Fix broken tests.
justinkambic Apr 10, 2020
59bc38f
Fix broken tests.
justinkambic Apr 10, 2020
1062e41
Rename '@timestamp' property to 'timestamp' on Ping type.
justinkambic Apr 10, 2020
70ecdfa
Fix broken type and key pings list table on document ID instead of ti…
justinkambic Apr 13, 2020
e7904dc
Fix broken unit tests.
justinkambic Apr 13, 2020
1418a6d
Merge branch 'master' into uptime_remove-pings-graphql
justinkambic Apr 13, 2020
c1aea4a
Fix broken tests and types.
justinkambic Apr 13, 2020
46f856e
Fix broken functional test.
justinkambic Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove local state storage from parent components.
justinkambic committed Mar 27, 2020
commit 507dcf78122a6aa94973af1453816c792586a6cd
Original file line number Diff line number Diff line change
@@ -14,15 +14,8 @@ import { PingListComponent } from '../../functional';

export interface PingListProps {
monitorId: string;
onSelectedStatusChange: (status: string | undefined) => void;
onSelectedLocationChange: (location: any) => void;
onPageCountChange: (itemCount: number) => void;
pageSize: number;
selectedOption: string;
selectedLocation: string | undefined;
size: number;
status: string;
}

export const PingList = (props: PingListProps) => {
const {
loading,
Original file line number Diff line number Diff line change
@@ -66,24 +66,34 @@ interface Props extends PingListProps {
pings: Ping[];
}

const DEFAULT_PAGE_SIZE = 10;

const statusOptions = [
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.allStatusOptionLabel', {
defaultMessage: 'All',
}),
value: '',
},
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.upStatusOptionLabel', {
defaultMessage: 'Up',
}),
value: 'up',
},
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.downStatusOptionLabel', {
defaultMessage: 'Down',
}),
value: 'down',
},
];

export const PingListComponent = (props: Props) => {
const {
dateRangeStart,
dateRangeEnd,
getPings,
loading,
locations,
monitorId,
onPageCountChange,
onSelectedLocationChange,
onSelectedStatusChange,
pageSize,
pings,
selectedLocation,
selectedOption,
size,
status,
} = props;
const [selectedLocation, setSelectedLocation] = useState<string>('');
const [status, setStatus] = useState<string>('');
const [size, setSize] = useState(DEFAULT_PAGE_SIZE);
const { dateRangeStart, dateRangeEnd, getPings, loading, locations, monitorId, pings } = props;

useEffect(() => {
getPings({
@@ -98,26 +108,6 @@ export const PingListComponent = (props: Props) => {

const [itemIdToExpandedRowMap, setItemIdToExpandedRowMap] = useState<ExpandedRowMap>({});

const statusOptions = [
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.allStatusOptionLabel', {
defaultMessage: 'All',
}),
value: '',
},
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.upStatusOptionLabel', {
defaultMessage: 'Up',
}),
value: 'up',
},
{
text: i18n.translate('xpack.uptime.pingList.statusOptions.downStatusOptionLabel', {
defaultMessage: 'Down',
}),
value: 'down',
},
];
const locationOptions = !locations
? [AllLocationOption]
: [AllLocationOption].concat(
@@ -243,13 +233,13 @@ export const PingListComponent = (props: Props) => {
const pagination: Pagination = {
initialPageSize: 20,
pageIndex: 0,
pageSize,
pageSize: size,
pageSizeOptions: [5, 10, 20, 50, 100],
/**
* we're not currently supporting pagination in this component
* so the first page is the only page
*/
totalItemCount: pageSize,
totalItemCount: size,
};

return (
@@ -273,15 +263,9 @@ export const PingListComponent = (props: Props) => {
aria-label={i18n.translate('xpack.uptime.pingList.statusLabel', {
defaultMessage: 'Status',
})}
value={selectedOption}
value={status}
onChange={selected => {
if (typeof selected.target.value === 'string') {
onSelectedStatusChange(
selected.target && selected.target.value !== ''
? selected.target.value
: undefined
);
}
setStatus(selected.target.value);
}}
/>
</EuiFormRow>
@@ -300,9 +284,7 @@ export const PingListComponent = (props: Props) => {
defaultMessage: 'Location',
})}
onChange={selected => {
onSelectedLocationChange(
selected.target && selected.target.value !== '' ? selected.target.value : null
);
setSelectedLocation(selected.target.value);
}}
/>
</EuiFormRow>
@@ -318,7 +300,7 @@ export const PingListComponent = (props: Props) => {
itemId="@timestamp"
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
pagination={pagination}
onChange={(criteria: any) => onPageCountChange(criteria.page!.size)}
onChange={(criteria: any) => setSize(criteria.page!.size)}
/>
</EuiPanel>
);
28 changes: 3 additions & 25 deletions x-pack/legacy/plugins/uptime/public/pages/monitor.tsx
Original file line number Diff line number Diff line change
@@ -5,11 +5,10 @@
*/

import { EuiSpacer } from '@elastic/eui';
import React, { useContext, useState, useEffect } from 'react';
import React, { useEffect } from 'react';
import { useParams } from 'react-router-dom';
import { connect, MapDispatchToPropsFunction, MapStateToPropsParam } from 'react-redux';
import { UptimeRefreshContext } from '../contexts';
import { useUptimeTelemetry, useUrlParams, UptimePage } from '../hooks';
import { useUptimeTelemetry, UptimePage } from '../hooks';
import { useTrackPageview } from '../../../../../plugins/observability/public';
import { MonitorStatusDetails } from '../components/connected';
import { Ping } from '../../common/runtime_types';
@@ -45,14 +44,6 @@ export const MonitorPageComponent: React.FC<Props> = ({
}
}, [dispatchGetMonitorStatus, monitorId]);

const [pingListPageCount, setPingListPageCount] = useState<number>(10);
const { refreshApp } = useContext(UptimeRefreshContext);
const [getUrlParams, updateUrlParams] = useUrlParams();
const { absoluteDateRangeStart, absoluteDateRangeEnd, ...params } = getUrlParams();
const { selectedPingStatus } = params;

const [selectedLocation, setSelectedLocation] = useState(undefined);

useUptimeTelemetry(UptimePage.Monitor);

useTrackPageview({ app: 'uptime', path: 'monitor' });
@@ -68,20 +59,7 @@ export const MonitorPageComponent: React.FC<Props> = ({
<EuiSpacer size="s" />
<MonitorCharts monitorId={monitorId} />
<EuiSpacer size="s" />
<PingList
onPageCountChange={setPingListPageCount}
onSelectedLocationChange={setSelectedLocation}
onSelectedStatusChange={(selectedStatus: string | undefined) => {
updateUrlParams({ selectedPingStatus: selectedStatus || '' });
refreshApp();
}}
pageSize={pingListPageCount}
selectedOption={selectedPingStatus}
selectedLocation={selectedLocation}
monitorId={monitorId}
size={pingListPageCount}
status={selectedPingStatus}
/>
<PingList monitorId={monitorId} />
</>
);
};