Skip to content

Commit

Permalink
[8.8] Fix Alerts table inspect modal incomplete title (#156488) (#156648
Browse files Browse the repository at this point in the history
)

# Backport

This will backport the following commits from `main` to `8.8`:
- [Fix Alerts table inspect modal incomplete title
(#156488)](#156488)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Pablo
Machado","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-04T08:09:05Z","message":"Fix
Alerts table inspect modal incomplete title (#156488)\n\nissue:
https://github.com/elastic/kibana/issues/156267\r\n\r\n##
Summary\r\n\r\nAdd a title to \"Alerts Table inspect
modal\".\r\n\r\n**BEFORE**\r\n\r\n<img width=\"751\" alt=\"Screenshot
2023-05-03 at 15 55
58\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235937998-caedf8f5-6645-440f-af1d-8618e8012d8b.png\">\r\n\r\n**AFTER**\r\n\r\n<img
width=\"769\" alt=\"Screenshot 2023-05-03 at 15 58
30\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235938006-6c303f9d-8b81-43d0-b536-ae23f1f5bfd1.png\">","sha":"c1d76f8b4745334ff37491914b37c80c18dbfbeb","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Threat
Hunting","Team: SecuritySolution","Team:Threat
Hunting:Explore","v8.8.0","v8.9.0"],"number":156488,"url":"https://github.com/elastic/kibana/pull/156488","mergeCommit":{"message":"Fix
Alerts table inspect modal incomplete title (#156488)\n\nissue:
https://github.com/elastic/kibana/issues/156267\r\n\r\n##
Summary\r\n\r\nAdd a title to \"Alerts Table inspect
modal\".\r\n\r\n**BEFORE**\r\n\r\n<img width=\"751\" alt=\"Screenshot
2023-05-03 at 15 55
58\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235937998-caedf8f5-6645-440f-af1d-8618e8012d8b.png\">\r\n\r\n**AFTER**\r\n\r\n<img
width=\"769\" alt=\"Screenshot 2023-05-03 at 15 58
30\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235938006-6c303f9d-8b81-43d0-b536-ae23f1f5bfd1.png\">","sha":"c1d76f8b4745334ff37491914b37c80c18dbfbeb"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156488","number":156488,"mergeCommit":{"message":"Fix
Alerts table inspect modal incomplete title (#156488)\n\nissue:
https://github.com/elastic/kibana/issues/156267\r\n\r\n##
Summary\r\n\r\nAdd a title to \"Alerts Table inspect
modal\".\r\n\r\n**BEFORE**\r\n\r\n<img width=\"751\" alt=\"Screenshot
2023-05-03 at 15 55
58\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235937998-caedf8f5-6645-440f-af1d-8618e8012d8b.png\">\r\n\r\n**AFTER**\r\n\r\n<img
width=\"769\" alt=\"Screenshot 2023-05-03 at 15 58
30\"\r\nsrc=\"https://user-images.githubusercontent.com/1490444/235938006-6c303f9d-8b81-43d0-b536-ae23f1f5bfd1.png\">","sha":"c1d76f8b4745334ff37491914b37c80c18dbfbeb"}}]}]
BACKPORT-->

Co-authored-by: Pablo Machado <[email protected]>
  • Loading branch information
kibanamachine and machadoum authored May 4, 2023
1 parent 069d308 commit 499b5e9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { GetInspectQuery } from '../../../types';
import icon from './assets/illustration_product_no_results_magnifying_glass.svg';
import { InspectButton } from './toolbar/components/inspect';
import { ALERTS_TABLE_TITLE } from './translations';

