diff --git a/public/app/features/alerting/unified/Receivers.test.tsx b/public/app/features/alerting/unified/Receivers.test.tsx index 5058856159d..389c5c06c29 100644 --- a/public/app/features/alerting/unified/Receivers.test.tsx +++ b/public/app/features/alerting/unified/Receivers.test.tsx @@ -24,6 +24,7 @@ import store from 'app/core/store'; import { contextSrv } from 'app/core/services/context_srv'; import { selectOptionInTest } from '@grafana/ui'; import { AlertManagerDataSourceJsonData, AlertManagerImplementation } from 'app/plugins/datasource/alertmanager/types'; +import { interceptLinkClicks } from 'app/core/navigation/patch/interceptLinkClicks'; jest.mock('./api/alertmanager'); jest.mock('./api/grafana'); @@ -116,6 +117,8 @@ const clickSelectOption = async (selectElement: HTMLElement, optionText: string) await selectOptionInTest(selectElement, optionText); }; +document.addEventListener('click', interceptLinkClicks); + describe('Receivers', () => { beforeEach(() => { jest.resetAllMocks(); @@ -404,11 +407,12 @@ describe('Receivers', () => { const receiverRows = receiversTable.querySelectorAll('tbody tr'); expect(receiverRows[0]).toHaveTextContent('cloud-receiver'); expect(byTestId('edit').query(receiverRows[0])).not.toBeInTheDocument(); - await userEvent.click(byTestId('view').get(receiverRows[0])); + userEvent.click(byTestId('view').get(receiverRows[0])); // check that form is open await byRole('heading', { name: /contact point/i }).find(); expect(locationService.getLocation().pathname).toEqual('/alerting/notifications/receivers/cloud-receiver/edit'); + const channelForms = ui.channelFormContainer.queryAll(); expect(channelForms).toHaveLength(2); diff --git a/public/app/features/alerting/unified/components/rules/ActionIcon.tsx b/public/app/features/alerting/unified/components/rules/ActionIcon.tsx index d38406a105a..e8000c98a88 100644 --- a/public/app/features/alerting/unified/components/rules/ActionIcon.tsx +++ b/public/app/features/alerting/unified/components/rules/ActionIcon.tsx @@ -1,18 +1,15 @@ -import { Icon, IconName, useStyles, Tooltip } from '@grafana/ui'; +import { IconName, Tooltip, LinkButton, Button } from '@grafana/ui'; import { PopoverContent, TooltipPlacement } from '@grafana/ui/src/components/Tooltip'; import React, { FC } from 'react'; -import { css, cx } from '@emotion/css'; -import { Link } from 'react-router-dom'; interface Props { tooltip: PopoverContent; icon: IconName; - className?: string; tooltipPlacement?: TooltipPlacement; to?: string; target?: string; - onClick?: (e: React.MouseEvent) => void; + onClick?: () => void; 'data-testid'?: string; } @@ -27,53 +24,33 @@ export const ActionIcon: FC = ({ ...rest }) => { const ariaLabel = typeof tooltip === 'string' ? tooltip : undefined; - const iconEl = ( - - ); return ( {to ? ( - - {iconEl} - + ) : ( - iconEl +