Skip to content

Commit

Permalink
Fix Alerts table inspect modal incomplete title
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed May 3, 2023
1 parent a16930f commit daea4b6
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 daea4b6

Please sign in to comment.