-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security solution][Endpoint] Add back button when to the event filters list #101280
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
Merged
dasansol92
merged 4 commits into
elastic:master
from
dasansol92:fix/olm-no_back_button_from_the_event_filters_tab_to_the_integration_tab-101264
Jun 9, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2464de0
Add back button when to the event filters list. Isolated back to exte…
dasansol92 983fff7
Adds unit tests for back button
dasansol92 5d80975
Merge branch 'master' into fix/olm-no_back_button_from_the_event_filt…
kibanamachine 68e52ac
Merge branch 'master' into fix/olm-no_back_button_from_the_event_filt…
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
.../public/management/components/back_to_external_app_button/back_to_external_app_button.tsx
This file contains hidden or 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,52 @@ | ||
| /* | ||
| * 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, { memo } from 'react'; | ||
|
|
||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { EuiButtonEmpty } from '@elastic/eui'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| import { ListPageRouteState } from '../../../../common/endpoint/types'; | ||
|
|
||
| import { useNavigateToAppEventHandler } from '../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; | ||
|
|
||
| const EuiButtonEmptyStyled = styled(EuiButtonEmpty)` | ||
| margin-bottom: ${({ theme }) => theme.eui.euiSizeS}; | ||
|
|
||
| .euiIcon { | ||
| width: ${({ theme }) => theme.eui.euiIconSizes.small}; | ||
| height: ${({ theme }) => theme.eui.euiIconSizes.small}; | ||
| } | ||
|
|
||
| .text { | ||
| font-size: ${({ theme }) => theme.eui.euiFontSizeXS}; | ||
| } | ||
| `; | ||
|
|
||
| export const BackToExternalAppButton = memo<ListPageRouteState>( | ||
| ({ backButtonLabel, backButtonUrl, onBackButtonNavigateTo }) => { | ||
| const handleBackOnClick = useNavigateToAppEventHandler(...onBackButtonNavigateTo!); | ||
|
|
||
| return ( | ||
| <EuiButtonEmptyStyled | ||
| flush="left" | ||
| size="xs" | ||
| iconType="arrowLeft" | ||
| href={backButtonUrl!} | ||
| onClick={handleBackOnClick} | ||
| textProps={{ className: 'text' }} | ||
| data-test-subj="backToOrigin" | ||
| > | ||
| {backButtonLabel || ( | ||
| <FormattedMessage id="xpack.securitySolution.list.backButton" defaultMessage="Back" /> | ||
| )} | ||
| </EuiButtonEmptyStyled> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| BackToExternalAppButton.displayName = 'BackToExternalAppButton'; |
8 changes: 8 additions & 0 deletions
8
...ugins/security_solution/public/management/components/back_to_external_app_button/index.ts
This file contains hidden or 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,8 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export { BackToExternalAppButton } from './back_to_external_app_button'; |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,10 +5,10 @@ | |
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { memo, useCallback, useEffect } from 'react'; | ||
| import React, { memo, useCallback, useMemo, useEffect } from 'react'; | ||
| import { useDispatch } from 'react-redux'; | ||
| import { Dispatch } from 'redux'; | ||
| import { useHistory } from 'react-router-dom'; | ||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { FormattedMessage } from '@kbn/i18n/react'; | ||
| import { EuiButton, EuiSpacer, EuiHorizontalRule, EuiText } from '@elastic/eui'; | ||
|
|
@@ -34,14 +34,15 @@ import { | |
| showDeleteModal, | ||
| } from '../store/selector'; | ||
| import { PaginatedContent, PaginatedContentProps } from '../../../components/paginated_content'; | ||
| import { Immutable } from '../../../../../common/endpoint/types'; | ||
| import { Immutable, ListPageRouteState } from '../../../../../common/endpoint/types'; | ||
| import { | ||
| ExceptionItem, | ||
| ExceptionItemProps, | ||
| } from '../../../../common/components/exceptions/viewer/exception_item'; | ||
| import { EventFilterDeleteModal } from './components/event_filter_delete_modal'; | ||
|
|
||
| import { SearchBar } from '../../../components/search_bar'; | ||
| import { BackToExternalAppButton } from '../../../components/back_to_external_app_button'; | ||
|
|
||
| type EventListPaginatedContent = PaginatedContentProps< | ||
| Immutable<ExceptionListItemSchema>, | ||
|
|
@@ -59,6 +60,7 @@ const AdministrationListPage = styled(_AdministrationListPage)` | |
| `; | ||
|
|
||
| export const EventFiltersListPage = memo(() => { | ||
| const { state: routeState } = useLocation<ListPageRouteState | undefined>(); | ||
| const history = useHistory(); | ||
| const dispatch = useDispatch<Dispatch<AppAction>>(); | ||
| const isActionError = useEventFiltersSelector(getActionError); | ||
|
|
@@ -103,6 +105,13 @@ export const EventFiltersListPage = memo(() => { | |
| } | ||
| }, [dispatch, formEntry, history, isActionError, location, navigateCallback]); | ||
|
|
||
| const backButton = useMemo(() => { | ||
| if (routeState && routeState.onBackButtonNavigateTo) { | ||
| return <BackToExternalAppButton {...routeState} />; | ||
| } | ||
| return null; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: does headerComponent expect a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's an optional component, so null works in this case |
||
| }, [routeState]); | ||
|
|
||
| const handleAddButtonClick = useCallback( | ||
| () => | ||
| navigateCallback({ | ||
|
|
@@ -173,6 +182,7 @@ export const EventFiltersListPage = memo(() => { | |
| return ( | ||
| <AdministrationListPage | ||
| beta={false} | ||
| headerBackComponent={backButton} | ||
| title={ | ||
| <FormattedMessage | ||
| id="xpack.securitySolution.eventFilters.list.pageTitle" | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Maybe just call this
Back buttonsince now it looks similar to the test description name below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this before having more
out of datecheck errors and will do this change in next pr :)