-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SIEM] Fix link on overview page #60348
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
54cf075
Fix link on overview page
XavierM 3c1d9cc
no needs of useMemo
XavierM 6f000ef
clean up
XavierM 1378b84
review I
XavierM 6828519
review II
XavierM 68e8a97
review III
XavierM 31e7961
Merge branch 'master' of github.com:elastic/kibana into overview-link
XavierM 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
19 changes: 19 additions & 0 deletions
19
x-pack/legacy/plugins/siem/public/components/link_to/helpers.test.ts
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,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { appendSearch } from './helpers'; | ||
|
||
describe('appendSearch', () => { | ||
test('should return empty string if no parameter', () => { | ||
expect(appendSearch()).toEqual(''); | ||
}); | ||
test('should return empty string if parameter is undefined', () => { | ||
expect(appendSearch(undefined)).toEqual(''); | ||
}); | ||
test('should return parameter if parameter is defined', () => { | ||
expect(appendSearch('helloWorld')).toEqual('helloWorld'); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
x-pack/legacy/plugins/siem/public/components/link_to/helpers.ts
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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const appendSearch = (search?: string) => (search != null ? `${search}` : ''); |
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
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
20 changes: 20 additions & 0 deletions
20
x-pack/legacy/plugins/siem/public/components/navigation/use_get_url_search.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,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { isEqual } from 'lodash/fp'; | ||
import { useMemo } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { makeMapStateToProps } from '../url_state/helpers'; | ||
import { getSearch } from './helpers'; | ||
import { SearchNavTab } from './types'; | ||
|
||
export const useGetUrlSearch = (tab: SearchNavTab) => { | ||
const mapState = makeMapStateToProps(); | ||
const { urlState } = useSelector(mapState, isEqual); | ||
const urlSearch = useMemo(() => getSearch(tab, urlState), [tab, urlState]); | ||
return urlSearch; | ||
}; |
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
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 |
---|---|---|
|
@@ -19,12 +19,7 @@ import { TimelineUrl } from '../../store/timeline/model'; | |
import { formatDate } from '../super_date_picker'; | ||
import { NavTab } from '../navigation/types'; | ||
import { CONSTANTS, UrlStateType } from './constants'; | ||
import { | ||
LocationTypes, | ||
UrlStateContainerPropTypes, | ||
ReplaceStateInLocation, | ||
UpdateUrlStateString, | ||
} from './types'; | ||
import { ReplaceStateInLocation, UpdateUrlStateString } from './types'; | ||
|
||
export const decodeRisonUrlState = <T>(value: string | undefined): T | null => { | ||
try { | ||
|
@@ -113,42 +108,13 @@ export const getTitle = ( | |
return navTabs[pageName] != null ? navTabs[pageName].name : ''; | ||
}; | ||
|
||
export const getCurrentLocation = ( | ||
pageName: string, | ||
detailName: string | undefined | ||
): LocationTypes => { | ||
if (pageName === SiemPageName.overview) { | ||
return CONSTANTS.overviewPage; | ||
} else if (pageName === SiemPageName.hosts) { | ||
if (detailName != null) { | ||
return CONSTANTS.hostsDetails; | ||
} | ||
return CONSTANTS.hostsPage; | ||
} else if (pageName === SiemPageName.network) { | ||
if (detailName != null) { | ||
return CONSTANTS.networkDetails; | ||
} | ||
return CONSTANTS.networkPage; | ||
} else if (pageName === SiemPageName.detections) { | ||
return CONSTANTS.detectionsPage; | ||
} else if (pageName === SiemPageName.timelines) { | ||
return CONSTANTS.timelinePage; | ||
} else if (pageName === SiemPageName.case) { | ||
if (detailName != null) { | ||
return CONSTANTS.caseDetails; | ||
} | ||
return CONSTANTS.casePage; | ||
} | ||
return CONSTANTS.unknown; | ||
}; | ||
|
||
export const makeMapStateToProps = () => { | ||
const getInputsSelector = inputsSelectors.inputsSelector(); | ||
const getGlobalQuerySelector = inputsSelectors.globalQuerySelector(); | ||
const getGlobalFiltersQuerySelector = inputsSelectors.globalFiltersQuerySelector(); | ||
const getGlobalSavedQuerySelector = inputsSelectors.globalSavedQuerySelector(); | ||
const getTimelines = timelineSelectors.getTimelines(); | ||
const mapStateToProps = (state: State, { pageName, detailName }: UrlStateContainerPropTypes) => { | ||
const mapStateToProps = (state: State) => { | ||
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.
|
||
const inputState = getInputsSelector(state); | ||
const { linkTo: globalLinkTo, timerange: globalTimerange } = inputState.global; | ||
const { linkTo: timelineLinkTo, timerange: timelineTimerange } = inputState.timeline; | ||
|
Oops, something went wrong.
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.
FYI -> It was not used @stephmilovic told me and when I went in this files, I had to delete it ;)