[Metrics UI] Fix alert management to open without refresh (#73739)
* [Metrics UI] Fix alert management to open without refresh * removing unecessary code * Deleting unused imports Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
84884a9398
commit
aa668db796
|
@ -4,17 +4,16 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState, useCallback, useMemo } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import { EuiPopover, EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel } from '@elastic/eui';
|
import { EuiPopover, EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel } from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { useAlertPrefillContext } from '../../../alerting/use_alert_prefill';
|
import { useAlertPrefillContext } from '../../../alerting/use_alert_prefill';
|
||||||
import { AlertFlyout } from './alert_flyout';
|
import { AlertFlyout } from './alert_flyout';
|
||||||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
|
import { ManageAlertsContextMenuItem } from './manage_alerts_context_menu_item';
|
||||||
|
|
||||||
export const InventoryAlertDropdown = () => {
|
export const InventoryAlertDropdown = () => {
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [flyoutVisible, setFlyoutVisible] = useState(false);
|
const [flyoutVisible, setFlyoutVisible] = useState(false);
|
||||||
const kibana = useKibana();
|
|
||||||
|
|
||||||
const { inventoryPrefill } = useAlertPrefillContext();
|
const { inventoryPrefill } = useAlertPrefillContext();
|
||||||
const { nodeType, metric, filterQuery } = inventoryPrefill;
|
const { nodeType, metric, filterQuery } = inventoryPrefill;
|
||||||
|
@ -27,26 +26,12 @@ export const InventoryAlertDropdown = () => {
|
||||||
setPopoverOpen(true);
|
setPopoverOpen(true);
|
||||||
}, [setPopoverOpen]);
|
}, [setPopoverOpen]);
|
||||||
|
|
||||||
const menuItems = useMemo(() => {
|
const menuItems = [
|
||||||
return [
|
<EuiContextMenuItem icon="bell" key="createLink" onClick={() => setFlyoutVisible(true)}>
|
||||||
<EuiContextMenuItem icon="bell" key="createLink" onClick={() => setFlyoutVisible(true)}>
|
<FormattedMessage id="xpack.infra.alerting.createAlertButton" defaultMessage="Create alert" />
|
||||||
<FormattedMessage
|
</EuiContextMenuItem>,
|
||||||
id="xpack.infra.alerting.createAlertButton"
|
<ManageAlertsContextMenuItem />,
|
||||||
defaultMessage="Create alert"
|
];
|
||||||
/>
|
|
||||||
</EuiContextMenuItem>,
|
|
||||||
<EuiContextMenuItem
|
|
||||||
icon="tableOfContents"
|
|
||||||
key="manageLink"
|
|
||||||
href={kibana.services?.application?.getUrlForApp(
|
|
||||||
'management/insightsAndAlerting/triggersActions/alerts'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<FormattedMessage id="xpack.infra.alerting.manageAlerts" defaultMessage="Manage alerts" />
|
|
||||||
</EuiContextMenuItem>,
|
|
||||||
];
|
|
||||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
||||||
}, [kibana.services]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -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 (
|
||||||
|
<EuiContextMenuItem icon="tableOfContents" key="manageLink" {...manageAlertsLinkProps}>
|
||||||
|
<FormattedMessage id="xpack.infra.alerting.manageAlerts" defaultMessage="Manage alerts" />
|
||||||
|
</EuiContextMenuItem>
|
||||||
|
);
|
||||||
|
};
|
|
@ -4,17 +4,16 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useState, useCallback, useMemo } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import { EuiPopover, EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel } from '@elastic/eui';
|
import { EuiPopover, EuiButtonEmpty, EuiContextMenuItem, EuiContextMenuPanel } from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
|
|
||||||
import { useAlertPrefillContext } from '../../use_alert_prefill';
|
import { useAlertPrefillContext } from '../../use_alert_prefill';
|
||||||
import { AlertFlyout } from './alert_flyout';
|
import { AlertFlyout } from './alert_flyout';
|
||||||
|
import { ManageAlertsContextMenuItem } from '../../inventory/components/manage_alerts_context_menu_item';
|
||||||
|
|
||||||
export const MetricsAlertDropdown = () => {
|
export const MetricsAlertDropdown = () => {
|
||||||
const [popoverOpen, setPopoverOpen] = useState(false);
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
||||||
const [flyoutVisible, setFlyoutVisible] = useState(false);
|
const [flyoutVisible, setFlyoutVisible] = useState(false);
|
||||||
const kibana = useKibana();
|
|
||||||
|
|
||||||
const { metricThresholdPrefill } = useAlertPrefillContext();
|
const { metricThresholdPrefill } = useAlertPrefillContext();
|
||||||
const { groupBy, filterQuery, metrics } = metricThresholdPrefill;
|
const { groupBy, filterQuery, metrics } = metricThresholdPrefill;
|
||||||
|
@ -27,26 +26,12 @@ export const MetricsAlertDropdown = () => {
|
||||||
setPopoverOpen(true);
|
setPopoverOpen(true);
|
||||||
}, [setPopoverOpen]);
|
}, [setPopoverOpen]);
|
||||||
|
|
||||||
const menuItems = useMemo(() => {
|
const menuItems = [
|
||||||
return [
|
<EuiContextMenuItem icon="bell" key="createLink" onClick={() => setFlyoutVisible(true)}>
|
||||||
<EuiContextMenuItem icon="bell" key="createLink" onClick={() => setFlyoutVisible(true)}>
|
<FormattedMessage id="xpack.infra.alerting.createAlertButton" defaultMessage="Create alert" />
|
||||||
<FormattedMessage
|
</EuiContextMenuItem>,
|
||||||
id="xpack.infra.alerting.createAlertButton"
|
<ManageAlertsContextMenuItem />,
|
||||||
defaultMessage="Create alert"
|
];
|
||||||
/>
|
|
||||||
</EuiContextMenuItem>,
|
|
||||||
<EuiContextMenuItem
|
|
||||||
icon="tableOfContents"
|
|
||||||
key="manageLink"
|
|
||||||
href={kibana.services?.application?.getUrlForApp(
|
|
||||||
'management/insightsAndAlerting/triggersActions/alerts'
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<FormattedMessage id="xpack.infra.alerting.manageAlerts" defaultMessage="Manage alerts" />
|
|
||||||
</EuiContextMenuItem>,
|
|
||||||
];
|
|
||||||
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
||||||
}, [kibana.services]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in a new issue