mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[SecuritySolution] Fix Entity risk score visualization displays 'N/A' instead of score (#177448)
## Summary Add a new property to the `LensVisualization` that prevents the table and tab filters from being applied. ### BEFORE <img src="e13deb8f
-d023-404d-9cea-e749b8ee2694" width="500" /> ### AFTER <img src="ad12325d
-fe4f-40cd-83a8-45d755707061" width="500" /> ### How to test it? * Open the User flyout on the host's page / Events * The risk score visualization should not be filtered by *exists host.name" ### Checklist Delete any items that are not applicable to this PR. - [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
This commit is contained in:
parent
f89bc8f4c6
commit
45ce4c3f31
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