const heights = {
tall: 490,
Expand All @@ -40,7 +41,7 @@ export const EmptyState: React.FC<{
<EuiFlexGroup alignItems="flexEnd" justifyContent="flexEnd">
{showInpectButton && (
<EuiFlexItem grow={false}>
<InspectButton getInspectQuery={getInspectQuery} />
<InspectButton getInspectQuery={getInspectQuery} inspectTitle={ALERTS_TABLE_TITLE} />
</EuiFlexItem>
)}
{controls?.right && <EuiFlexItem grow={false}>{controls.right}</EuiFlexItem>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ describe('Inspect Button', () => {
});

test('open Inspect Modal', async () => {
render(<InspectButton showInspectButton getInspectQuery={getInspectQuery} />);
render(
<InspectButton
inspectTitle={'Inspect Title'}
showInspectButton
getInspectQuery={getInspectQuery}
/>
);
fireEvent.click(await screen.findByTestId('inspect-icon-button'));

expect(await screen.findByTestId('mocker-modal')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ interface InspectButtonProps {
onCloseInspect?: () => void;
showInspectButton?: boolean;
getInspectQuery: GetInspectQuery;
inspectTitle: string;
}

const InspectButtonComponent: React.FC<InspectButtonProps> = ({ getInspectQuery }) => {
const InspectButtonComponent: React.FC<InspectButtonProps> = ({
getInspectQuery,
inspectTitle,
}) => {
const [isShowingModal, setIsShowingModal] = useState(false);

const onOpenModal = () => {
Expand All @@ -63,6 +67,7 @@ const InspectButtonComponent: React.FC<InspectButtonProps> = ({ getInspectQuery
closeModal={onCloseModal}
data-test-subj="inspect-modal"
getInspectQuery={getInspectQuery}
title={inspectTitle}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('Modal Inspect', () => {
const closeModal = jest.fn();
const defaultProps: ModalInspectProps = {
closeModal,
title: 'Inspect',
getInspectQuery: () => ({
request: [getRequest()],
response: [response],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DescriptionListStyled.displayName = 'DescriptionListStyled';
export interface ModalInspectProps {
closeModal: () => void;
getInspectQuery: GetInspectQuery;
title: string;
}

interface Request {
Expand Down Expand Up @@ -91,7 +92,7 @@ const stringify = (object: Request | Response): string => {
}
};

const ModalInspectQueryComponent = ({ closeModal, getInspectQuery }: ModalInspectProps) => {
const ModalInspectQueryComponent = ({ closeModal, getInspectQuery, title }: ModalInspectProps) => {
const { request, response } = getInspectQuery();
// using index 0 as there will be only one request and response for now
const parsedRequest: Request = parse(request[0]);
Expand Down Expand Up @@ -200,7 +201,9 @@ const ModalInspectQueryComponent = ({ closeModal, getInspectQuery }: ModalInspec
return (
<MyEuiModal onClose={closeModal} data-test-subj="modal-inspect-euiModal">
<EuiModalHeader>
<EuiModalHeaderTitle>{i18n.INSPECT}</EuiModalHeaderTitle>
<EuiModalHeaderTitle>
{i18n.INSPECT} {title}
</EuiModalHeaderTitle>
</EuiModalHeader>

<EuiModalBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { LastUpdatedAt } from './components/last_updated_at';
import { FieldBrowser } from '../../field_browser';
import { FieldBrowserOptions } from '../../field_browser/types';
import { InspectButton } from './components/inspect';
import { ALERTS_TABLE_TITLE } from '../translations';

const BulkActionsToolbar = lazy(() => import('../bulk_actions/components/toolbar'));

Expand All @@ -33,7 +34,9 @@ const rightControl = ({
}) => {
return (
<>
{showInspectButton && <InspectButton getInspectQuery={getInspectQuery} />}
{showInspectButton && (
<InspectButton inspectTitle={ALERTS_TABLE_TITLE} getInspectQuery={getInspectQuery} />
)}
<LastUpdatedAt updatedAt={updatedAt} />
{controls?.right}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ export const ALERTS_TABLE_CONTROL_COLUMNS_VIEW_DETAILS_LABEL = i18n.translate(
defaultMessage: 'View details',
}
);

export const ALERTS_TABLE_TITLE = i18n.translate(
'xpack.triggersActionsUI.sections.alertsTable.title',
{
defaultMessage: 'Alerts table',
}
);

0 comments on commit 499b5e9

Please sign in to comment.