mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.13] [SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448) (#177553)
# Backport This will backport the following commits from `main` to `8.13`: - [[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448)](https://github.com/elastic/kibana/pull/177448) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Pablo Machado","email":"pablo.nevesmachado@elastic.co"},"sourceCommit":{"committedDate":"2024-02-22T08:35:08Z","message":"[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448)\n\n## Summary\r\n\r\nAdd a new property to the `LensVisualization` that prevents the table\r\nand tab filters from being applied.\r\n\r\n### BEFORE\r\n<img\r\nsrc=\"e13deb8f
-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\" />\r\n\r\n### AFTER\r\n<img\r\nsrc=\"ad12325d
-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\" />\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the host's page / Events\r\n* The risk score visualization should not be filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v8.13.0","v8.14.0"],"title":"[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score","number":177448,"url":"https://github.com/elastic/kibana/pull/177448","mergeCommit":{"message":"[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448)\n\n## Summary\r\n\r\nAdd a new property to the `LensVisualization` that prevents the table\r\nand tab filters from being applied.\r\n\r\n### BEFORE\r\n<img\r\nsrc=\"e13deb8f
-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\" />\r\n\r\n### AFTER\r\n<img\r\nsrc=\"ad12325d
-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\" />\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the host's page / Events\r\n* The risk score visualization should not be filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/177448","number":177448,"mergeCommit":{"message":"[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448)\n\n## Summary\r\n\r\nAdd a new property to the `LensVisualization` that prevents the table\r\nand tab filters from being applied.\r\n\r\n### BEFORE\r\n<img\r\nsrc=\"e13deb8f
-d023-404d-9cea-e749b8ee2694\"\r\nwidth=\"500\" />\r\n\r\n### AFTER\r\n<img\r\nsrc=\"ad12325d
-fe4f-40cd-83a8-45d755707061\"\r\nwidth=\"500\" />\r\n\r\n\r\n### How to test it?\r\n* Open the User flyout on the host's page / Events\r\n* The risk score visualization should not be filtered by *exists\r\nhost.name\"\r\n\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n\r\n- [X] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"45ce4c3f3111dd07ed51d6f62d9b1d77887ada34"}}]}] BACKPORT--> Co-authored-by: Pablo Machado <pablo.nevesmachado@elastic.co>
This commit is contained in:
parent
f91e5cb22d
commit
59467419cc
5 changed files with 34 additions and 2 deletions
|
@ -63,6 +63,7 @@ const LensComponentWrapper = styled.div<{
|
|||
|
||||
const LensEmbeddableComponent: React.FC<LensEmbeddableComponentProps> = ({
|
||||
applyGlobalQueriesAndFilters = true,
|
||||
applyPageAndTabsFilters = true,
|
||||
extraActions,
|
||||
extraOptions,
|
||||
getLensAttributes,
|
||||
|
@ -99,6 +100,7 @@ const LensEmbeddableComponent: React.FC<LensEmbeddableComponentProps> = ({
|
|||
const { searchSessionId } = useVisualizationResponse({ visualizationId: id });
|
||||
const attributes = useLensAttributes({
|
||||
applyGlobalQueriesAndFilters,
|
||||
applyPageAndTabsFilters,
|
||||
extraOptions,
|
||||
getLensAttributes,
|
||||
lensAttributes,
|
||||
|
|
|
@ -28,6 +28,7 @@ export type GetLensAttributes = (
|
|||
|
||||
export interface UseLensAttributesProps {
|
||||
applyGlobalQueriesAndFilters?: boolean;
|
||||
applyPageAndTabsFilters?: boolean;
|
||||
extraOptions?: ExtraOptions;
|
||||
getLensAttributes?: GetLensAttributes;
|
||||
lensAttributes?: LensAttributes | null;
|
||||
|
@ -83,6 +84,7 @@ export enum VisualizationContextMenuDefaultActionName {
|
|||
|
||||
export interface LensEmbeddableComponentProps {
|
||||
applyGlobalQueriesAndFilters?: boolean;
|
||||
applyPageAndTabsFilters?: boolean;
|
||||
extraActions?: Action[];
|
||||
extraOptions?: ExtraOptions;
|
||||
getLensAttributes?: GetLensAttributes;
|
||||
|
|
|
@ -153,6 +153,31 @@ describe('useLensAttributes', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('should not apply tabs and pages when applyPageAndTabsFilters = false', () => {
|
||||
(useRouteSpy as jest.Mock).mockReturnValue([
|
||||
{
|
||||
detailName: 'elastic',
|
||||
pageName: 'user',
|
||||
tabName: 'events',
|
||||
},
|
||||
]);
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
useLensAttributes({
|
||||
applyPageAndTabsFilters: false,
|
||||
getLensAttributes: getExternalAlertLensAttributes,
|
||||
stackByField: 'event.dataset',
|
||||
}),
|
||||
{ wrapper }
|
||||
);
|
||||
|
||||
expect(result?.current?.state.filters).toEqual([
|
||||
...getExternalAlertLensAttributes().state.filters,
|
||||
...getIndexFilters(['auditbeat-*']),
|
||||
...filterFromSearchBar,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should add data view id to references', () => {
|
||||
const { result } = renderHook(
|
||||
() =>
|
||||
|
|
|
@ -24,6 +24,7 @@ import {
|
|||
|
||||
export const useLensAttributes = ({
|
||||
applyGlobalQueriesAndFilters = true,
|
||||
applyPageAndTabsFilters = true,
|
||||
extraOptions,
|
||||
getLensAttributes,
|
||||
lensAttributes,
|
||||
|
@ -95,8 +96,8 @@ export const useLensAttributes = ({
|
|||
...(applyGlobalQueriesAndFilters ? { query } : {}),
|
||||
filters: [
|
||||
...attrs.state.filters,
|
||||
...pageFilters,
|
||||
...tabsFilters,
|
||||
...(applyPageAndTabsFilters ? pageFilters : []),
|
||||
...(applyPageAndTabsFilters ? tabsFilters : []),
|
||||
...indexFilters,
|
||||
...(applyGlobalQueriesAndFilters ? filters : []),
|
||||
],
|
||||
|
@ -108,6 +109,7 @@ export const useLensAttributes = ({
|
|||
} as LensAttributes;
|
||||
}, [
|
||||
applyGlobalQueriesAndFilters,
|
||||
applyPageAndTabsFilters,
|
||||
attrs,
|
||||
dataViewId,
|
||||
filters,
|
||||
|
|
|
@ -210,6 +210,7 @@ const RiskSummaryComponent = <T extends RiskScoreEntity>({
|
|||
{riskData && (
|
||||
<VisualizationEmbeddable
|
||||
applyGlobalQueriesAndFilters={false}
|
||||
applyPageAndTabsFilters={false}
|
||||
lensAttributes={lensAttributes}
|
||||
id={`RiskSummary-risk_score_metric`}
|
||||
timerange={timerange}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue