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] Edit uptime alerts #68005

Merged
merged 53 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c094dd9
Extract store creation to plugin start, add redux providers to alert …
justinkambic May 8, 2020
6bb5519
Update unit test.
justinkambic May 13, 2020
e5a1eb3
Move alert registration to `setup` function.
justinkambic May 14, 2020
03ec299
Allow external editing of uptime client alert types.
justinkambic May 14, 2020
bf16f6a
Move alert initialization back to `start`.
justinkambic May 14, 2020
c2ad6d0
Clean up interfaces for alert types.
justinkambic May 15, 2020
f8e3c7e
Add code that will work for settings link even outside uptime app.
justinkambic May 15, 2020
4ced92e
Merge branch 'master' into uptime_edit-alerts
justinkambic May 27, 2020
47fe9cc
Create new atomic params type for status alerts.
justinkambic May 28, 2020
f5cf3b5
Update executor params typing to support both alert params types.
justinkambic May 29, 2020
e414180
Update snapshot for alert factory function.
justinkambic May 29, 2020
68dec30
Fix broken types and refresh snapshots.
justinkambic May 29, 2020
4c64d12
Merge branch 'master' into uptime_edit-alerts
justinkambic May 29, 2020
13594b7
Merge branch 'uptime_monitor-status-alert-params' into uptime_edit-al…
justinkambic May 29, 2020
ccea1f0
Allow edits of filters for monitor alerts.
justinkambic Jun 2, 2020
4caaeca
Support default parameter value for numTimes.
justinkambic Jun 2, 2020
93739f5
Support default parameter values for timerange.
justinkambic Jun 2, 2020
c93037e
Modify kuery bar to work for alert edits, fix some filter issues.
justinkambic Jun 2, 2020
87df991
Clean up tests and fix types.
justinkambic Jun 2, 2020
7ad31fc
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 3, 2020
af77c7a
Fix types and add a test.
justinkambic Jun 3, 2020
fdab0ac
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 3, 2020
496b537
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 3, 2020
9c85287
Merge branch 'master' into uptime_edit-alerts-ahead
elasticmachine Jun 3, 2020
3cbe39a
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 3, 2020
604c889
Add callout and validation handling for old alerts while editing.
justinkambic Jun 4, 2020
7f0f95f
Add a test for updated validation function.
justinkambic Jun 4, 2020
cc243ef
Merge branch 'uptime_edit-alerts-ahead' of github.com:justinkambic/ki…
justinkambic Jun 4, 2020
7546699
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 4, 2020
e59dc77
Define window for overview filters fetch action.
justinkambic Jun 4, 2020
86baf2c
Revert store initialization.
justinkambic Jun 4, 2020
dcce253
Make monitor counter function while editing alerts.
justinkambic Jun 4, 2020
4af3d19
Refresh snapshot.
justinkambic Jun 4, 2020
18846c9
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 4, 2020
a372640
Merge branch 'master' into uptime_edit-alerts-ahead
shahzad31 Jun 5, 2020
abc7e07
Move snapshot count in monitor status alert to callout.
justinkambic Jun 5, 2020
68c6e13
Add new state for selected filters.
justinkambic Jun 5, 2020
647d74f
Merge branch 'uptime_edit-alerts-ahead' of github.com:justinkambic/ki…
justinkambic Jun 5, 2020
9eb7de4
Add basic functional tests for uptime alert flyouts.
justinkambic Jun 5, 2020
63bf9ec
Fix broken types.
justinkambic Jun 5, 2020
b6c5e04
Update unit tests with mock provider.
justinkambic Jun 5, 2020
b7053b8
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 5, 2020
518410d
Remove unneeded params from hook.
justinkambic Jun 5, 2020
a5e0571
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 6, 2020
ba2b18e
Add more unit tests.
justinkambic Jun 6, 2020
290905e
Reducing functional test flakiness.
justinkambic Jun 6, 2020
1e9928c
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 6, 2020
589f0f8
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 8, 2020
b761ea4
Alert flyout controls update url only within Uptime app.
justinkambic Jun 8, 2020
ce725fb
Extract context interaction to container component, update snapshots.
justinkambic Jun 8, 2020
c1e6344
Merge branch 'master' into uptime_edit-alerts-ahead
justinkambic Jun 8, 2020
0eea5fd
Add missing parameter to test file.
justinkambic Jun 8, 2020
09bf4b3
Remove flaky functional test.
justinkambic Jun 8, 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
32 changes: 29 additions & 3 deletions x-pack/plugins/uptime/public/apps/plugin.ts
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.
*/

