[Resolver] no longer pass related event stats to process node component (#72435)
This commit is contained in:
parent
5741a868bc
commit
75e4c7a2b7
5 changed files with 20 additions and 53 deletions
|
@ -116,13 +116,14 @@ export const tree = createSelector(graphableProcesses, function indexedTree(
|
|||
*/
|
||||
export const relatedEventsStats: (
|
||||
state: DataState
|
||||
) => Map<string, ResolverNodeStats> | null = createSelector(
|
||||
) => (nodeID: string) => ResolverNodeStats | undefined = createSelector(
|
||||
resolverTreeResponse,
|
||||
(resolverTree?: ResolverTree) => {
|
||||
if (resolverTree) {
|
||||
return resolverTreeModel.relatedEventsStats(resolverTree);
|
||||
const map = resolverTreeModel.relatedEventsStats(resolverTree);
|
||||
return (nodeID: string) => map.get(nodeID);
|
||||
} else {
|
||||
return null;
|
||||
return () => undefined;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -213,12 +214,8 @@ export const relatedEventInfoByEntityId: (
|
|||
relatedEventsStats
|
||||
/* eslint-enable no-shadow */
|
||||
) {
|
||||
if (!relatedEventsStats) {
|
||||
// If there are no related event stats, there are no related event info objects
|
||||
return () => null;
|
||||
}
|
||||
return (entityId) => {
|
||||
const stats = relatedEventsStats.get(entityId);
|
||||
const stats = relatedEventsStats(entityId);
|
||||
if (!stats) {
|
||||
return null;
|
||||
}
|
||||
|
@ -524,37 +521,16 @@ export function databaseDocumentIDToAbort(state: DataState): string | null {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `ResolverNodeStats` for a process (`ResolverEvent`)
|
||||
*/
|
||||
const relatedEventStatsForProcess: (
|
||||
state: DataState
|
||||
) => (event: ResolverEvent) => ResolverNodeStats | null = createSelector(
|
||||
relatedEventsStats,
|
||||
(statsMap) => {
|
||||
if (!statsMap) {
|
||||
return () => null;
|
||||
}
|
||||
return (event: ResolverEvent) => {
|
||||
const nodeStats = statsMap.get(uniquePidForProcess(event));
|
||||
if (!nodeStats) {
|
||||
return null;
|
||||
}
|
||||
return nodeStats;
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* The sum of all related event categories for a process.
|
||||
*/
|
||||
export const relatedEventTotalForProcess: (
|
||||
state: DataState
|
||||
) => (event: ResolverEvent) => number | null = createSelector(
|
||||
relatedEventStatsForProcess,
|
||||
relatedEventsStats,
|
||||
(statsForProcess) => {
|
||||
return (event: ResolverEvent) => {
|
||||
const stats = statsForProcess(event);
|
||||
const stats = statsForProcess(uniquePidForProcess(event));
|
||||
if (!stats) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as dataSelectors from './data/selectors';
|
|||
import * as uiSelectors from './ui/selectors';
|
||||
import { ResolverState, IsometricTaxiLayout } from '../types';
|
||||
import { uniquePidForProcess } from '../models/process_event';
|
||||
import { ResolverEvent } from '../../../common/endpoint/types';
|
||||
import { ResolverEvent, ResolverNodeStats } from '../../../common/endpoint/types';
|
||||
|
||||
/**
|
||||
* A matrix that when applied to a Vector2 will convert it from world coordinates to screen coordinates.
|
||||
|
@ -99,7 +99,9 @@ export const terminatedProcesses = composeSelectors(
|
|||
/**
|
||||
* Returns a map of `ResolverEvent` entity_id to their related event and alert statistics
|
||||
*/
|
||||
export const relatedEventsStats = composeSelectors(
|
||||
export const relatedEventsStats: (
|
||||
state: ResolverState
|
||||
) => (nodeID: string) => ResolverNodeStats | undefined = composeSelectors(
|
||||
dataStateSelector,
|
||||
dataSelectors.relatedEventsStats
|
||||
);
|
||||
|
|
|
@ -60,7 +60,6 @@ export const ResolverMap = React.memo(function ({
|
|||
const { processNodePositions, connectingEdgeLineSegments } = useSelector(
|
||||
selectors.visibleNodesAndEdgeLines
|
||||
)(timeAtRender);
|
||||
const relatedEventsStats = useSelector(selectors.relatedEventsStats);
|
||||
const terminatedProcesses = useSelector(selectors.terminatedProcesses);
|
||||
const { projectionMatrix, ref, onMouseDown } = useCamera();
|
||||
const isLoading = useSelector(selectors.isLoading);
|
||||
|
@ -110,9 +109,6 @@ export const ResolverMap = React.memo(function ({
|
|||
position={position}
|
||||
projectionMatrix={projectionMatrix}
|
||||
event={processEvent}
|
||||
relatedEventsStatsForProcess={
|
||||
relatedEventsStats ? relatedEventsStats.get(entityId(processEvent)) : undefined
|
||||
}
|
||||
isProcessTerminated={terminatedProcesses.has(processEntityId)}
|
||||
isProcessOrigin={false}
|
||||
timeAtRender={timeAtRender}
|
||||
|
|
|
@ -99,8 +99,9 @@ const PanelContent = memo(function PanelContent() {
|
|||
|
||||
const relatedEventStats = useSelector(selectors.relatedEventsStats);
|
||||
const { crumbId, crumbEvent } = queryParams;
|
||||
const relatedStatsForIdFromParams: ResolverNodeStats | undefined =
|
||||
idFromParams && relatedEventStats ? relatedEventStats.get(idFromParams) : undefined;
|
||||
const relatedStatsForIdFromParams: ResolverNodeStats | undefined = idFromParams
|
||||
? relatedEventStats(idFromParams)
|
||||
: undefined;
|
||||
|
||||
/**
|
||||
* Determine which set of breadcrumbs to display based on the query parameters
|
||||
|
|
|
@ -14,7 +14,7 @@ import { NodeSubMenu, subMenuAssets } from './submenu';
|
|||
import { applyMatrix3 } from '../models/vector2';
|
||||
import { Vector2, Matrix3 } from '../types';
|
||||
import { SymbolIds, useResolverTheme, calculateResolverFontSize } from './assets';
|
||||
import { ResolverEvent, ResolverNodeStats } from '../../../common/endpoint/types';
|
||||
import { ResolverEvent } from '../../../common/endpoint/types';
|
||||
import { useResolverDispatch } from './use_resolver_dispatch';
|
||||
import * as eventModel from '../../../common/endpoint/models/event';
|
||||
import * as processEventModel from '../models/process_event';
|
||||
|
@ -73,7 +73,6 @@ const UnstyledProcessEventDot = React.memo(
|
|||
projectionMatrix,
|
||||
isProcessTerminated,
|
||||
isProcessOrigin,
|
||||
relatedEventsStatsForProcess,
|
||||
timeAtRender,
|
||||
}: {
|
||||
/**
|
||||
|
@ -100,12 +99,6 @@ const UnstyledProcessEventDot = React.memo(
|
|||
* Whether or not to show the process as the originating event.
|
||||
*/
|
||||
isProcessOrigin: boolean;
|
||||
/**
|
||||
* A collection of events related to the current node and statistics (e.g. counts indexed by event type)
|
||||
* to provide the user some visibility regarding the contents thereof.
|
||||
* Statistics for the number of related events and alerts for this process node
|
||||
*/
|
||||
relatedEventsStatsForProcess?: ResolverNodeStats;
|
||||
|
||||
/**
|
||||
* The time (unix epoch) at render.
|
||||
|
@ -127,6 +120,7 @@ const UnstyledProcessEventDot = React.memo(
|
|||
const activeDescendantId = useSelector(selectors.uiActiveDescendantId);
|
||||
const selectedDescendantId = useSelector(selectors.uiSelectedDescendantId);
|
||||
const nodeID = processEventModel.uniquePidForProcess(event);
|
||||
const relatedEventStats = useSelector(selectors.relatedEventsStats)(nodeID);
|
||||
|
||||
// define a standard way of giving HTML IDs to nodes based on their entity_id/nodeID.
|
||||
// this is used to link nodes via aria attributes
|
||||
|
@ -270,15 +264,13 @@ const UnstyledProcessEventDot = React.memo(
|
|||
const relatedEventOptions = useMemo(() => {
|
||||
const relatedStatsList = [];
|
||||
|
||||
if (!relatedEventsStatsForProcess) {
|
||||
if (!relatedEventStats) {
|
||||
// Return an empty set of options if there are no stats to report
|
||||
return [];
|
||||
}
|
||||
// If we have entries to show, map them into options to display in the selectable list
|
||||
|
||||
for (const [category, total] of Object.entries(
|
||||
relatedEventsStatsForProcess.events.byCategory
|
||||
)) {
|
||||
for (const [category, total] of Object.entries(relatedEventStats.events.byCategory)) {
|
||||
relatedStatsList.push({
|
||||
prefix: <EuiI18nNumber value={total || 0} />,
|
||||
optionTitle: category,
|
||||
|
@ -296,9 +288,9 @@ const UnstyledProcessEventDot = React.memo(
|
|||
});
|
||||
}
|
||||
return relatedStatsList;
|
||||
}, [relatedEventsStatsForProcess, dispatch, event, pushToQueryParams, nodeID]);
|
||||
}, [relatedEventStats, dispatch, event, pushToQueryParams, nodeID]);
|
||||
|
||||
const relatedEventStatusOrOptions = !relatedEventsStatsForProcess
|
||||
const relatedEventStatusOrOptions = !relatedEventStats
|
||||
? subMenuAssets.initialMenuStatus
|
||||
: relatedEventOptions;
|
||||
|
||||
|
|
Loading…
Reference in a new issue