Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Exceptions] - Fix bug mislabeling edit/delete for endpoint exception items #151532

Merged
merged 4 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import React, { useMemo } from 'react';
import type { FC } from 'react';
import type {
ExceptionListItemIdentifiers,
Expand All @@ -13,10 +13,8 @@ import type {
ViewerStatus,
} from '@kbn/securitysolution-exception-list-components';
import { ExceptionItems } from '@kbn/securitysolution-exception-list-components';
import type {
ExceptionListItemSchema,
ExceptionListTypeEnum,
} from '@kbn/securitysolution-io-ts-list-types';
import { ExceptionListTypeEnum } from '@kbn/securitysolution-io-ts-list-types';
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';

import type { Pagination } from '@elastic/eui';
import { FormattedDate } from '../../../common/components/formatted_date';
Expand Down Expand Up @@ -60,6 +58,18 @@ const ListExceptionItemsComponent: FC<ListExceptionItemsProps> = ({
onPaginationChange,
onCreateExceptionListItem,
}) => {
const editButtonText = useMemo(() => {
return listType === ExceptionListTypeEnum.ENDPOINT
? i18n.EXCEPTION_ITEM_CARD_EDIT_ENDPOINT_LABEL
: i18n.EXCEPTION_ITEM_CARD_EDIT_LABEL;
}, [listType]);

const deleteButtonText = useMemo(() => {
return listType === ExceptionListTypeEnum.ENDPOINT
? i18n.EXCEPTION_ITEM_CARD_DELETE_ENDPOINT_LABEL
: i18n.EXCEPTION_ITEM_CARD_DELETE_LABEL;
}, [listType]);

return (
<>
<ExceptionItems
Expand All @@ -73,8 +83,8 @@ const ListExceptionItemsComponent: FC<ListExceptionItemsProps> = ({
emptyViewerButtonText={emptyViewerButtonText}
pagination={pagination}
lastUpdated={lastUpdated}
editActionLabel={i18n.EXCEPTION_ITEM_CARD_EDIT_LABEL}
deleteActionLabel={i18n.EXCEPTION_ITEM_CARD_DELETE_LABEL}
editActionLabel={editButtonText}
deleteActionLabel={deleteButtonText}
onPaginationChange={onPaginationChange}
onEditExceptionItem={onEditExceptionItem}
onDeleteException={onDeleteException}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@ export const EXCEPTION_ITEM_CARD_EDIT_LABEL = i18n.translate(
}
);

export const EXCEPTION_ITEM_CARD_EDIT_ENDPOINT_LABEL = i18n.translate(
'xpack.securitySolution.exceptions.list.exception.endpoint.item.card.edit.label',
{
defaultMessage: 'Edit endpoint exception',
}
);

export const EXCEPTION_ITEM_CARD_DELETE_LABEL = i18n.translate(
'xpack.securitySolution.exceptions.list.exception.item.card.delete.label',
{
defaultMessage: 'Delete rule exception',
}
);

export const EXCEPTION_ITEM_CARD_DELETE_ENDPOINT_LABEL = i18n.translate(
'xpack.securitySolution.exceptions.list.exception.endpoint.item.card.delete.label',
{
defaultMessage: 'Delete endpoint exception',
}
);

export const EXCEPTION_UTILITY_TITLE = i18n.translate(
'xpack.securitySolution.exceptions.list.utility.title',
{
Expand Down