import {
CoreSetup,
CoreStart,
Expand All @@ -16,8 +17,16 @@ import { PLUGIN } from '../../common/constants';
import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public';
import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public';
import { EmbeddableStart } from '../../../../../src/plugins/embeddable/public';
import { TriggersAndActionsUIPublicPluginSetup } from '../../../triggers_actions_ui/public';
import { DataPublicPluginSetup } from '../../../../../src/plugins/data/public';
import {
TriggersAndActionsUIPublicPluginSetup,
TriggersAndActionsUIPublicPluginStart,
} from '../../../triggers_actions_ui/public';
import {
DataPublicPluginSetup,
DataPublicPluginStart,
} from '../../../../../src/plugins/data/public';
import { alertTypeInitializers } from '../lib/alert_types';
import { kibanaService } from '../state/kibana_service';

export interface ClientPluginsSetup {
data: DataPublicPluginSetup;
Expand All @@ -27,6 +36,8 @@ export interface ClientPluginsSetup {

export interface ClientPluginsStart {
embeddable: EmbeddableStart;
data: DataPublicPluginStart;
triggers_actions_ui: TriggersAndActionsUIPublicPluginStart;
}

export type ClientSetup = void;
Expand Down Expand Up @@ -66,6 +77,7 @@ export class UptimePlugin
);

const { element } = params;

const libs: UMFrontendLibs = {
framework: getKibanaFrameworkAdapter(coreStart, plugins, corePlugins),
};
Expand All @@ -74,7 +86,21 @@ export class UptimePlugin
});
}

public start(_start: CoreStart, _plugins: {}): void {}
public start(start: CoreStart, plugins: ClientPluginsStart): void {
kibanaService.core = start;
alertTypeInitializers.forEach((init) => {
const alertInitializer = init({
core: start,
plugins,
});
if (
plugins.triggers_actions_ui &&
!plugins.triggers_actions_ui.alertTypeRegistry.has(alertInitializer.id)
) {
plugins.triggers_actions_ui.alertTypeRegistry.register(alertInitializer);
}
});
}

