From 340f01a1580d7512d263dbca12f7de73dfc21d2c Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Wed, 29 Jul 2020 12:54:50 -0700 Subject: [PATCH] [Metrics UI] Fix alert management to open without refresh --- .../inventory/components/alert_dropdown.tsx | 11 ++-------- .../manage_alerts_context_menu_item.tsx | 22 +++++++++++++++++++ .../components/alert_dropdown.tsx | 11 ++-------- 3 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 x-pack/plugins/infra/public/alerting/inventory/components/manage_alerts_context_menu_item.tsx diff --git a/x-pack/plugins/infra/public/alerting/inventory/components/alert_dropdown.tsx b/x-pack/plugins/infra/public/alerting/inventory/components/alert_dropdown.tsx index 04642a01c15b4d..0dba1f4c4d5c87 100644 --- a/x-pack/plugins/infra/public/alerting/inventory/components/alert_dropdown.tsx +++ b/x-pack/plugins/infra/public/alerting/inventory/components/alert_dropdown.tsx @@ -10,6 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { useAlertPrefillContext } from '../../../alerting/use_alert_prefill'; import { AlertFlyout } from './alert_flyout'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { ManageAlertsContextMenuItem } from './manage_alerts_context_menu_item'; export const InventoryAlertDropdown = () => { const [popoverOpen, setPopoverOpen] = useState(false); @@ -35,15 +36,7 @@ export const InventoryAlertDropdown = () => { defaultMessage="Create alert" /> , - - - , + , ]; /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [kibana.services]); diff --git a/x-pack/plugins/infra/public/alerting/inventory/components/manage_alerts_context_menu_item.tsx b/x-pack/plugins/infra/public/alerting/inventory/components/manage_alerts_context_menu_item.tsx new file mode 100644 index 00000000000000..fc565aee37ff48 --- /dev/null +++ b/x-pack/plugins/infra/public/alerting/inventory/components/manage_alerts_context_menu_item.tsx @@ -0,0 +1,22 @@ +/* + * 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 { EuiContextMenuItem } from '@elastic/eui'; +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { useLinkProps } from '../../../hooks/use_link_props'; + +export const ManageAlertsContextMenuItem = () => { + const manageAlertsLinkProps = useLinkProps({ + app: 'management', + pathname: '/insightsAndAlerting/triggersActions/alerts', + }); + return ( + + + + ); +}; diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx index 384a93e796dbe3..b485b92e0912c1 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/alert_dropdown.tsx @@ -10,6 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { useAlertPrefillContext } from '../../use_alert_prefill'; import { AlertFlyout } from './alert_flyout'; +import { ManageAlertsContextMenuItem } from '../../inventory/components/manage_alerts_context_menu_item'; export const MetricsAlertDropdown = () => { const [popoverOpen, setPopoverOpen] = useState(false); @@ -35,15 +36,7 @@ export const MetricsAlertDropdown = () => { defaultMessage="Create alert" /> , - - - , + , ]; /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [kibana.services]);