From 7d2bd7d6ad395fd364024e49b8755fb52b539d7f Mon Sep 17 00:00:00 2001 From: Coen Warmer Date: Fri, 30 Sep 2022 15:30:35 +0200 Subject: [PATCH] Adjust order and naming of header action buttons --- .../components/header_actions.test.tsx | 19 ------- .../components/header_actions.tsx | 56 +++++-------------- .../components/page_title.test.tsx | 2 +- 3 files changed, 16 insertions(+), 61 deletions(-) diff --git a/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.test.tsx b/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.test.tsx index 3884447cd8933..8bbec59c52b95 100644 --- a/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.test.tsx +++ b/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.test.tsx @@ -52,8 +52,6 @@ describe('Header Actions', () => { mockKibana(); }); - const mockViewInExternalApp = jest.fn(); - it('should display an actions button', () => { const { queryByTestId } = render(); expect(queryByTestId('alert-details-header-actions-menu-button')).toBeTruthy(); @@ -82,21 +80,4 @@ describe('Header Actions', () => { }); }); }); - - it('should show a connector action if passed an externalConnector prop', async () => { - const { findByRole, getByTestId } = render( - - ); - - fireEvent.click(await findByRole('button', { name: 'Actions' })); - const button = getByTestId('view-in-external-app-button'); - expect(button).toBeTruthy(); - - fireEvent.click(button); - - expect(mockViewInExternalApp).toBeCalledTimes(1); - }); }); diff --git a/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.tsx b/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.tsx index 7b851dc09bbba..e7a2c773dc68f 100644 --- a/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.tsx +++ b/x-pack/plugins/observability/public/pages/alert_details/components/header_actions.tsx @@ -20,13 +20,9 @@ import { TopAlert } from '../../alerts'; export interface HeaderActionsProps { alert: TopAlert | null; - externalConnector?: { - name: string; - onViewInExternalApp: (alertId: string) => void; - }; } -export function HeaderActions({ alert, externalConnector }: HeaderActionsProps) { +export function HeaderActions({ alert }: HeaderActionsProps) { const { http, cases: { @@ -69,7 +65,7 @@ export function HeaderActions({ alert, externalConnector }: HeaderActionsProps) selectCaseModal.open({ attachments }); }; - const handleViewRuleConditions = () => { + const handleViewRuleDetails = () => { setIsPopoverOpen(false); setRuleConditionsFlyoutOpen(true); }; @@ -79,12 +75,6 @@ export function HeaderActions({ alert, externalConnector }: HeaderActionsProps) setSnoozeModalOpen(true); }; - const handleOpenInExternalApp = () => { - if (alert) { - externalConnector?.onViewInExternalApp(alert.fields[ALERT_UUID]); - } - }; - return ( <> - {i18n.translate('xpack.observability.alertDetails.addToCase', { - defaultMessage: 'Add to case', + {i18n.translate('xpack.observability.alertDetails.viewRuleDetails', { + defaultMessage: 'View rule details', })} @@ -121,13 +112,12 @@ export function HeaderActions({ alert, externalConnector }: HeaderActionsProps) - {i18n.translate('xpack.observability.alertDetails.viewRuleConditons', { - defaultMessage: 'View rule conditions', + {i18n.translate('xpack.observability.alertDetails.editSnoozeRule', { + defaultMessage: 'Snooze the rule', })} @@ -135,31 +125,15 @@ export function HeaderActions({ alert, externalConnector }: HeaderActionsProps) - {i18n.translate('xpack.observability.alertDetails.editSnoozeRule', { - defaultMessage: 'Snooze the rule', + {i18n.translate('xpack.observability.alertDetails.addToCase', { + defaultMessage: 'Add to case', })} - - {externalConnector ? ( - - - {i18n.translate('xpack.observability.alertDetails.viewInExternalApp', { - defaultMessage: 'View in {name}', - values: { name: externalConnector.name }, - })} - - - ) : null} diff --git a/x-pack/plugins/observability/public/pages/alert_details/components/page_title.test.tsx b/x-pack/plugins/observability/public/pages/alert_details/components/page_title.test.tsx index e669e57cd6021..bd0b15e8ffc2a 100644 --- a/x-pack/plugins/observability/public/pages/alert_details/components/page_title.test.tsx +++ b/x-pack/plugins/observability/public/pages/alert_details/components/page_title.test.tsx @@ -22,7 +22,7 @@ describe('Page Title', () => { it('should display a title when it is passed', () => { const { getByText } = renderComp(defaultProps); - expect(getByText('Great success')).toBeTruthy(); + expect(getByText(defaultProps.title)).toBeTruthy(); }); it('should display an active badge when active is true', async () => {