From 13c2ed4e439520d32e070e2ab52b7b8362264056 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Wed, 18 Dec 2019 09:35:04 -0700 Subject: [PATCH 01/17] [Metrics UI] Customize "node info" section per Inventory Model (#53325) --- .../inventory_models/aws_ec2/layout.tsx | 204 +++--- .../inventory_models/aws_rds/layout.tsx | 321 ++++----- .../common/inventory_models/aws_s3/layout.tsx | 247 +++---- .../inventory_models/aws_sqs/layout.tsx | 247 +++---- .../inventory_models/container/layout.tsx | 402 +++++------ .../common/inventory_models/host/layout.tsx | 668 +++++++++--------- .../common/inventory_models/pod/layout.tsx | 267 +++---- .../metrics/components/layout_content.tsx | 12 + ...{node_details.tsx => metadata_details.tsx} | 66 +- .../metrics/components/node_details_page.tsx | 26 +- .../metrics/containers/metadata_context.ts | 9 + 11 files changed, 1281 insertions(+), 1188 deletions(-) create mode 100644 x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx rename x-pack/legacy/plugins/infra/public/pages/metrics/components/{node_details.tsx => metadata_details.tsx} (72%) create mode 100644 x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx index 01009b478951a..a3074b78f9f3b 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/aws_ec2/layout.tsx @@ -8,109 +8,123 @@ import { i18n } from '@kbn/i18n'; import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; import { Section } from '../../../public/pages/metrics/components/section'; import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; +import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- + +
- - - - - - - - -
+ + + + + + + + + +
+
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx index 5f1185666a35d..debb569fcd5bb 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/aws_rds/layout.tsx @@ -10,171 +10,174 @@ import { Section } from '../../../public/pages/metrics/components/section'; import { SubSection } from '../../../public/pages/metrics/components/sub_section'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- +
- - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + +
+
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx index 80089f15b04b2..955960f5baeda 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/aws_s3/layout.tsx @@ -10,134 +10,137 @@ import { Section } from '../../../public/pages/metrics/components/section'; import { SubSection } from '../../../public/pages/metrics/components/sub_section'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- +
- - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + +
+
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx index 40cb0a64d83cc..5d460c971ec3b 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/aws_sqs/layout.tsx @@ -10,134 +10,137 @@ import { Section } from '../../../public/pages/metrics/components/section'; import { SubSection } from '../../../public/pages/metrics/components/sub_section'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- +
- - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + +
+
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx index 00da70f1d96a5..e207687cf8643 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/container/layout.tsx @@ -11,212 +11,220 @@ import { SubSection } from '../../../public/pages/metrics/components/sub_section import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- - - - + +
- - - - - - - - - - - - - - -
+ + + + + + + + + + + + + + + + + + +
+
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx index fee79d8364c42..ca53193e64ca2 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/host/layout.tsx @@ -5,348 +5,366 @@ */ import React from 'react'; import { i18n } from '@kbn/i18n'; +import { withTheme } from '../../../../../common/eui_styled_components/eui_styled_components'; import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; import { Section } from '../../../public/pages/metrics/components/section'; import { SubSection } from '../../../public/pages/metrics/components/sub_section'; import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; -import { withTheme } from '../../../../../common/eui_styled_components'; import * as Aws from '../shared/layouts/aws'; import * as Ngnix from '../shared/layouts/nginx'; +import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- - - - + +
- - - + + + + + + + + + + + + + + +
+
- - - - - - - - -
-
- - - - - - - - - - - - - - - -
- - + + + + + + + + + + + + + + + +
+ + +
)); diff --git a/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx b/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx index 401e25c4defb8..f0c27ccff13b1 100644 --- a/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx +++ b/x-pack/legacy/plugins/infra/common/inventory_models/pod/layout.tsx @@ -12,143 +12,148 @@ import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauge import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; import { withTheme } from '../../../../../common/eui_styled_components'; import * as Nginx from '../shared/layouts/nginx'; +import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; export const Layout = withTheme(({ metrics, theme }: LayoutPropsWithTheme) => ( -
- - - - + +
- - - - - - - - -
- + + + + + + + + + + + + +
+ +
)); diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx b/x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx new file mode 100644 index 0000000000000..a2bd9cdc13179 --- /dev/null +++ b/x-pack/legacy/plugins/infra/public/pages/metrics/components/layout_content.tsx @@ -0,0 +1,12 @@ +/* + * 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 { EuiPageContent } from '@elastic/eui'; +import { euiStyled } from '../../../../../../common/eui_styled_components'; + +export const LayoutContent = euiStyled(EuiPageContent)` + position: relative; +`; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details.tsx b/x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx similarity index 72% rename from x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details.tsx rename to x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx index 5329ea992c493..c43f2d10d7163 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details.tsx +++ b/x-pack/legacy/plugins/infra/public/pages/metrics/components/metadata_details.tsx @@ -4,16 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useState, useCallback, useMemo } from 'react'; +import React, { useContext, useState, useCallback, useMemo } from 'react'; import { EuiButtonIcon, EuiFlexGrid, EuiFlexItem, EuiTitle, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; import { InfraMetadata } from '../../../../common/http_api'; import euiStyled from '../../../../../../common/eui_styled_components'; - -interface Props { - metadata?: InfraMetadata | null; -} +import { MetadataContext } from '../containers/metadata_context'; interface FieldDef { field: string; @@ -101,7 +98,13 @@ const getValueForField = (metadata: InfraMetadata, { field, isBoolean }: FieldDe return value; }; -export const NodeDetails = ({ metadata }: Props) => { +interface Props { + fields?: string[]; +} + +const NUMBER_OF_COLUMNS = 4; + +export const MetadataDetails = (props: Props) => { const [isOpen, setControlState] = useState(false); const toggleIsOpen = useCallback( @@ -109,38 +112,58 @@ export const NodeDetails = ({ metadata }: Props) => { [isOpen] ); - const fields = useMemo(() => (isOpen ? FIELDS : FIELDS.slice(0, 4)), [isOpen]); + const filteredFields = useMemo(() => { + if (props.fields && props.fields.length) { + return props.fields + .map(field => { + const fieldDef = FIELDS.find(f => f.field === field); + if (fieldDef) { + return fieldDef; + } + }) + .filter(f => f) as FieldDef[]; + } else { + return FIELDS; + } + }, [props.fields]); + const fields = useMemo( + () => (isOpen ? filteredFields : filteredFields.slice(0, NUMBER_OF_COLUMNS)), + [filteredFields, isOpen] + ); + const metadata = useContext(MetadataContext); if (!metadata) { return null; } return ( - - - - - + + {filteredFields.length > NUMBER_OF_COLUMNS ? ( + + + + ) : null} + {fields.map(field => ( -

{getLabelForField(field)}

+
{getLabelForField(field)}
{getValueForField(metadata, field)}
))}
-
+ ); }; -const NodeDetailsContainer = euiStyled.div` +const MetadataContainer = euiStyled.div` border-top: ${props => props.theme.eui.euiBorderWidthThin} solid ${props => props.theme.eui.euiBorderColor}; border-bottom: ${props => props.theme.eui.euiBorderWidthThin} solid ${props => @@ -153,4 +176,5 @@ display: flex; const Controls = euiStyled.div` flex-grow: 0; margin-right: ${props => props.theme.eui.paddingSizes.m}; +min-width: 0px; `; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx b/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx index 933831c6ec87d..2f4eb57cd5161 100644 --- a/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx +++ b/x-pack/legacy/plugins/infra/public/pages/metrics/components/node_details_page.tsx @@ -12,7 +12,6 @@ import { EuiPageHeaderSection, EuiHideFor, EuiTitle, - EuiPageContent, } from '@elastic/eui'; import { InventoryMetric } from '../../../../common/inventory_models/types'; import { useNodeDetails } from '../../../containers/node_details/use_node_details'; @@ -20,13 +19,13 @@ import { InfraNodeType, InfraTimerangeInput } from '../../../graphql/types'; import { MetricsSideNav } from './side_nav'; import { AutoSizer } from '../../../components/auto_sizer'; import { MetricsTimeControls } from './time_controls'; -import { NodeDetails } from './node_details'; import { SideNavContext, NavItem } from '../lib/side_nav_context'; import { PageBody } from './page_body'; import euiStyled from '../../../../../../common/eui_styled_components'; import { MetricsTimeInput } from '../containers/with_metrics_time'; import { InfraMetadata } from '../../../../common/http_api/metadata_api'; import { PageError } from './page_error'; +import { MetadataContext } from '../../../pages/metrics/containers/metadata_context'; interface Props { name: string; @@ -100,14 +99,13 @@ export const NodeDetailsPage = (props: Props) => { - - - + + 0 && props.isAutoReloading ? false : loading} refetch={refetch} @@ -117,8 +115,8 @@ export const NodeDetailsPage = (props: Props) => { isLiveStreaming={props.isAutoReloading} stopLiveStreaming={() => props.setAutoReload(false)} /> - - + + ); @@ -128,10 +126,6 @@ export const NodeDetailsPage = (props: Props) => { ); }; -const EuiPageContentWithRelative = euiStyled(EuiPageContent)` - position: relative; -`; - const MetricsDetailsPageColumn = euiStyled.div` flex: 1 0 0%; display: flex; diff --git a/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts b/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts new file mode 100644 index 0000000000000..4ecf7fa15548c --- /dev/null +++ b/x-pack/legacy/plugins/infra/public/pages/metrics/containers/metadata_context.ts @@ -0,0 +1,9 @@ +/* + * 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 { InfraMetadata } from '../../../../common/http_api'; +export const MetadataContext = React.createContext(null); From b34852a5bc3a9e013c9cd23cc3a345947b524fde Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Wed, 18 Dec 2019 10:21:10 -0700 Subject: [PATCH 02/17] Telemetry usage collection welcome screen (#53084) * Changes text dynamically based on the value of optIn in kibana.yml --- .../__snapshots__/home.test.js.snap | 2 +- .../__snapshots__/welcome.test.tsx.snap | 263 +++++++++++++++++- .../kibana/public/home/components/home.js | 11 +- .../public/home/components/home.test.js | 4 + .../kibana/public/home/components/home_app.js | 4 +- .../public/home/components/welcome.test.tsx | 24 +- .../kibana/public/home/components/welcome.tsx | 83 +++--- 7 files changed, 346 insertions(+), 45 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap index 0bf8c808ae920..c1131cbe559f6 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap @@ -1072,8 +1072,8 @@ exports[`home welcome should show the normal home page if welcome screen is disa exports[`home welcome should show the welcome screen if enabled, and there are no index patterns defined 1`] = ` `; diff --git a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap index 2007a3bb773cf..e36a6e0a5a9fb 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap +++ b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap @@ -62,10 +62,46 @@ exports[`should render a Welcome screen with no telemetry disclaimer 1`] = ` + + + + + + + + + + @@ -138,6 +174,231 @@ exports[`should render a Welcome screen with the telemetry disclaimer 1`] = ` + + + + + + + + + + + + + + + + + +`; + +exports[`should render a Welcome screen with the telemetry disclaimer when optIn is false 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +

+ +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+
+
+`; + +exports[`should render a Welcome screen with the telemetry disclaimer when optIn is true 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +

+ +

+
+ +
+
+
+ + + diff --git a/src/legacy/core_plugins/kibana/public/home/components/home.js b/src/legacy/core_plugins/kibana/public/home/components/home.js index c87ceb9777c74..d552dd070c86d 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home.js @@ -51,10 +51,7 @@ export class Home extends Component { getServices().getInjected('disableWelcomeScreen') || props.localStorage.getItem(KEY_ENABLE_WELCOME) === 'false' ); - const showTelemetryDisclaimer = getServices().getInjected( - 'telemetryNotifyUserAboutOptInDefault' - ); - + const currentOptInStatus = this.props.getOptInStatus(); this.state = { // If welcome is enabled, we wait for loading to complete // before rendering. This prevents an annoying flickering @@ -63,7 +60,7 @@ export class Home extends Component { isLoading: isWelcomeEnabled, isNewKibanaInstance: false, isWelcomeEnabled, - showTelemetryDisclaimer, + currentOptInStatus, }; } @@ -222,14 +219,13 @@ export class Home extends Component { renderLoading() { return ''; } - renderWelcome() { return ( ); } @@ -269,4 +265,5 @@ Home.propTypes = { urlBasePath: PropTypes.string.isRequired, mlEnabled: PropTypes.bool.isRequired, onOptInSeen: PropTypes.func.isRequired, + getOptInStatus: PropTypes.func.isRequired, }; diff --git a/src/legacy/core_plugins/kibana/public/home/components/home.test.js b/src/legacy/core_plugins/kibana/public/home/components/home.test.js index 780e2af695381..1f46cf2875fee 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home.test.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home.test.js @@ -63,6 +63,10 @@ describe('home', () => { setItem: sinon.mock(), }, urlBasePath: 'goober', + onOptInSeen() { + return false; + }, + getOptInStatus: jest.fn(), }; }); diff --git a/src/legacy/core_plugins/kibana/public/home/components/home_app.js b/src/legacy/core_plugins/kibana/public/home/components/home_app.js index 5a12eb0a66cf1..29f24f5b841a3 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home_app.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home_app.js @@ -29,14 +29,13 @@ import { getTutorial } from '../load_tutorials'; import { replaceTemplateStrings } from './tutorial/replace_template_strings'; import { getServices } from '../kibana_services'; import { npSetup } from 'ui/new_platform'; - export function HomeApp({ directories }) { const { getInjected, savedObjectsClient, getBasePath, addBasePath, - telemetryOptInProvider: { setOptInNoticeSeen }, + telemetryOptInProvider: { setOptInNoticeSeen, getOptIn }, } = getServices(); const { cloud } = npSetup.plugins; const isCloudEnabled = !!(cloud && cloud.isCloudEnabled); @@ -87,6 +86,7 @@ export function HomeApp({ directories }) { localStorage={localStorage} urlBasePath={getBasePath()} onOptInSeen={setOptInNoticeSeen} + getOptInStatus={getOptIn} /> diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx index 21dcfd9ef15de..42c6e6ff6056a 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx @@ -35,7 +35,25 @@ jest.mock('../kibana_services', () => ({ test('should render a Welcome screen with the telemetry disclaimer', () => { const component = shallow( // @ts-ignore - {}} showTelemetryDisclaimer={true} onOptInSeen={() => {}} /> + {}} onOptInSeen={() => {}} /> + ); + + expect(component).toMatchSnapshot(); +}); + +test('should render a Welcome screen with the telemetry disclaimer when optIn is true', () => { + const component = shallow( + // @ts-ignore + {}} onOptInSeen={() => {}} currentOptInStatus={true} /> + ); + + expect(component).toMatchSnapshot(); +}); + +test('should render a Welcome screen with the telemetry disclaimer when optIn is false', () => { + const component = shallow( + // @ts-ignore + {}} onOptInSeen={() => {}} currentOptInStatus={false} /> ); expect(component).toMatchSnapshot(); @@ -45,7 +63,7 @@ test('should render a Welcome screen with no telemetry disclaimer', () => { // @ts-ignore const component = shallow( // @ts-ignore - {}} showTelemetryDisclaimer={false} onOptInSeen={() => {}} /> + {}} onOptInSeen={() => {}} /> ); expect(component).toMatchSnapshot(); @@ -56,7 +74,7 @@ test('fires opt-in seen when mounted', () => { shallow( // @ts-ignore - {}} showTelemetryDisclaimer={true} onOptInSeen={seen} /> + {}} onOptInSeen={seen} /> ); expect(seen).toHaveBeenCalled(); diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx index c8de0bf7bb936..435bf98ca7840 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx @@ -23,7 +23,7 @@ * in Elasticsearch. */ -import React from 'react'; +import React, { Fragment } from 'react'; import { EuiLink, EuiTextColor, @@ -39,12 +39,11 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { getServices } from '../kibana_services'; import { SampleDataCard } from './sample_data'; - interface Props { urlBasePath: string; onSkip: () => void; onOptInSeen: () => any; - showTelemetryDisclaimer: boolean; + currentOptInStatus: boolean; } /** @@ -84,9 +83,42 @@ export class Welcome extends React.Component { document.removeEventListener('keydown', this.hideOnEsc); } - render() { - const { urlBasePath, showTelemetryDisclaimer } = this.props; + private renderTelemetryEnabledOrDisabledText = () => { + if (this.props.currentOptInStatus) { + return ( + + + + + + + ); + } else { + return ( + + + + + + + ); + } + }; + render() { + const { urlBasePath } = this.props; return (
@@ -121,34 +153,23 @@ export class Welcome extends React.Component { onDecline={this.onSampleDataDecline} /> - {showTelemetryDisclaimer && ( - - - - - + + + - - - - - )} + + {this.renderTelemetryEnabledOrDisabledText()} + From 44348aa9983659219c6f143c09e22d4cfcbdafb4 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Wed, 18 Dec 2019 17:31:31 +0000 Subject: [PATCH 03/17] Aligns Alerting's interval with TaskManager's generic schedule field (#52873) Follow up from the #52727 in Task Manager, we want Alerting and Task Manager to align on their schedule api (in the near future, Alerting will actually use Task manager's schedule system to remove this duplication). --- x-pack/legacy/plugins/alerting/README.md | 12 +- x-pack/legacy/plugins/alerting/mappings.json | 8 +- .../alerting/server/alerts_client.test.ts | 114 +++++++++++------- .../plugins/alerting/server/alerts_client.ts | 25 ++-- .../server/lib/get_next_run_at.test.ts | 4 +- .../alerting/server/lib/get_next_run_at.ts | 5 +- .../server/lib/task_runner_factory.test.ts | 2 +- .../server/lib/task_runner_factory.ts | 11 +- .../alerting/server/routes/create.test.ts | 10 +- .../plugins/alerting/server/routes/create.ts | 9 +- .../alerting/server/routes/get.test.ts | 2 +- .../alerting/server/routes/update.test.ts | 8 +- .../plugins/alerting/server/routes/update.ts | 9 +- .../legacy/plugins/alerting/server/types.ts | 8 +- .../routes/__mocks__/request_responses.ts | 2 +- .../detection_engine/routes/rules/utils.ts | 2 +- .../detection_engine/rules/create_rules.ts | 2 +- .../detection_engine/rules/update_rules.ts | 13 +- .../common/lib/alert_utils.ts | 2 +- .../common/lib/get_test_alert_data.ts | 2 +- .../tests/alerting/alerts.ts | 12 +- .../tests/alerting/create.ts | 32 +++-- .../tests/alerting/find.ts | 4 +- .../security_and_spaces/tests/alerting/get.ts | 2 +- .../tests/alerting/update.ts | 26 ++-- .../spaces_only/tests/alerting/alerts.ts | 2 +- .../spaces_only/tests/alerting/create.ts | 2 +- .../spaces_only/tests/alerting/find.ts | 2 +- .../spaces_only/tests/alerting/get.ts | 2 +- .../spaces_only/tests/alerting/update.ts | 4 +- 30 files changed, 212 insertions(+), 126 deletions(-) diff --git a/x-pack/legacy/plugins/alerting/README.md b/x-pack/legacy/plugins/alerting/README.md index 85dbd75e14174..0b4024be39548 100644 --- a/x-pack/legacy/plugins/alerting/README.md +++ b/x-pack/legacy/plugins/alerting/README.md @@ -200,7 +200,7 @@ Payload: |name|A name to reference and search in the future.|string| |tags|A list of keywords to reference and search in the future.|string[]| |alertTypeId|The id value of the alert type you want to call when the alert is scheduled to execute.|string| -|interval|The interval in seconds, minutes, hours or days the alert should execute. Example: `10s`, `5m`, `1h`, `1d`.|string| +|schedule|The schedule specifying when this alert should run, using one of the available schedule formats specified under _Schedule Formats_ below|object| |params|The parameters to pass in to the alert type executor `params` value. This will also validate against the alert type params validator if defined.|object| |actions|Array of the following:
- `group` (string): We support grouping actions in the scenario of escalations or different types of alert instances. If you don't need this, feel free to use `default` as a value.
- `id` (string): The id of the action saved object to execute.
- `params` (object): The map to the `params` the action type will receive. In order to help apply context to strings, we handle them as mustache templates and pass in a default set of context. (see templating actions).|array| @@ -242,7 +242,7 @@ Payload: |Property|Description|Type| |---|---|---| -|interval|The interval in seconds, minutes, hours or days the alert should execute. Example: `10s`, `5m`, `1h`, `1d`.|string| +|schedule|The schedule specifying when this alert should be run, using one of the available schedule formats specified under _Schedule Formats_ below|object| |name|A name to reference and search in the future.|string| |tags|A list of keywords to reference and search in the future.|string[]| |params|The parameters to pass in to the alert type executor `params` value. This will also validate against the alert type params validator if defined.|object| @@ -304,6 +304,14 @@ Params: |---|---|---| |id|The id of the alert you're trying to update the API key for. System will use user in request context to generate an API key for.|string| +##### Schedule Formats +A schedule is structured such that the key specifies the format you wish to use and its value specifies the schedule. + +We currently support the _Interval format_ which specifies the interval in seconds, minutes, hours or days at which the alert should execute. +Example: `{ interval: "10s" }`, `{ interval: "5m" }`, `{ interval: "1h" }`, `{ interval: "1d" }`. + +There are plans to support multiple other schedule formats in the near fuiture. + ## Alert instance factory **alertInstanceFactory(id)** diff --git a/x-pack/legacy/plugins/alerting/mappings.json b/x-pack/legacy/plugins/alerting/mappings.json index 7a7446602351d..9536187116031 100644 --- a/x-pack/legacy/plugins/alerting/mappings.json +++ b/x-pack/legacy/plugins/alerting/mappings.json @@ -13,8 +13,12 @@ "alertTypeId": { "type": "keyword" }, - "interval": { - "type": "keyword" + "schedule": { + "properties": { + "interval": { + "type": "keyword" + } + } }, "actions": { "type": "nested", diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts index 37eb6a9b21d44..b07dad68da72d 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts @@ -47,7 +47,7 @@ function getMockData(overwrites: Record = {}) { name: 'abc', tags: ['foo'], alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, throttle: null, params: { bar: true, @@ -92,7 +92,7 @@ describe('create()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -157,10 +157,12 @@ describe('create()', () => { ], "alertTypeId": "123", "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", } `); @@ -184,13 +186,15 @@ describe('create()', () => { "apiKeyOwner": undefined, "createdBy": "elastic", "enabled": true, - "interval": "10s", "muteAll": false, "mutedInstanceIds": Array [], "name": "abc", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "tags": Array [ "foo", ], @@ -298,7 +302,7 @@ describe('create()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -399,10 +403,12 @@ describe('create()', () => { ], "alertTypeId": "123", "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", } `); @@ -445,7 +451,7 @@ describe('create()', () => { attributes: { enabled: false, alertTypeId: '123', - interval: 10000, + schedule: { interval: 10000 }, params: { bar: true, }, @@ -484,10 +490,12 @@ describe('create()', () => { "alertTypeId": "123", "enabled": false, "id": "1", - "interval": 10000, "params": Object { "bar": true, }, + "schedule": Object { + "interval": 10000, + }, } `); expect(savedObjectsClient.create).toHaveBeenCalledTimes(1); @@ -585,7 +593,7 @@ describe('create()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -648,7 +656,7 @@ describe('create()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -722,7 +730,7 @@ describe('create()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -794,7 +802,7 @@ describe('create()', () => { createdBy: 'elastic', updatedBy: 'elastic', enabled: true, - interval: '10s', + schedule: { interval: '10s' }, throttle: null, muteAll: false, mutedInstanceIds: [], @@ -820,7 +828,7 @@ describe('enable()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: false, }, @@ -846,7 +854,7 @@ describe('enable()', () => { 'alert', '1', { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -879,7 +887,7 @@ describe('enable()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, }, @@ -897,7 +905,7 @@ describe('enable()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: false, }, @@ -927,7 +935,7 @@ describe('enable()', () => { 'alert', '1', { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -962,7 +970,7 @@ describe('disable()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -976,7 +984,7 @@ describe('disable()', () => { 'alert', '1', { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', apiKey: null, apiKeyOwner: null, @@ -997,7 +1005,7 @@ describe('disable()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: false, scheduledTaskId: 'task-123', @@ -1060,7 +1068,7 @@ describe('muteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1088,7 +1096,7 @@ describe('muteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1107,7 +1115,7 @@ describe('muteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1129,7 +1137,7 @@ describe('unmuteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1157,7 +1165,7 @@ describe('unmuteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1176,7 +1184,7 @@ describe('unmuteInstance()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, scheduledTaskId: 'task-123', @@ -1199,7 +1207,7 @@ describe('get()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1235,10 +1243,12 @@ describe('get()', () => { ], "alertTypeId": "123", "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, } `); expect(savedObjectsClient.get).toHaveBeenCalledTimes(1); @@ -1257,7 +1267,7 @@ describe('get()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1292,7 +1302,7 @@ describe('find()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1332,10 +1342,12 @@ describe('find()', () => { ], "alertTypeId": "123", "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, }, ], "page": 1, @@ -1362,7 +1374,7 @@ describe('delete()', () => { type: 'alert', attributes: { alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1443,7 +1455,7 @@ describe('update()', () => { type: 'alert', attributes: { enabled: true, - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1470,7 +1482,7 @@ describe('update()', () => { const result = await alertsClient.update({ id: '1', data: { - interval: '10s', + schedule: { interval: '10s' }, name: 'abc', tags: ['foo'], params: { @@ -1501,10 +1513,12 @@ describe('update()', () => { ], "enabled": true, "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", } `); @@ -1528,11 +1542,13 @@ describe('update()', () => { "apiKey": null, "apiKeyOwner": null, "enabled": true, - "interval": "10s", "name": "abc", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", "tags": Array [ "foo", @@ -1598,7 +1614,7 @@ describe('update()', () => { type: 'alert', attributes: { enabled: true, - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1651,7 +1667,7 @@ describe('update()', () => { const result = await alertsClient.update({ id: '1', data: { - interval: '10s', + schedule: { interval: '10s' }, name: 'abc', tags: ['foo'], params: { @@ -1712,10 +1728,12 @@ describe('update()', () => { ], "enabled": true, "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", } `); @@ -1771,7 +1789,7 @@ describe('update()', () => { type: 'alert', attributes: { enabled: true, - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, @@ -1799,7 +1817,7 @@ describe('update()', () => { const result = await alertsClient.update({ id: '1', data: { - interval: '10s', + schedule: { interval: '10s' }, name: 'abc', tags: ['foo'], params: { @@ -1831,10 +1849,12 @@ describe('update()', () => { "apiKey": "MTIzOmFiYw==", "enabled": true, "id": "1", - "interval": "10s", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", } `); @@ -1858,11 +1878,13 @@ describe('update()', () => { "apiKey": "MTIzOmFiYw==", "apiKeyOwner": "elastic", "enabled": true, - "interval": "10s", "name": "abc", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "scheduledTaskId": "task-123", "tags": Array [ "foo", @@ -1909,7 +1931,7 @@ describe('update()', () => { alertsClient.update({ id: '1', data: { - interval: '10s', + schedule: { interval: '10s' }, name: 'abc', tags: ['foo'], params: { @@ -1939,7 +1961,7 @@ describe('updateApiKey()', () => { id: '1', type: 'alert', attributes: { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, }, @@ -1956,7 +1978,7 @@ describe('updateApiKey()', () => { 'alert', '1', { - interval: '10s', + schedule: { interval: '10s' }, alertTypeId: '2', enabled: true, apiKey: Buffer.from('123:abc').toString('base64'), diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client.ts b/x-pack/legacy/plugins/alerting/server/alerts_client.ts index 27fda9871e685..578daa445b6ff 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client.ts @@ -8,7 +8,14 @@ import Boom from 'boom'; import { omit } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Logger, SavedObjectsClientContract, SavedObjectReference } from 'src/core/server'; -import { Alert, RawAlert, AlertTypeRegistry, AlertAction, AlertType } from './types'; +import { + Alert, + RawAlert, + AlertTypeRegistry, + AlertAction, + AlertType, + IntervalSchedule, +} from './types'; import { TaskManagerStartContract } from './shim'; import { validateAlertTypeParams } from './lib'; import { CreateAPIKeyResult as SecurityPluginCreateAPIKeyResult } from '../../../../plugins/security/server'; @@ -82,7 +89,7 @@ interface UpdateOptions { data: { name: string; tags: string[]; - interval: string; + schedule: IntervalSchedule; actions: NormalizedAlertAction[]; params: Record; }; @@ -145,11 +152,7 @@ export class AlertsClient { if (data.enabled) { let scheduledTask; try { - scheduledTask = await this.scheduleAlert( - createdAlert.id, - rawAlert.alertTypeId, - rawAlert.interval - ); + scheduledTask = await this.scheduleAlert(createdAlert.id, rawAlert.alertTypeId); } catch (e) { // Cleanup data, something went wrong scheduling the task try { @@ -259,11 +262,7 @@ export class AlertsClient { const { attributes, version } = await this.savedObjectsClient.get('alert', id); if (attributes.enabled === false) { const apiKey = await this.createAPIKey(); - const scheduledTask = await this.scheduleAlert( - id, - attributes.alertTypeId, - attributes.interval - ); + const scheduledTask = await this.scheduleAlert(id, attributes.alertTypeId); const username = await this.getUserName(); await this.savedObjectsClient.update( 'alert', @@ -364,7 +363,7 @@ export class AlertsClient { } } - private async scheduleAlert(id: string, alertTypeId: string, interval: string) { + private async scheduleAlert(id: string, alertTypeId: string) { return await this.taskManager.schedule({ taskType: `alerting:${alertTypeId}`, params: { diff --git a/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.test.ts b/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.test.ts index 852e412689b35..1c4d8a42d2830 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.test.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.test.ts @@ -15,12 +15,12 @@ const mockedNow = new Date('2019-06-03T18:55:25.982Z'); test('Adds interface to given date when result is > Date.now()', () => { const currentRunAt = new Date('2019-06-03T18:55:23.982Z'); - const result = getNextRunAt(currentRunAt, '10s'); + const result = getNextRunAt(currentRunAt, { interval: '10s' }); expect(result).toEqual(new Date('2019-06-03T18:55:33.982Z')); }); test('Uses Date.now() when the result would of been a date in the past', () => { const currentRunAt = new Date('2019-06-03T18:55:13.982Z'); - const result = getNextRunAt(currentRunAt, '10s'); + const result = getNextRunAt(currentRunAt, { interval: '10s' }); expect(result).toEqual(mockedNow); }); diff --git a/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.ts b/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.ts index 901b614b4d68c..f9867b5372908 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/get_next_run_at.ts @@ -5,9 +5,10 @@ */ import { parseDuration } from './parse_duration'; +import { IntervalSchedule } from '../types'; -export function getNextRunAt(currentRunAt: Date, interval: string) { - let nextRunAt = currentRunAt.getTime() + parseDuration(interval); +export function getNextRunAt(currentRunAt: Date, schedule: IntervalSchedule) { + let nextRunAt = currentRunAt.getTime() + parseDuration(schedule.interval); if (nextRunAt < Date.now()) { // To prevent returning dates in the past, we'll return now instead nextRunAt = Date.now(); diff --git a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts index c21c419977bbe..7966f98c749c8 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.test.ts @@ -74,7 +74,7 @@ const mockedAlertTypeSavedObject = { attributes: { enabled: true, alertTypeId: '123', - interval: '10s', + schedule: { interval: '10s' }, mutedInstanceIds: [], params: { bar: true, diff --git a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts index 051b15fc8dd8f..fe0979538d04e 100644 --- a/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts +++ b/x-pack/legacy/plugins/alerting/server/lib/task_runner_factory.ts @@ -20,6 +20,7 @@ import { GetServicesFunction, RawAlert, SpaceIdToNamespaceFunction, + IntervalSchedule, } from '../types'; export interface TaskRunnerContext { @@ -94,7 +95,7 @@ export class TaskRunnerFactory { const services = getServices(fakeRequest); // Ensure API key is still valid and user has access const { - attributes: { params, actions, interval, throttle, muteAll, mutedInstanceIds }, + attributes: { params, actions, schedule, throttle, muteAll, mutedInstanceIds }, references, } = await services.savedObjectsClient.get('alert', alertId); @@ -167,7 +168,13 @@ export class TaskRunnerFactory { }) ); - const nextRunAt = getNextRunAt(new Date(taskInstance.startedAt!), interval); + const nextRunAt = getNextRunAt( + new Date(taskInstance.startedAt!), + // we do not currently have a good way of returning the type + // from SavedObjectsClient, and as we currenrtly require a schedule + // and we only support `interval`, we can cast this safely + schedule as IntervalSchedule + ); return { state: { diff --git a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts index 634a797880812..a804aff55ad42 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts @@ -13,7 +13,7 @@ server.route(createAlertRoute); const mockedAlert = { alertTypeId: '1', name: 'abc', - interval: '10s', + schedule: { interval: '10s' }, tags: ['foo'], params: { bar: true, @@ -65,11 +65,13 @@ test('creates an alert with proper parameters', async () => { ], "alertTypeId": "1", "id": "123", - "interval": "10s", "name": "abc", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "tags": Array [ "foo", ], @@ -91,11 +93,13 @@ test('creates an alert with proper parameters', async () => { ], "alertTypeId": "1", "enabled": true, - "interval": "10s", "name": "abc", "params": Object { "bar": true, }, + "schedule": Object { + "interval": "10s", + }, "tags": Array [ "foo", ], diff --git a/x-pack/legacy/plugins/alerting/server/routes/create.ts b/x-pack/legacy/plugins/alerting/server/routes/create.ts index cb5277ae19100..417072f978a92 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/create.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/create.ts @@ -7,6 +7,7 @@ import Hapi from 'hapi'; import Joi from 'joi'; import { getDurationSchema } from '../lib'; +import { IntervalSchedule } from '../types'; interface ScheduleRequest extends Hapi.Request { payload: { @@ -14,7 +15,7 @@ interface ScheduleRequest extends Hapi.Request { name: string; tags: string[]; alertTypeId: string; - interval: string; + schedule: IntervalSchedule; actions: Array<{ group: string; id: string; @@ -43,7 +44,11 @@ export const createAlertRoute = { .default([]), alertTypeId: Joi.string().required(), throttle: getDurationSchema().default(null), - interval: getDurationSchema().required(), + schedule: Joi.object() + .keys({ + interval: getDurationSchema().required(), + }) + .required(), params: Joi.object().required(), actions: Joi.array() .items( diff --git a/x-pack/legacy/plugins/alerting/server/routes/get.test.ts b/x-pack/legacy/plugins/alerting/server/routes/get.test.ts index 4d44ee9dfe6bd..b97762d10c960 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/get.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/get.test.ts @@ -13,7 +13,7 @@ server.route(getAlertRoute); const mockedAlert = { id: '1', alertTypeId: '1', - interval: '10s', + schedule: { interval: '10s' }, params: { bar: true, }, diff --git a/x-pack/legacy/plugins/alerting/server/routes/update.test.ts b/x-pack/legacy/plugins/alerting/server/routes/update.test.ts index 334fb2120319d..8ce9d94140e6d 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/update.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/update.test.ts @@ -16,7 +16,7 @@ const mockedResponse = { id: '1', alertTypeId: '1', tags: ['foo'], - interval: '12s', + schedule: { interval: '12s' }, params: { otherField: false, }, @@ -40,7 +40,7 @@ test('calls the update function with proper parameters', async () => { throttle: null, name: 'abc', tags: ['bar'], - interval: '12s', + schedule: { interval: '12s' }, params: { otherField: false, }, @@ -75,11 +75,13 @@ test('calls the update function with proper parameters', async () => { }, }, ], - "interval": "12s", "name": "abc", "params": Object { "otherField": false, }, + "schedule": Object { + "interval": "12s", + }, "tags": Array [ "bar", ], diff --git a/x-pack/legacy/plugins/alerting/server/routes/update.ts b/x-pack/legacy/plugins/alerting/server/routes/update.ts index 6e8f8557fb24a..bc55d48465602 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/update.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/update.ts @@ -7,6 +7,7 @@ import Joi from 'joi'; import Hapi from 'hapi'; import { getDurationSchema } from '../lib'; +import { IntervalSchedule } from '../types'; interface UpdateRequest extends Hapi.Request { params: { @@ -16,7 +17,7 @@ interface UpdateRequest extends Hapi.Request { alertTypeId: string; name: string; tags: string[]; - interval: string; + schedule: IntervalSchedule; actions: Array<{ group: string; id: string; @@ -45,7 +46,11 @@ export const updateAlertRoute = { tags: Joi.array() .items(Joi.string()) .required(), - interval: getDurationSchema().required(), + schedule: Joi.object() + .keys({ + interval: getDurationSchema().required(), + }) + .required(), params: Joi.object().required(), actions: Joi.array() .items( diff --git a/x-pack/legacy/plugins/alerting/server/types.ts b/x-pack/legacy/plugins/alerting/server/types.ts index 1bec2632d8082..e06e0c45e20b4 100644 --- a/x-pack/legacy/plugins/alerting/server/types.ts +++ b/x-pack/legacy/plugins/alerting/server/types.ts @@ -60,12 +60,16 @@ export interface RawAlertAction extends SavedObjectAttributes { params: AlertActionParams; } +export interface IntervalSchedule extends SavedObjectAttributes { + interval: string; +} + export interface Alert { enabled: boolean; name: string; tags: string[]; alertTypeId: string; - interval: string; + schedule: IntervalSchedule; actions: AlertAction[]; params: Record; scheduledTaskId?: string; @@ -83,7 +87,7 @@ export interface RawAlert extends SavedObjectAttributes { name: string; tags: string[]; alertTypeId: string; - interval: string; + schedule: SavedObjectAttributes; actions: RawAlertAction[]; params: SavedObjectAttributes; scheduledTaskId?: string; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts index ae205a814daae..3c5182b5178b3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -271,7 +271,7 @@ export const getResult = (): RuleAlertType => ({ references: ['http://www.example.com', 'https://ww.example.com'], version: 1, }, - interval: '5m', + schedule: { interval: '5m' }, enabled: true, actions: [], throttle: null, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts index 88261d872b0ea..dad22c74398d2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts @@ -45,7 +45,7 @@ export const transformAlertToRule = (alert: RuleAlertType): Partial { + it('should handle create alert request appropriately when interval schedule is wrong syntax', async () => { const response = await supertestWithoutAuth .post(`${getUrlPrefix(space.id)}/api/alert`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData(getTestAlertData({ interval: '10x' }))); + .send(getTestAlertData(getTestAlertData({ schedule: { interval: '10x' } }))); switch (scenario.id) { case 'no_kibana_privileges at space1': @@ -275,10 +275,15 @@ export default function createAlertTests({ getService }: FtrProviderContext) { statusCode: 400, error: 'Bad Request', message: - 'child "interval" fails because ["interval" with value "10x" fails to match the seconds pattern, "interval" with value "10x" fails to match the minutes pattern, "interval" with value "10x" fails to match the hours pattern, "interval" with value "10x" fails to match the days pattern]', + 'child "schedule" fails because [child "interval" fails because ["interval" with value "10x" fails to match the seconds pattern, "interval" with value "10x" fails to match the minutes pattern, "interval" with value "10x" fails to match the hours pattern, "interval" with value "10x" fails to match the days pattern]]', validation: { source: 'payload', - keys: ['interval', 'interval', 'interval', 'interval'], + keys: [ + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + ], }, }); break; @@ -287,12 +292,12 @@ export default function createAlertTests({ getService }: FtrProviderContext) { } }); - it('should handle create alert request appropriately when interval is 0', async () => { + it('should handle create alert request appropriately when interval schedule is 0', async () => { const response = await supertestWithoutAuth .post(`${getUrlPrefix(space.id)}/api/alert`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData(getTestAlertData({ interval: '0s' }))); + .send(getTestAlertData(getTestAlertData({ schedule: { interval: '0s' } }))); switch (scenario.id) { case 'no_kibana_privileges at space1': @@ -312,10 +317,15 @@ export default function createAlertTests({ getService }: FtrProviderContext) { statusCode: 400, error: 'Bad Request', message: - 'child "interval" fails because ["interval" with value "0s" fails to match the seconds pattern, "interval" with value "0s" fails to match the minutes pattern, "interval" with value "0s" fails to match the hours pattern, "interval" with value "0s" fails to match the days pattern]', + 'child "schedule" fails because [child "interval" fails because ["interval" with value "0s" fails to match the seconds pattern, "interval" with value "0s" fails to match the minutes pattern, "interval" with value "0s" fails to match the hours pattern, "interval" with value "0s" fails to match the days pattern]]', validation: { source: 'payload', - keys: ['interval', 'interval', 'interval', 'interval'], + keys: [ + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + ], }, }); break; diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts index 359058f2ac23a..4da6c059c5a5e 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/find.ts @@ -59,7 +59,7 @@ export default function createFindTests({ getService }: FtrProviderContext) { name: 'abc', tags: ['foo'], alertTypeId: 'test.noop', - interval: '1m', + schedule: { interval: '1m' }, enabled: true, actions: [], params: {}, @@ -138,7 +138,7 @@ export default function createFindTests({ getService }: FtrProviderContext) { name: 'abc', tags: ['foo'], alertTypeId: 'test.noop', - interval: '1m', + schedule: { interval: '1m' }, enabled: false, actions: [ { diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts index 1a8109f6b6b3c..9c1f7fea93292 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get.ts @@ -53,7 +53,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { name: 'abc', tags: ['foo'], alertTypeId: 'test.noop', - interval: '1m', + schedule: { interval: '1m' }, enabled: true, actions: [], params: {}, diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts index 1b1bcef9ad23f..0e2ec0f7bc534 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts @@ -36,7 +36,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { params: { foo: true, }, - interval: '12s', + schedule: { interval: '12s' }, actions: [], throttle: '2m', }; @@ -96,7 +96,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { params: { foo: true, }, - interval: '12s', + schedule: { interval: '12s' }, throttle: '1m', actions: [], }); @@ -145,7 +145,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { params: { foo: true, }, - interval: '12s', + schedule: { interval: '12s' }, actions: [], }); @@ -203,10 +203,10 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { statusCode: 400, error: 'Bad Request', message: - 'child "throttle" fails because ["throttle" is required]. child "name" fails because ["name" is required]. child "tags" fails because ["tags" is required]. child "interval" fails because ["interval" is required]. child "params" fails because ["params" is required]. child "actions" fails because ["actions" is required]', + 'child "throttle" fails because ["throttle" is required]. child "name" fails because ["name" is required]. child "tags" fails because ["tags" is required]. child "schedule" fails because ["schedule" is required]. child "params" fails because ["params" is required]. child "actions" fails because ["actions" is required]', validation: { source: 'payload', - keys: ['throttle', 'name', 'tags', 'interval', 'params', 'actions'], + keys: ['throttle', 'name', 'tags', 'schedule', 'params', 'actions'], }, }); break; @@ -237,7 +237,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { .send({ name: 'bcd', tags: ['bar'], - interval: '1m', + schedule: { interval: '1m' }, throttle: '1m', params: {}, actions: [], @@ -269,12 +269,12 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { } }); - it('should handle update alert request appropriately when interval is wrong syntax', async () => { + it('should handle update alert request appropriately when interval schedule is wrong syntax', async () => { const response = await supertestWithoutAuth .put(`${getUrlPrefix(space.id)}/api/alert/1`) .set('kbn-xsrf', 'foo') .auth(user.username, user.password) - .send(getTestAlertData({ interval: '10x', enabled: undefined })); + .send(getTestAlertData({ schedule: { interval: '10x' }, enabled: undefined })); switch (scenario.id) { case 'no_kibana_privileges at space1': @@ -294,10 +294,16 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { statusCode: 400, error: 'Bad Request', message: - 'child "interval" fails because ["interval" with value "10x" fails to match the seconds pattern, "interval" with value "10x" fails to match the minutes pattern, "interval" with value "10x" fails to match the hours pattern, "interval" with value "10x" fails to match the days pattern]. "alertTypeId" is not allowed', + 'child "schedule" fails because [child "interval" fails because ["interval" with value "10x" fails to match the seconds pattern, "interval" with value "10x" fails to match the minutes pattern, "interval" with value "10x" fails to match the hours pattern, "interval" with value "10x" fails to match the days pattern]]. "alertTypeId" is not allowed', validation: { source: 'payload', - keys: ['interval', 'interval', 'interval', 'interval', 'alertTypeId'], + keys: [ + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + 'schedule.interval', + 'alertTypeId', + ], }, }); break; diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts.ts index 5fafd8b0bfb61..03e973194b4e2 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/alerts.ts @@ -123,7 +123,7 @@ export default function alertTests({ getService }: FtrProviderContext) { .set('kbn-xsrf', 'foo') .send( getTestAlertData({ - interval: '1m', + schedule: { interval: '1m' }, alertTypeId: 'test.always-firing', params: { index: ES_TEST_INDEX_NAME, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts index 929905a958abb..0e9011729eb3e 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/create.ts @@ -71,7 +71,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) { alertTypeId: 'test.noop', params: {}, createdBy: null, - interval: '1m', + schedule: { interval: '1m' }, scheduledTaskId: response.body.scheduledTaskId, updatedBy: null, throttle: '1m', diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts index 0d12af6db79b2..3fdd9168eb5cb 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/find.ts @@ -42,7 +42,7 @@ export default function createFindTests({ getService }: FtrProviderContext) { name: 'abc', tags: ['foo'], alertTypeId: 'test.noop', - interval: '1m', + schedule: { interval: '1m' }, enabled: true, actions: [], params: {}, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts index 9e4797bcbf7ad..a49d3478d336d 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get.ts @@ -36,7 +36,7 @@ export default function createGetTests({ getService }: FtrProviderContext) { name: 'abc', tags: ['foo'], alertTypeId: 'test.noop', - interval: '1m', + schedule: { interval: '1m' }, enabled: true, actions: [], params: {}, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts index a6eccf88d9e26..46822781c0cd3 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/update.ts @@ -31,7 +31,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { params: { foo: true, }, - interval: '12s', + schedule: { interval: '12s' }, actions: [], throttle: '1m', }; @@ -71,7 +71,7 @@ export default function createUpdateTests({ getService }: FtrProviderContext) { params: { foo: true, }, - interval: '12s', + schedule: { interval: '12s' }, actions: [], throttle: '1m', }) From 942fdeeb2d9a32622d8d3929e484dde5c6e16074 Mon Sep 17 00:00:00 2001 From: Alex Holmansky Date: Wed, 18 Dec 2019 12:40:58 -0500 Subject: [PATCH 04/17] Fix a typo in PR project assigner workflow configuration (#53511) * Workflow configurations to assign issues and PRs with Team:AppArch label to kibana-app-arch project * Fix a typo in the label name * Remove merge conflicts --- .github/workflows/pr-project-assigner.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-project-assigner.yml b/.github/workflows/pr-project-assigner.yml index aea8a9cad6b1f..8eab1b99957cd 100644 --- a/.github/workflows/pr-project-assigner.yml +++ b/.github/workflows/pr-project-assigner.yml @@ -11,5 +11,5 @@ jobs: uses: elastic/github-actions/project-assigner@v1.0.0 id: project_assigner with: - issue-mappings: '[{"label": "Team:AppAch", "projectName": "kibana-app-arch", "columnId": 6173897}]' - ghToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + issue-mappings: '[{"label": "Team:AppArch", "projectName": "kibana-app-arch", "columnId": 6173897}]' + ghToken: ${{ secrets.GITHUB_TOKEN }} From 068f3ffa2c0e6e45ddbaa1228f057887cc024f9a Mon Sep 17 00:00:00 2001 From: Chandler Prall Date: Wed, 18 Dec 2019 11:15:14 -0700 Subject: [PATCH 05/17] Upgrade to EUI@17.1.2 [table typescript types] (#52688) * more types * table types changes * siem table conversions * Updated rest of x-pack for EUI table typees * updated x-pack changes against master * Update to published eui 17.1.0 * kibana snapshots * x-pack snapshots * src snapshots * autofixes * autofixes, round 2 --- package.json | 2 +- .../flyout_service.test.tsx.snap | 4 +- .../__snapshots__/modal_service.test.tsx.snap | 2 +- .../dashboard_empty_screen.test.tsx.snap | 14 +- .../__snapshots__/no_results.test.js.snap | 4 + .../saved_objects_installer.test.js.snap | 5 +- .../__jest__/__snapshots__/table.test.js.snap | 3 +- .../__jest__/__snapshots__/table.test.js.snap | 1 - .../__jest__/__snapshots__/table.test.js.snap | 1 - .../index_pattern_table.tsx | 4 +- .../__snapshots__/objects_table.test.js.snap | 1 - .../__snapshots__/flyout.test.js.snap | 4 - .../__snapshots__/relationships.test.js.snap | 8 - .../__snapshots__/new_vis_modal.test.tsx.snap | 108 +++++++++++--- .../visualization_noresults.test.js.snap | 1 + .../visualization_requesterror.test.js.snap | 1 + .../shard_failure_table.test.tsx.snap | 1 - .../fetch/components/shard_failure_table.tsx | 14 +- .../__snapshots__/field_name.test.tsx.snap | 6 + .../exit_full_screen_button.test.js.snap | 2 + .../vislib_vis_legend.test.tsx.snap | 4 +- .../inspector_panel.test.tsx.snap | 6 +- .../inspector/public/views/data/types.ts | 4 +- .../exit_full_screen_button.test.tsx.snap | 4 + .../table_list_view/table_list_view.tsx | 6 +- .../plugins/kbn_tp_run_pipeline/package.json | 2 +- .../kbn_tp_custom_visualizations/package.json | 2 +- .../kbn_tp_embeddable_explorer/package.json | 2 +- .../kbn_tp_sample_panel_action/package.json | 2 +- typings/@elastic/eui/index.d.ts | 13 -- .../__test__/__snapshots__/List.test.tsx.snap | 96 ++++++++---- .../ServiceOverview.test.tsx.snap | 4 +- .../components/shared/ManagedTable/index.tsx | 14 +- .../__snapshots__/Stackframe.test.tsx.snap | 4 + .../TransactionActionMenu.test.tsx.snap | 4 +- .../public/components/table/table.tsx | 4 +- .../components/table/table_type_configs.tsx | 2 +- .../public/pages/beat/details.tsx | 3 +- .../dropdown_filter.examples.storyshot | 10 ++ .../extended_template.examples.storyshot | 6 +- .../date_format.examples.storyshot | 9 +- .../number_format.examples.storyshot | 9 +- .../__snapshots__/asset.examples.storyshot | 24 ++- .../color_dot.examples.storyshot | 8 + .../color_manager.examples.storyshot | 24 ++- .../color_palette.examples.storyshot | 6 + .../color_picker.examples.storyshot | 28 +++- .../custom_element_modal.examples.storyshot | 30 +++- .../element_card.examples.storyshot | 6 + .../element_controls.examples.storyshot | 6 +- .../element_grid.examples.storyshot | 24 ++- .../file_upload.examples.storyshot | 3 +- .../font_picker.examples.storyshot | 6 +- .../item_grid.examples.storyshot | 12 ++ .../keyboard_shortcuts_doc.examples.storyshot | 3 +- .../sidebar_header.examples.storyshot | 12 +- .../__snapshots__/tag.examples.storyshot | 4 + .../__snapshots__/tag_list.examples.storyshot | 6 + .../pdf_panel.examples.storyshot | 3 +- .../workpad_export.examples.storyshot | 6 +- .../extended_template.examples.storyshot | 27 ++-- .../extended_template.examples.storyshot | 12 +- .../simple_template.examples.storyshot | 2 + .../__snapshots__/shareable.test.tsx.snap | 10 +- .../__snapshots__/canvas.examples.storyshot | 33 +++-- .../__tests__/__snapshots__/app.test.tsx.snap | 2 +- .../__snapshots__/footer.examples.storyshot | 22 ++- .../page_controls.examples.storyshot | 18 ++- .../__snapshots__/title.examples.storyshot | 6 + .../autoplay_settings.examples.storyshot | 12 ++ .../__snapshots__/settings.examples.storyshot | 6 +- .../toolbar_settings.examples.storyshot | 12 ++ .../__snapshots__/settings.test.tsx.snap | 104 ++++++++++--- .../extend_index_management.test.js.snap | 6 +- .../__snapshots__/policy_table.test.js.snap | 3 + .../node_attrs_details/node_attrs_details.js | 2 +- .../template_table/template_table.tsx | 8 +- .../components/nodes_overview/table.tsx | 6 +- .../sections/anomalies/table.tsx | 10 +- x-pack/legacy/plugins/infra/types/eui.d.ts | 23 --- .../__snapshots__/license_status.test.js.snap | 4 +- .../upload_license.test.tsx.snap | 48 ++++-- .../pipelines_table.test.js.snap | 1 - .../upgrade_failure.test.js.snap | 12 ++ .../annotations_table.test.js.snap | 1 - .../components/job_messages/job_messages.tsx | 5 +- .../components/ml_in_memory_table/types.ts | 29 ++-- .../__snapshots__/events_table.test.js.snap | 2 - .../table/__snapshots__/table.test.js.snap | 1 - .../list/__snapshots__/table.test.js.snap | 2 - .../__snapshots__/no_data.test.js.snap | 4 + .../__snapshots__/summary_status.test.js.snap | 4 + .../remote_cluster_form.test.js.snap | 9 ++ .../report_info_button.test.tsx.snap | 34 +++-- .../report_listing.test.tsx.snap | 140 ------------------ .../public/components/report_listing.tsx | 9 +- .../api_keys_grid_page.test.tsx.snap | 18 ++- .../components/api_keys_grid_page.tsx | 5 +- .../__snapshots__/feature_table.test.tsx.snap | 3 - .../privilege_space_table.tsx | 6 +- .../roles_grid_page.test.tsx.snap | 9 +- .../roles_grid/components/roles_grid_page.tsx | 9 +- .../users_grid/components/users_list_page.tsx | 10 +- .../event_details/event_fields_browser.tsx | 1 + .../components/event_details/helpers.tsx | 12 +- .../fields_browser/category_columns.tsx | 2 +- .../components/fields_browser/field_items.tsx | 4 +- .../ml/tables/anomalies_host_table.tsx | 4 +- .../ml/tables/anomalies_network_table.tsx | 4 +- .../components/ml/tables/basic_table.tsx | 11 +- .../ml_popover/jobs_table/jobs_table.tsx | 2 +- .../siem/public/components/notes/columns.tsx | 3 + .../siem/public/components/notes/helpers.tsx | 8 +- .../siem/public/components/notes/index.tsx | 16 +- .../open_timeline/timelines_table/index.tsx | 7 +- .../page/network/network_http_table/index.tsx | 3 +- .../components/paginated_table/index.tsx | 21 ++- .../__snapshots__/index.test.tsx.snap | 26 +++- .../plugins/siem/public/graphql/types.ts | 14 +- .../detection_engine/rule_details/index.tsx | 5 +- .../rules/activity_monitor/columns.tsx | 32 ++-- .../rules/activity_monitor/index.tsx | 21 +-- .../rules/all_rules/columns.tsx | 18 ++- .../rules/all_rules/index.tsx | 2 +- .../pages/detection_engine/rules/types.ts | 2 +- .../policy_list/policy_table/policy_table.tsx | 4 +- .../repository_table/repository_table.tsx | 4 +- .../restore_table/shards_table.tsx | 1 + .../snapshot_table/snapshot_table.tsx | 4 +- .../enabled_features/feature_table.tsx | 2 +- .../spaces_grid_pages.test.tsx.snap | 1 - .../components/step_define/pivot_preview.tsx | 2 +- .../components/transform_list/columns.tsx | 2 +- .../expanded_row_messages_pane.tsx | 4 +- .../expanded_row_preview_pane.tsx | 11 +- .../transform_list/transform_list.tsx | 9 +- .../tabs/checkup/deprecations/index_table.tsx | 4 +- .../monitor_status.bar.test.tsx.snap | 2 + .../uptime_date_picker.test.tsx.snap | 8 + .../__snapshots__/donut_chart.test.tsx.snap | 4 + .../__snapshots__/empty_state.test.tsx.snap | 12 ++ .../filter_popover.test.tsx.snap | 1 + .../functional/monitor_list/monitor_list.tsx | 8 +- .../functional/monitor_list/types.ts | 4 +- .../functional/ping_list/ping_list.tsx | 2 +- .../json_watch_edit_simulate_results.tsx | 6 +- .../watch_list/components/watch_list.tsx | 2 +- .../watch_status/components/watch_history.tsx | 2 +- x-pack/package.json | 2 +- yarn.lock | 8 +- 150 files changed, 997 insertions(+), 626 deletions(-) diff --git a/package.json b/package.json index a771a130d08b1..1cec7aaacbbc9 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "@elastic/charts": "^14.0.0", "@elastic/datemath": "5.0.2", "@elastic/ems-client": "1.0.5", - "@elastic/eui": "17.0.0", + "@elastic/eui": "17.1.2", "@elastic/filesaver": "1.1.2", "@elastic/good": "8.1.1-kibana2", "@elastic/numeral": "2.3.3", diff --git a/src/core/public/overlays/flyout/__snapshots__/flyout_service.test.tsx.snap b/src/core/public/overlays/flyout/__snapshots__/flyout_service.test.tsx.snap index 626c91b6a9668..9bd686776138f 100644 --- a/src/core/public/overlays/flyout/__snapshots__/flyout_service.test.tsx.snap +++ b/src/core/public/overlays/flyout/__snapshots__/flyout_service.test.tsx.snap @@ -31,7 +31,7 @@ Array [ ] `; -exports[`FlyoutService openFlyout() renders a flyout to the DOM 2`] = `"
Flyout content
"`; +exports[`FlyoutService openFlyout() renders a flyout to the DOM 2`] = `"
Flyout content
"`; exports[`FlyoutService openFlyout() with a currently active flyout replaces the current flyout with a new one 1`] = ` Array [ @@ -74,4 +74,4 @@ Array [ ] `; -exports[`FlyoutService openFlyout() with a currently active flyout replaces the current flyout with a new one 2`] = `"
Flyout content 2
"`; +exports[`FlyoutService openFlyout() with a currently active flyout replaces the current flyout with a new one 2`] = `"
Flyout content 2
"`; diff --git a/src/core/public/overlays/modal/__snapshots__/modal_service.test.tsx.snap b/src/core/public/overlays/modal/__snapshots__/modal_service.test.tsx.snap index 3928c54f90179..131ec836f5252 100644 --- a/src/core/public/overlays/modal/__snapshots__/modal_service.test.tsx.snap +++ b/src/core/public/overlays/modal/__snapshots__/modal_service.test.tsx.snap @@ -29,7 +29,7 @@ Array [ ] `; -exports[`ModalService openModal() renders a modal to the DOM 2`] = `"
Modal content
"`; +exports[`ModalService openModal() renders a modal to the DOM 2`] = `"
Modal content
"`; exports[`ModalService openModal() with a currently active modal replaces the current modal with a new one 1`] = ` Array [ diff --git a/src/legacy/core_plugins/kibana/public/dashboard/__tests__/__snapshots__/dashboard_empty_screen.test.tsx.snap b/src/legacy/core_plugins/kibana/public/dashboard/__tests__/__snapshots__/dashboard_empty_screen.test.tsx.snap index 4ea658bcd03ef..178014a691be3 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/__tests__/__snapshots__/dashboard_empty_screen.test.tsx.snap +++ b/src/legacy/core_plugins/kibana/public/dashboard/__tests__/__snapshots__/dashboard_empty_screen.test.tsx.snap @@ -230,14 +230,18 @@ exports[`DashboardEmptyScreen renders correctly with visualize paragraph 1`] = ` type="dashboardApp" > `; exports[`Table should render the boolean template (true) 1`] = ` `; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/scripted_fields_table/components/table/__jest__/__snapshots__/table.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/scripted_fields_table/components/table/__jest__/__snapshots__/table.test.js.snap index f2a55649fe4d7..4716fb8f77633 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/scripted_fields_table/components/table/__jest__/__snapshots__/table.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/scripted_fields_table/components/table/__jest__/__snapshots__/table.test.js.snap @@ -55,7 +55,6 @@ exports[`Table should render normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/source_filters_table/components/table/__jest__/__snapshots__/table.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/source_filters_table/components/table/__jest__/__snapshots__/table.test.js.snap index 415bae7389e97..7856572373e79 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/source_filters_table/components/table/__jest__/__snapshots__/table.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/source_filters_table/components/table/__jest__/__snapshots__/table.test.js.snap @@ -78,7 +78,6 @@ exports[`Table should render normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx index f54afc4a5e359..f254a6bc22a0d 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/index_pattern_table/index_pattern_table.tsx @@ -59,7 +59,7 @@ const columns = [ ))} ), - dataType: 'string', + dataType: 'string' as const, sortable: ({ sort }: { sort: string }) => sort, }, ]; @@ -72,7 +72,7 @@ const pagination = { const sorting = { sort: { field: 'title', - direction: 'asc', + direction: 'asc' as const, }, }; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap index 843c8207c88c3..731a3379491c1 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/__jest__/__snapshots__/objects_table.test.js.snap @@ -54,7 +54,6 @@ exports[`ObjectsTable delete should show a confirm modal 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/__jest__/__snapshots__/flyout.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/__jest__/__snapshots__/flyout.test.js.snap index a9175e7b2a63e..ace06e0420a7c 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/__jest__/__snapshots__/flyout.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/flyout/__jest__/__snapshots__/flyout.test.js.snap @@ -90,7 +90,6 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -116,7 +115,6 @@ exports[`Flyout conflicts should allow conflict resolution 1`] = ` } } responsive={true} - sorting={false} /> @@ -411,7 +409,6 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -448,7 +445,6 @@ exports[`Flyout legacy conflicts should allow conflict resolution 1`] = ` } } responsive={true} - sorting={false} /> diff --git a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/relationships/__jest__/__snapshots__/relationships.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/relationships/__jest__/__snapshots__/relationships.test.js.snap index 6060e96f3cfb6..941a0ffded820 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/relationships/__jest__/__snapshots__/relationships.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/objects/components/objects_table/components/relationships/__jest__/__snapshots__/relationships.test.js.snap @@ -83,7 +83,6 @@ exports[`Relationships should render dashboards normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -155,7 +154,6 @@ exports[`Relationships should render dashboards normally 1`] = ` ], } } - sorting={false} />
@@ -294,7 +292,6 @@ exports[`Relationships should render index patterns normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -371,7 +368,6 @@ exports[`Relationships should render index patterns normally 1`] = ` ], } } - sorting={false} />
@@ -461,7 +457,6 @@ exports[`Relationships should render searches normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -538,7 +533,6 @@ exports[`Relationships should render searches normally 1`] = ` ], } } - sorting={false} />
@@ -628,7 +622,6 @@ exports[`Relationships should render visualizations normally 1`] = ` }, ] } - executeQueryOptions={Object {}} items={ Array [ Object { @@ -700,7 +693,6 @@ exports[`Relationships should render visualizations normally 1`] = ` ], } } - sorting={false} /> diff --git a/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap b/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap index ca6b872c73f8f..0b44c7dc4e860 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap +++ b/src/legacy/core_plugins/kibana/public/visualize/wizard/__snapshots__/new_vis_modal.test.tsx.snap @@ -169,6 +169,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiButtonIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -226,6 +227,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -275,6 +277,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiBetaBadge__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -290,6 +293,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -325,6 +329,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -361,6 +366,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -494,6 +500,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiButtonIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -551,6 +558,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -600,6 +608,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiBetaBadge__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -615,6 +624,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -650,6 +660,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -686,6 +697,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -758,6 +770,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiButtonIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -815,6 +828,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -864,6 +878,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--medium euiIcon-isLoading euiBetaBadge__icon" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -879,6 +894,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -914,6 +930,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -950,6 +967,7 @@ exports[`NewVisModal filter for visualization types should render as expected 1` class="euiIcon euiIcon--large euiIcon--secondary euiIcon-isLoading" focusable="false" height="16" + role="img" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" @@ -1031,16 +1049,18 @@ exports[`NewVisModal filter for visualization types should render as expected 1` type="cross" >