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] Synthetics UI #77960

Merged
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
6ab28e6
Checkpoint
andrewvc Jun 16, 2020
4cb1b54
Various
andrewvc Aug 26, 2020
f7e7a0c
Blah
andrewvc Sep 16, 2020
b5e12c2
Merge remote-tracking branch 'origin/master' into script-monitors
andrewvc Sep 16, 2020
1a067d7
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 17, 2020
e1ad0a4
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 18, 2020
3807a1a
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 18, 2020
ce80357
Display synthetics steps.
justinkambic Sep 18, 2020
f306d44
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 21, 2020
a0ae07e
Add loading state for snapshots. Add error and stack trace fields.
justinkambic Sep 21, 2020
3068243
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 21, 2020
ab26710
Lazy load screenshot images and cache screenshot GET endpoint.
justinkambic Sep 22, 2020
2674db2
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 22, 2020
d861e1a
Fix extra requests bug.
justinkambic Sep 22, 2020
a088ed1
Improve screenshot empty state.
justinkambic Sep 22, 2020
b20f6cc
Switch to use of code block for stack and error.
justinkambic Sep 22, 2020
d3f18d1
Add onmouseenter and onmouseleave for image input/popover.
justinkambic Sep 22, 2020
6893024
Add image overlay.
justinkambic Sep 22, 2020
7ee39d7
Support `skipped` state.
justinkambic Sep 23, 2020
e99421f
Add synthetics type for Ping.
justinkambic Sep 23, 2020
a7b21af
Fix type references in reducer, api request, components.
justinkambic Sep 23, 2020
bb7ff42
Add required mapping logic to journey request function.
justinkambic Sep 23, 2020
4558c34
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 23, 2020
67a5a85
Modularize new components.
justinkambic Sep 23, 2020
bd015f0
Delete obsolete code.
justinkambic Sep 23, 2020
f15d55b
Delete unused code.
justinkambic Sep 23, 2020
70147a1
Test expanded row changes.
justinkambic Sep 23, 2020
5c16a0d
Add a test for ping list expand check.
justinkambic Sep 23, 2020
fdb4e57
Various fixes
andrewvc Sep 24, 2020
94de530
Extract code accordion to new component
justinkambic Sep 24, 2020
fbeba47
Subsume synthetics type into Ping type.
justinkambic Sep 24, 2020
260a358
Add new journey viz for 0 steps case.
justinkambic Sep 24, 2020
502d5de
Use code block for console output.
justinkambic Sep 25, 2020
941d6a9
Expand step count cap.
justinkambic Sep 28, 2020
3961507
Improve formatting of console steps visualization.
justinkambic Sep 28, 2020
4bb4096
Improve empty prompt.
justinkambic Sep 28, 2020
c78c2e9
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 28, 2020
3d9c196
Extract empty prompt to dedicated file.
justinkambic Sep 28, 2020
8623470
Extract executed journey UI to dedicated file.
justinkambic Sep 28, 2020
1a55db1
Extract console step list components to dedicated files.
justinkambic Sep 28, 2020
73a9504
Update empty journey prompt to accept only check_group.
justinkambic Sep 28, 2020
18733f4
Clean up script expanded row component.
justinkambic Sep 28, 2020
3f8b8fa
Translate console output steps component.
justinkambic Sep 28, 2020
819b07e
Fix logic error.
justinkambic Sep 28, 2020
504dfbd
Clean up console step component.
justinkambic Sep 28, 2020
2cd74ad
Translate empty journey component.
justinkambic Sep 28, 2020
82af1a4
Translate status badge component.
justinkambic Sep 28, 2020
6ffecb1
Translate screenshot component.
justinkambic Sep 28, 2020
4408c81
Add experimental warning callout.
justinkambic Sep 28, 2020
71e9e9b
Re-introduce deleted code.
justinkambic Sep 28, 2020
cd1d813
Simplify console output step list.
justinkambic Sep 28, 2020
b098917
Support skipped step for executed journeys.
justinkambic Sep 28, 2020
965ceaa
Simplify executed journey component.
justinkambic Sep 28, 2020
955a6dd
Add translations for executed step.
justinkambic Sep 28, 2020
47567f5
Refresh outdated test snapshots.
justinkambic Sep 29, 2020
fc0ac9a
Simplify journey reducer signature.
justinkambic Sep 29, 2020
58579b0
Repair types.
justinkambic Sep 29, 2020
783e872
Fix broken i18n naming.
justinkambic Sep 29, 2020
ee92591
Add summary field to outdated ping test data.
justinkambic Sep 29, 2020
358bf81
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Sep 29, 2020
c7caf3f
Fix linting error.
justinkambic Sep 29, 2020
73e99bd
Remove @ts-ignore comment.
justinkambic Sep 29, 2020
0579ca2
Add tests for step screenshot display.
justinkambic Sep 29, 2020
20bcf4f
Add tests for status badge.
justinkambic Sep 29, 2020
35c85c8
Rename test file.
justinkambic Sep 29, 2020
5627814
Add tests for script expanded row.
justinkambic Sep 29, 2020
340764d
Add tests for executed step.
justinkambic Sep 29, 2020
0bb985e
Delete request and response fields from Ping's `synthetics` field.
justinkambic Sep 30, 2020
09f76ad
Fix screenshot querying effect, add flag to journey step state.
justinkambic Sep 30, 2020
ecc2679
Update screenshot api route to reply 404 when screenshot is null.
justinkambic Sep 30, 2020
7c86567
Simplify screenshot image fetching.
justinkambic Sep 30, 2020
81b08a9
Delete obsolete code.
justinkambic Sep 30, 2020
0be200f
Rename BrowserExpandedRow component.
justinkambic Oct 1, 2020
bbf7449
Merge branch 'master' of github.com:elastic/kibana into uptime_synth-…
justinkambic Oct 1, 2020
2b707e7
Remove all references to "suitejourney".
justinkambic Oct 1, 2020
f098da9
Add intentional var names.
justinkambic Oct 1, 2020
e929873
Rename Console components to use "event" terminology instead of "step".
justinkambic Oct 1, 2020
550b85f
Employ better copy.
justinkambic Oct 1, 2020
597bbd1
First names always bad names.
justinkambic Oct 1, 2020
29359b0
Rename CodeBlockAccordion component.
justinkambic Oct 1, 2020
6392497
Add blob_mime field to Ping type.
justinkambic Oct 1, 2020
17e1d39
Fix busted import path.
justinkambic Oct 1, 2020
ca637c6
Merge branch 'master' into uptime_synth-monitors-extend
justinkambic Oct 1, 2020
5c5287f
Update ping type for new position of errors field.
justinkambic Oct 1, 2020
418bdb3
Repair broken types.
justinkambic Oct 1, 2020
628e3a2
Fix summary querying
justinkambic Oct 1, 2020
f4473da
Type fixes.
justinkambic Oct 1, 2020
5f6f325
Switch state object from list to KVP.
justinkambic Oct 1, 2020
59b6f99
Checkpoint.
justinkambic Oct 2, 2020
486d1ec
Fix screenshot display test.
justinkambic Oct 2, 2020
2696683
Fix executed step test.
justinkambic Oct 2, 2020
e302a02
Refresh outdated test snapshots.
justinkambic Oct 2, 2020
33ef0ad
Repair broken types.
justinkambic Oct 2, 2020
01ace89
More typing fixes.
justinkambic Oct 2, 2020
512ea42
Merge branch 'master' into uptime_synth-monitors-extend
kibanamachine Oct 2, 2020
a6764f2
Fix console log and add a test.
justinkambic Oct 2, 2020
257f13c
Merge branch 'uptime_synth-monitors-extend' of github.com:justinkambi…
justinkambic Oct 2, 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
49 changes: 49 additions & 0 deletions x-pack/plugins/uptime/common/runtime_types/ping/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,48 @@ export const PingType = t.intersection([
down: t.number,
up: t.number,
}),
synthetics: t.partial({
index: t.number,
journey: t.type({
id: t.string,
name: t.string,
}),
error: t.partial({
message: t.string,
name: t.string,
stack: t.string,
}),
package_version: t.string,
step: t.type({
index: t.number,
name: t.string,
}),
type: t.string,
// ui-related field
screenshotLoading: t.boolean,
// ui-related field
screenshotExists: t.boolean,
blob: t.string,
andrewvc marked this conversation as resolved.
Show resolved Hide resolved
blob_mime: t.string,
payload: t.partial({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it makes sense to model payload this way. It's truly optional data, it should basically be any and consuming code would use type to determine which fields t check for. It's possible, for instance, for a field named myfield to have different values in different docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - I will extract a type for what we're using today (I think this is basically just step/end) and make payload a oneOf([...]) case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet resolved, don't forget 😈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created elastic/uptime#258

duration: t.number,
index: t.number,
is_navigation_request: t.boolean,
message: t.string,
method: t.string,
name: t.string,
params: t.partial({
homepage: t.string,
}),
source: t.string,
start: t.number,
status: t.string,
ts: t.number,
type: t.string,
url: t.string,
end: t.number,
}),
}),
tags: t.array(t.string),
tcp: t.partial({
rtt: t.partial({
Expand All @@ -202,6 +244,13 @@ export const PingType = t.intersection([
}),
]);

export const SyntheticsJourneyApiResponseType = t.type({
checkGroup: t.string,
steps: t.array(PingType),
});

export type SyntheticsJourneyApiResponse = t.TypeOf<typeof SyntheticsJourneyApiResponseType>;

export type Ping = t.TypeOf<typeof PingType>;

// Convenience function for tests etc that makes an empty ping
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/uptime/public/apps/uptime_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface UptimeAppColors {
range: string;
mean: string;
warning: string;
lightestShade: string;
}

export interface UptimeAppProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('PingListExpandedRow', () => {
docId: 'fdeio12',
timestamp: '19290310',
monitor: {
check_group: 'check_group_id',
duration: {
us: 12345,
},
Expand Down Expand Up @@ -87,4 +88,25 @@ describe('PingListExpandedRow', () => {

expect(docLinkComponent).toHaveLength(1);
});

it('renders a synthetics expanded row for synth monitor', () => {
ping.monitor.type = 'browser';
expect(shallowWithIntl(<PingListExpandedRowComponent ping={ping} />)).toMatchInlineSnapshot(`
<EuiFlexGroup
direction="column"
>
<EuiFlexItem>
<EuiCallOut
iconType="beaker"
title="Experimental feature"
/>
</EuiFlexItem>
<EuiFlexItem>
<BrowserExpandedRow
checkGroup="check_group_id"
/>
</EuiFlexItem>
</EuiFlexGroup>
`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { PingListComponent, toggleDetails } from '../ping_list';
import { PingListComponent, rowShouldExpand, toggleDetails } from '../ping_list';
import { Ping, PingsResponse } from '../../../../../common/runtime_types';
import { ExpandedRowMap } from '../../../overview/monitor_list/types';

Expand Down Expand Up @@ -182,6 +182,7 @@ describe('PingList component', () => {
to: 'now',
}}
getPings={jest.fn()}
pruneJourneysCallback={jest.fn()}
lastRefresh={123}
loading={false}
locations={[]}
Expand Down Expand Up @@ -273,5 +274,14 @@ describe('PingList component', () => {
/>
`);
});

describe('rowShouldExpand', () => {
// TODO: expand for all cases
it('returns true for browser monitors', () => {
const ping = pings[0];
ping.monitor.type = 'browser';
expect(rowShouldExpand(ping)).toBe(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore formatNumber
import { formatNumber } from '@elastic/eui/lib/services/format';
import {
Expand All @@ -19,6 +20,7 @@ import { i18n } from '@kbn/i18n';
import { Ping, HttpResponseBody } from '../../../../common/runtime_types';
import { DocLinkForBody } from './doc_link_body';
import { PingRedirects } from './ping_redirects';
import { BrowserExpandedRow } from '../synthetics/browser_expanded_row';

interface Props {
ping: Ping;
Expand Down Expand Up @@ -53,6 +55,24 @@ const BodyExcerpt = ({ content }: { content: string }) =>
export const PingListExpandedRowComponent = ({ ping }: Props) => {
const listItems = [];

if (ping.monitor.type === 'browser') {
return (
<EuiFlexGroup direction="column">
<EuiFlexItem>
<EuiCallOut
iconType="beaker"
title={i18n.translate('xpack.uptime.synthetics.experimentalCallout.title', {
defaultMessage: 'Experimental feature',
})}
/>
</EuiFlexItem>
<EuiFlexItem>
<BrowserExpandedRow checkGroup={ping.monitor.check_group} />
</EuiFlexItem>
</EuiFlexGroup>
);
}

// Show the error block
if (ping.error) {
listItems.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*/

export { PingListComponent } from './ping_list';
export { PingList } from './ping_list_container';
export { PingList } from './ping_list';
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,63 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import moment from 'moment';
import React, { useState, useEffect } from 'react';
import React, { useCallback, useContext, useState, useEffect } from 'react';
import styled from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
import { Ping, GetPingsParams, DateRange } from '../../../../common/runtime_types';
import { convertMicrosecondsToMilliseconds as microsToMillis } from '../../../lib/helper';
import { LocationName } from './location_name';
import { Pagination } from '../../overview/monitor_list';
import { PingListExpandedRowComponent } from './expanded_row';
import { PingListProps } from './ping_list_container';
// import { PingListProps } from './ping_list_container';
import { pruneJourneyState } from '../../../state/actions/journey';
import { selectPingList } from '../../../state/selectors';
import { UptimeRefreshContext, UptimeSettingsContext } from '../../../contexts';
import { getPings as getPingsAction } from '../../../state/actions';

export interface PingListProps {
monitorId: string;
}

export const PingList = (props: PingListProps) => {
const {
error,
loading,
pingList: { locations, pings, total },
} = useSelector(selectPingList);

const { lastRefresh } = useContext(UptimeRefreshContext);

const { dateRangeStart: drs, dateRangeEnd: dre } = useContext(UptimeSettingsContext);

const dispatch = useDispatch();
const getPingsCallback = useCallback(
(params: GetPingsParams) => dispatch(getPingsAction(params)),
[dispatch]
);
const pruneJourneysCallback = useCallback(
(checkGroups: string[]) => dispatch(pruneJourneyState(checkGroups)),
[dispatch]
);

return (
<PingListComponent
dateRange={{
from: drs,
to: dre,
}}
error={error}
getPings={getPingsCallback}
pruneJourneysCallback={pruneJourneysCallback}
lastRefresh={lastRefresh}
loading={loading}
locations={locations}
pings={pings}
total={total}
{...props}
/>
);
};

export const AllLocationOption = {
'data-test-subj': 'xpack.uptime.pingList.locationOptions.all',
Expand Down Expand Up @@ -63,6 +112,7 @@ interface Props extends PingListProps {
dateRange: DateRange;
error?: Error;
getPings: (props: GetPingsParams) => void;
pruneJourneysCallback: (checkGroups: string[]) => void;
lastRefresh: number;
loading: boolean;
locations: string[];
Expand Down Expand Up @@ -96,6 +146,13 @@ const statusOptions = [
},
];

export function rowShouldExpand(item: Ping) {
const errorPresent = !!item.error;
const httpBodyPresent = item.http?.response?.body?.bytes ?? 0 > 0;
const isBrowserMonitor = item.monitor.type === 'browser';
return errorPresent || httpBodyPresent || isBrowserMonitor;
}

export const PingListComponent = (props: Props) => {
const [selectedLocation, setSelectedLocation] = useState<string>('');
const [status, setStatus] = useState<string>('');
Expand All @@ -105,6 +162,7 @@ export const PingListComponent = (props: Props) => {
dateRange: { from, to },
error,
getPings,
pruneJourneysCallback,
lastRefresh,
loading,
locations,
Expand All @@ -129,6 +187,27 @@ export const PingListComponent = (props: Props) => {

const [expandedRows, setExpandedRows] = useState<Record<string, JSX.Element>>({});

const expandedIdsToRemove = JSON.stringify(
Object.keys(expandedRows).filter((e) => !pings.some(({ docId }) => docId === e))
);
useEffect(() => {
const parsed = JSON.parse(expandedIdsToRemove);
if (parsed.length) {
parsed.forEach((docId: string) => {
delete expandedRows[docId];
});
setExpandedRows(expandedRows);
}
}, [expandedIdsToRemove, expandedRows]);

const expandedCheckGroups = pings
.filter((p: Ping) => Object.keys(expandedRows).some((f) => p.docId === f))
.map(({ monitor: { check_group: cg } }) => cg);
const expandedCheckGroupsStr = JSON.stringify(expandedCheckGroups);
useEffect(() => {
pruneJourneysCallback(JSON.parse(expandedCheckGroupsStr));
}, [pruneJourneysCallback, expandedCheckGroupsStr]);

const locationOptions = !locations
? [AllLocationOption]
: [AllLocationOption].concat(
Expand Down Expand Up @@ -239,7 +318,7 @@ export const PingListComponent = (props: Props) => {
<EuiButtonIcon
data-test-subj="uptimePingListExpandBtn"
onClick={() => toggleDetails(item, expandedRows, setExpandedRows)}
disabled={!item.error && !(item.http?.response?.body?.bytes ?? 0 > 0)}
disabled={!rowShouldExpand(item)}
aria-label={
expandedRows[item.docId]
? i18n.translate('xpack.uptime.pingList.collapseRow', {
Expand Down

This file was deleted.

Loading