forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Detections] Update rules count indicator in the R…
…ules table to show pagination info (elastic#138902) **Fixes:** elastic#121754 ## Summary Changes rules count pagination count to format: **"Showing 1-10 of 596 rules"** -> when page 1, rules per page is 10 and total rules is 596 **"Showing 6-6 of 6 rules"** -> when page 2, rules per page is 5 and total rules is 6 See other cases in tests. **Before changes** ![image](https://user-images.githubusercontent.com/5354282/184883106-118f0041-5567-4cf8-bfd5-8383e8146018.png) ![image](https://user-images.githubusercontent.com/5354282/184884145-22d30482-cc2d-4796-8f84-d809a8ca6d8a.png) **After changes** ![image](https://user-images.githubusercontent.com/5354282/184882149-d6c55dff-39a0-4a72-94a9-217b2e5ca7ac.png) ![image](https://user-images.githubusercontent.com/5354282/184886334-a107a2c5-31dc-4a7b-9e70-54c87c1630e0.png) ## Codebase changes - Refactors `AllRulesUtilityBar` component to separate usage of the utility bar between the all-rules table use-case and the Exceptions table use-case, by creating a new `ExceptionsTableUtilityBar` component. ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
13 changed files
with
334 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ections/pages/detection_engine/rules/all/exceptions/exceptions_table_utility_bar.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { TestProviders } from '../../../../../../common/mock'; | ||
import { render, screen, within } from '@testing-library/react'; | ||
import { ExceptionsTableUtilityBar } from './exceptions_table_utility_bar'; | ||
|
||
describe('ExceptionsTableUtilityBar', () => { | ||
it('displays correct exception lists label and refresh rules action button', () => { | ||
const EXCEPTION_LISTS_NUMBER = 25; | ||
render( | ||
<TestProviders> | ||
<ExceptionsTableUtilityBar | ||
onRefresh={jest.fn()} | ||
totalExceptionLists={EXCEPTION_LISTS_NUMBER} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('showingExceptionLists')).toBeInTheDocument(); | ||
expect(screen.getByTestId('refreshRulesAction')).toBeInTheDocument(); | ||
expect(screen.getByText(`Showing ${EXCEPTION_LISTS_NUMBER} lists`)).toBeInTheDocument(); | ||
}); | ||
|
||
it('invokes refresh on refresh action click', () => { | ||
const mockRefresh = jest.fn(); | ||
render( | ||
<TestProviders> | ||
<ExceptionsTableUtilityBar onRefresh={mockRefresh} totalExceptionLists={1} /> | ||
</TestProviders> | ||
); | ||
|
||
const buttonWrapper = screen.getByTestId('refreshRulesAction'); | ||
within(buttonWrapper).getByRole('button').click(); | ||
|
||
expect(mockRefresh).toHaveBeenCalled(); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
...c/detections/pages/detection_engine/rules/all/exceptions/exceptions_table_utility_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { | ||
UtilityBar, | ||
UtilityBarAction, | ||
UtilityBarGroup, | ||
UtilityBarSection, | ||
UtilityBarText, | ||
} from '../../../../../../common/components/utility_bar'; | ||
import * as i18n from './translations'; | ||
|
||
interface ExceptionsTableUtilityBarProps { | ||
onRefresh?: () => void; | ||
totalExceptionLists: number; | ||
} | ||
|
||
export const ExceptionsTableUtilityBar: React.FC<ExceptionsTableUtilityBarProps> = ({ | ||
onRefresh, | ||
totalExceptionLists, | ||
}) => { | ||
return ( | ||
<UtilityBar border> | ||
<UtilityBarSection> | ||
<UtilityBarGroup> | ||
<UtilityBarText dataTestSubj="showingExceptionLists"> | ||
{i18n.SHOWING_EXCEPTION_LISTS(totalExceptionLists)} | ||
</UtilityBarText> | ||
</UtilityBarGroup> | ||
<UtilityBarGroup> | ||
<UtilityBarAction | ||
dataTestSubj="refreshRulesAction" | ||
iconSide="left" | ||
iconType="refresh" | ||
onClick={onRefresh} | ||
> | ||
{i18n.REFRESH_EXCEPTIONS_TABLE} | ||
</UtilityBarAction> | ||
</UtilityBarGroup> | ||
</UtilityBarSection> | ||
</UtilityBar> | ||
); | ||
}; | ||
|
||
ExceptionsTableUtilityBar.displayName = 'ExceptionsTableUtilityBar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.