-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] User can add new event filter from event filter list #98118
Changes from all commits
a48ec3b
2fe9ee3
7aef7c9
dd7e246
b757731
95d0031
74f9c91
3836333
5b3e7e5
686f61c
46dcdcb
9eec29c
4606ad7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import { AdministrationSubTab } from '../types'; | |
import { appendSearch } from '../../common/components/link_to/helpers'; | ||
import { EndpointIndexUIQueryParams } from '../pages/endpoint_hosts/types'; | ||
import { TrustedAppsListPageLocation } from '../pages/trusted_apps/state'; | ||
import { EventFiltersPageLocation } from '../pages/event_filters/state'; | ||
import { EventFiltersListPageUrlSearchParams } from '../pages/event_filters/types'; | ||
|
||
// Taken from: https://github.com/microsoft/TypeScript/issues/12936#issuecomment-559034150 | ||
|
@@ -118,6 +119,26 @@ const normalizeTrustedAppsPageLocation = ( | |
} | ||
}; | ||
|
||
const normalizeEventFiltersPageLocation = ( | ||
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. 💡 I wonder if we can create a generic utility that could work for any use case in parsing/normalizing url params, so that we did not have to keep cloning this code. maybe a utility that takes in the |
||
location?: Partial<EventFiltersPageLocation> | ||
): Partial<EventFiltersPageLocation> => { | ||
if (location) { | ||
return { | ||
...(!isDefaultOrMissing(location.page_index, MANAGEMENT_DEFAULT_PAGE) | ||
? { page_index: location.page_index } | ||
: {}), | ||
...(!isDefaultOrMissing(location.page_size, MANAGEMENT_DEFAULT_PAGE_SIZE) | ||
? { page_size: location.page_size } | ||
: {}), | ||
...(!isDefaultOrMissing(location.show, undefined) ? { show: location.show } : {}), | ||
...(!isDefaultOrMissing(location.id, undefined) ? { id: location.id } : {}), | ||
...(!isDefaultOrMissing(location.filter, '') ? { filter: location.filter } : ''), | ||
}; | ||
} else { | ||
return {}; | ||
} | ||
}; | ||
|
||
/** | ||
* Given an object with url params, and a given key, return back only the first param value (case multiples were defined) | ||
* @param query | ||
|
@@ -181,12 +202,27 @@ export const getTrustedAppsListPath = (location?: Partial<TrustedAppsListPageLoc | |
)}`; | ||
}; | ||
|
||
export const extractEventFiltetrsPageLocation = ( | ||
query: querystring.ParsedUrlQuery | ||
): EventFiltersPageLocation => { | ||
const showParamValue = extractFirstParamValue(query, 'show') as EventFiltersPageLocation['show']; | ||
|
||
return { | ||
...extractListPaginationParams(query), | ||
show: | ||
showParamValue && ['edit', 'create'].includes(showParamValue) ? showParamValue : undefined, | ||
id: extractFirstParamValue(query, 'id'), | ||
}; | ||
}; | ||
|
||
export const getEventFiltersListPath = ( | ||
location?: Partial<EventFiltersListPageUrlSearchParams> | ||
): string => { | ||
const path = generatePath(MANAGEMENT_ROUTING_EVENT_FILTERS_PATH, { | ||
tabName: AdministrationSubTab.eventFilters, | ||
}); | ||
|
||
return `${path}${appendSearch(querystring.stringify(location))}`; | ||
return `${path}${appendSearch( | ||
querystring.stringify(normalizeEventFiltersPageLocation(location)) | ||
)}`; | ||
}; |
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.
thanks for fixing this!