Skip to content

Commit

Permalink
[8.7] [Security Solution][Exceptions] - Fix pagination bug on shared …
Browse files Browse the repository at this point in the history
…exception lists view (#151393) (#151927)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Security Solution][Exceptions] - Fix pagination bug on shared
exception lists view
(#151393)](#151393)

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

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

<!--BACKPORT [{"author":{"name":"Yara
Tercero","email":"yctercero@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-22T18:55:11Z","message":"[Security
Solution][Exceptions] - Fix pagination bug on shared exception lists
view (#151393)\n\n## Summary\r\n\r\nFixes
#147849 changing
number of rows in exception lists view from any page other\r\nthan page
1.","sha":"250dcffcdab4a63411713d638185b0c1c7c84687","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Detections
and Resp","Feature:Rule Exceptions","Team:Security Solution
Platform","v8.7.0","v8.8.0"],"number":151393,"url":"#151393
Solution][Exceptions] - Fix pagination bug on shared exception lists
view (#151393)\n\n## Summary\r\n\r\nFixes
#147849 changing
number of rows in exception lists view from any page other\r\nthan page
1.","sha":"250dcffcdab4a63411713d638185b0c1c7c84687"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"#151393
Solution][Exceptions] - Fix pagination bug on shared exception lists
view (#151393)\n\n## Summary\r\n\r\nFixes
#147849 changing
number of rows in exception lists view from any page other\r\nthan page
1.","sha":"250dcffcdab4a63411713d638185b0c1c7c84687"}}]}] BACKPORT-->

Co-authored-by: Yara Tercero <yctercero@users.noreply.github.com>
  • Loading branch information
kibanamachine and yctercero committed Feb 22, 2023
1 parent 0c4ecdf commit 2ba04b9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
EuiSpacer,
EuiPageHeader,
EuiHorizontalRule,
EuiText,
} from '@elastic/eui';

import type { NamespaceType, ExceptionListFilter } from '@kbn/securitysolution-io-ts-list-types';
Expand Down Expand Up @@ -151,7 +152,7 @@ export const SharedLists = React.memo(() => {
);

const handleDelete = useCallback(
({ id, listId, namespaceType }: { id: string; listId: string; namespaceType: NamespaceType }) =>
({ id, namespaceType }: { id: string; namespaceType: NamespaceType }) =>
async () => {
try {
if (exceptionsListsRef[id] != null) {
Expand Down Expand Up @@ -329,44 +330,28 @@ export const SharedLists = React.memo(() => {
iconSide="right"
onClick={onRowSizeButtonClick}
>
{/* TODO move to translations */}
{`Rows per page: ${rowSize}`}
{i18n.allExceptionsRowPerPage(rowSize)}
</EuiButtonEmpty>
);

const getIconType = (size: number) => {
return size === rowSize ? 'check' : 'empty';
};

const onPerPageClick = useCallback((size: number) => {
closeRowSizePopover();
setRowSize(size);
setActivePage(0);
}, []);

const rowSizeItems = [
<EuiContextMenuItem
key="5 rows"
icon={getIconType(5)}
onClick={() => {
closeRowSizePopover();
setRowSize(5);
}}
>
<EuiContextMenuItem key="5 rows" icon={getIconType(5)} onClick={() => onPerPageClick(5)}>
{'5 rows'}
</EuiContextMenuItem>,
<EuiContextMenuItem
key="10 rows"
icon={getIconType(10)}
onClick={() => {
closeRowSizePopover();
setRowSize(10);
}}
>
<EuiContextMenuItem key="10 rows" icon={getIconType(10)} onClick={() => onPerPageClick(10)}>
{'10 rows'}
</EuiContextMenuItem>,
<EuiContextMenuItem
key="25 rows"
icon={getIconType(25)}
onClick={() => {
closeRowSizePopover();
setRowSize(25);
}}
>
<EuiContextMenuItem key="25 rows" icon={getIconType(25)} onClick={() => onPerPageClick(25)}>
{'25 rows'}
</EuiContextMenuItem>,
];
Expand Down Expand Up @@ -397,14 +382,16 @@ export const SharedLists = React.memo(() => {
return (
<>
<MissingPrivilegesCallOut />
<EuiFlexGroup>
<EuiFlexItem>
<EuiPageHeader
pageTitle={i18n.ALL_EXCEPTIONS}
description={
<>
<div>
{"To view rule specific exceptions navigate to that rule's details page."}
<EuiPageHeader
pageTitle={i18n.ALL_EXCEPTIONS}
description={
<EuiFlexGroup gutterSize="xs" direction="column">
<EuiFlexItem>
<EuiFlexGroup gutterSize="none" direction="row">
<EuiFlexItem grow={false}>
<EuiText>{i18n.ALL_EXCEPTIONS_SUBTITLE}</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<EuiButtonIcon
iconType="popout"
aria-label="go-to-rules"
Expand All @@ -413,24 +400,18 @@ export const SharedLists = React.memo(() => {
navigateToApp('security', { openInNewTab: true, path: '/rules' })
}
/>
</div>
{/* TODO: update the above text to incorporate a navigateToApp link to the rule management page */}
<div>
{timelines.getLastUpdated({
showUpdating: loading,
updatedAt: lastUpdated,
})}
</div>
</>
}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton iconType={'importAction'} onClick={() => setDisplayImportListFlyout(true)}>
{i18n.IMPORT_EXCEPTION_LIST_BUTTON}
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
{timelines.getLastUpdated({
showUpdating: loading,
updatedAt: lastUpdated,
})}
</EuiFlexItem>
</EuiFlexGroup>
}
rightSideItems={[
<EuiPopover
data-test-subj="manageExceptionListCreateButton"
button={
Expand Down Expand Up @@ -464,9 +445,12 @@ export const SharedLists = React.memo(() => {
</EuiContextMenuItem>,
]}
/>
</EuiPopover>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPopover>,
<EuiButton iconType={'importAction'} onClick={() => setDisplayImportListFlyout(true)}>
{i18n.IMPORT_EXCEPTION_LIST_BUTTON}
</EuiButton>,
]}
/>

{displayCreateSharedListFlyout && (
<CreateSharedListFlyout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ export const ALL_EXCEPTIONS = i18n.translate(
}
);

export const ALL_EXCEPTIONS_SUBTITLE = i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allExceptions.tableSubtitle',
{
defaultMessage: "To view rule specific exceptions navigate to that rule's details page.",
}
);

export const allExceptionsRowPerPage = (rowSize: number) =>
i18n.translate('xpack.securitySolution.exceptions.allExceptionsRowPerPage', {
defaultMessage: 'Rows per page: {rowSize}',
values: { rowSize },
});

export const NO_LISTS_BODY = i18n.translate(
'xpack.securitySolution.detectionEngine.rules.allExceptions.filters.noListsBody',
{
Expand Down

0 comments on commit 2ba04b9

Please sign in to comment.