public stop(): void {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { UptimeDatePicker } from '../uptime_date_picker';
import { renderWithRouter, shallowWithRouter } from '../../../lib';
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../lib';

describe('UptimeDatePicker component', () => {
it('validates props with shallow render', () => {
Expand All @@ -15,7 +15,11 @@ describe('UptimeDatePicker component', () => {
});

it('renders properly with mock data', () => {
const component = renderWithRouter(<UptimeDatePicker />);
const component = renderWithRouter(
<MountWithReduxProvider>
<UptimeDatePicker />
</MountWithReduxProvider>
);
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { MonitorBarSeries, MonitorBarSeriesProps } from '../monitor_bar_series';
import { renderWithRouter, shallowWithRouter } from '../../../../lib';
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../../lib';
import { HistogramPoint } from '../../../../../common/runtime_types';

describe('MonitorBarSeries component', () => {
Expand Down Expand Up @@ -197,7 +197,11 @@ describe('MonitorBarSeries component', () => {
});

it('renders if the data series is present', () => {
const component = renderWithRouter(<MonitorBarSeries histogramSeries={histogramSeries} />);
const component = renderWithRouter(
<MountWithReduxProvider>
<MonitorBarSeries histogramSeries={histogramSeries} />
</MountWithReduxProvider>
);
expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React from 'react';
import { PingHistogramComponent, PingHistogramComponentProps } from '../ping_histogram';
import { renderWithRouter, shallowWithRouter } from '../../../../lib';
import { renderWithRouter, shallowWithRouter, MountWithReduxProvider } from '../../../../lib';

describe('PingHistogram component', () => {
const props: PingHistogramComponentProps = {
Expand Down Expand Up @@ -49,7 +49,12 @@ describe('PingHistogram component', () => {
});

it('renders the component without errors', () => {
const component = renderWithRouter(<PingHistogramComponent {...props} />);
const component = renderWithRouter(
<MountWithReduxProvider>
<PingHistogramComponent {...props} />
</MountWithReduxProvider>
);

expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
import { AddFilterButton } from '../add_filter_btn';
import { EuiButtonEmpty, EuiContextMenuItem } from '@elastic/eui';

describe('AddFilterButton component', () => {
it('provides all filter choices', () => {
const component = shallowWithIntl(
<AddFilterButton newFilters={[]} onNewFilter={jest.fn()} alertFilters={{}} />
);
expect(component).toMatchInlineSnapshot(`
<EuiPopover
anchorPosition="downLeft"
button={
<EuiButtonEmpty
data-test-subj="uptimeCreateAlertAddFilter"
disabled={false}
iconType="plusInCircleFilled"
onClick={[Function]}
>
Add filter
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="singlePanel"
isOpen={false}
ownFocus={false}
panelPaddingSize="none"
>
<EuiContextMenuPanel
hasFocus={true}
items={
Array [
<EuiContextMenuItem
data-test-subj="uptimeAlertAddFilter.observer.geo.name"
onClick={[Function]}
>
Location
</EuiContextMenuItem>,
<EuiContextMenuItem
data-test-subj="uptimeAlertAddFilter.tags"
onClick={[Function]}
>
Tag
</EuiContextMenuItem>,
<EuiContextMenuItem
data-test-subj="uptimeAlertAddFilter.url.port"
onClick={[Function]}
>
Port
</EuiContextMenuItem>,
<EuiContextMenuItem
data-test-subj="uptimeAlertAddFilter.monitor.type"
onClick={[Function]}
>
Type
</EuiContextMenuItem>,
]
}
/>
</EuiPopover>
`);
});

it('excludes filters that already have selected values', () => {
const component = shallowWithIntl(
<AddFilterButton
newFilters={['observer.geo.name', 'tags']}
alertFilters={{ 'url.port': ['443', '80'] }}
onNewFilter={jest.fn()}
/>
);
expect(component).toMatchInlineSnapshot(`
<EuiPopover
anchorPosition="downLeft"
button={
<EuiButtonEmpty
data-test-subj="uptimeCreateAlertAddFilter"
disabled={false}
iconType="plusInCircleFilled"
onClick={[Function]}
>
Add filter
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="singlePanel"
isOpen={false}
ownFocus={false}
panelPaddingSize="none"
>
<EuiContextMenuPanel
hasFocus={true}
items={
Array [
<EuiContextMenuItem
data-test-subj="uptimeAlertAddFilter.monitor.type"
onClick={[Function]}
>
Type
</EuiContextMenuItem>,
]
}
/>
</EuiPopover>
`);
});

it('popover is disabled if no values are available', () => {
const component = shallowWithIntl(
<AddFilterButton
newFilters={[]}
alertFilters={{
'observer.geo.name': ['fairbanks'],
tags: ['foo'],
'url.port': ['80'],
'monitor.type': ['http'],
}}
onNewFilter={jest.fn()}
/>
);
expect(component).toMatchInlineSnapshot(`
<EuiPopover
anchorPosition="downLeft"
button={
<EuiButtonEmpty
data-test-subj="uptimeCreateAlertAddFilter"
disabled={true}
iconType="plusInCircleFilled"
onClick={[Function]}
>
Add filter
</EuiButtonEmpty>
}
closePopover={[Function]}
display="inlineBlock"
hasArrow={true}
id="singlePanel"
isOpen={false}
ownFocus={false}
panelPaddingSize="none"
>
<EuiContextMenuPanel
hasFocus={true}
items={Array []}
/>
</EuiPopover>
`);
});

it('filter select', () => {
const mockOnNewFilter = jest.fn();
const component = mountWithIntl(
<AddFilterButton newFilters={[]} alertFilters={{}} onNewFilter={mockOnNewFilter} />
);
component.find(EuiButtonEmpty).simulate('click', { target: { value: '0' } });
component
.find(EuiContextMenuItem)
.first()
.simulate('click', { target: { value: '0' } });
expect(mockOnNewFilter).toHaveBeenCalled();
expect(mockOnNewFilter.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"observer.geo.name",
],
]
`);
});
});
Loading