Skip to content
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

[Resolver] aria-level and aria-flowto support enhancements #71777

Closed
wants to merge 12 commits into from

Conversation

oatkiller
Copy link
Contributor

@oatkiller oatkiller commented Jul 14, 2020

Summary

  • IndexedProcessTree now owns the concern of defining the order of siblings
  • IsometricTaxiLayout now owns the concept of ariaLevels
  • added datetime method to process_event model which returns a time in ms since unix epoch for the event
  • renamed some resolver selectors
  • added resolver selector: ariaLevel
  • added 'data' selector: followingSibling (used for aria-flowto)
  • added resolver selector ariaFlowtoNodeID which takes a nodeID, and returns its following sibling's node id (if that sibling is visible.) By only returning visible siblings, we ensure that aria-flowto will point to an html ID that is in the dom.

image

Checklist

For maintainers

@oatkiller oatkiller requested review from a team as code owners July 14, 2020 21:51
@oatkiller oatkiller added release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels Jul 14, 2020
@oatkiller oatkiller changed the title Resolver traverse levels [Resolver] aria-level and aria-flowto support Jul 14, 2020
@oatkiller oatkiller changed the title [Resolver] aria-level and aria-flowto support [Resolver] aria-level and aria-flowto support enhancements Jul 14, 2020
};
}
);
export const nodesAndEdgelines: (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

/* eslint-enable no-shadow */
) {
return (time: number) => indexedProcessNodesAndEdgeLineSegments(boundingBox(time));
export const visibleNodesAndEdgeLines = createSelector(nodesAndEdgelines, boundingBox, function (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

relatedEventsStatsForProcess={
relatedEventsStats ? relatedEventsStats.get(entityId(processEvent)) : undefined
}
isProcessTerminated={terminatedProcesses.has(processEntityId)}
isProcessOrigin={false}
timeAtRender={timeAtRender}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when timestamp is used to get the state of things during a (possible) animation, we should use the same value for all calls in the frame (regardless of how much time has passed.) this is a hacky way to get around the issue. we should file a ticket for it.

}) => {
// This should be unique to each instance of Resolver
const htmlIDPrefix = 'resolver';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kqualters-elastic we need use the documentLocationID here. that way we can have unique IDs.

const activeDescendantId = useSelector(selectors.uiActiveDescendantId);
const selectedDescendantId = useSelector(selectors.uiSelectedDescendantId);
const nodeID = processEventModel.uniquePidForProcess(event);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slowly changing things over to use a string, which i'm calling nodeID, to define nodes.
process events aren't good because several process events could define a node (start event, terminate event, already running event, different events from other vendors.) also, strings are interned and primitives which is nice

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(animationTarget.current as any).beginElement();
}
dispatch({
type: 'userSelectedResolverNode',
payload: {
nodeId,
selectedProcessId: selfId,
nodeId: nodeHTMLID(nodeID),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be able to pass just the nodeID. the HTML id can be calculated from that.

fill={isLabelFilled}
id={labelId}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same id and data-test-subj were being used for this button and its parent. the data-test-subj wasn't being used anyway.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

for (const treeRoot of roots) {
traverseLevels(idToAdjacent.get(uniquePidForProcess(treeRoot))!);
// if either value is NaN, compare them differently
if (isNaN(first)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why would these ever be NaN or is this a "should never happen" scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datetime tries to parse a Date from @timestamp (or somewhere else for legacy events.)
It then returns the getTime from that Date. If a date is 'Invalid Date', then getTime will return NaN.

maybe i should check for NaN in the body of datetime and return null instead.

@oatkiller oatkiller closed this Jul 15, 2020
@oatkiller oatkiller reopened this Jul 15, 2020
@@ -32,9 +32,9 @@ export function eventName(event: ResolverEvent): string {
}
}

export function eventId(event: ResolverEvent): string {
export function eventId(event: ResolverEvent): number | undefined | string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-buttner this function was converting the serial event id to a string. if it was undefined or 0 it was being converted to ''. i don't know the reasoning, but i undid it. some BE code was effected. let me know if this is OK

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkimmel or @kqualters-elastic may have thoughts here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine I left some comments about checking for undefined and not displaying the string 'undefined'.

@@ -32,10 +32,13 @@ export function isTerminatedProcess(passedEvent: ResolverEvent) {
* ms since unix epoc, based on timestamp.
* may return NaN if the timestamp wasn't present or was invalid.
*/
export function datetime(passedEvent: ResolverEvent): number {
export function datetime(passedEvent: ResolverEvent): number | null {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelolo24 when the value isn't defined or can't be parsed this now returns null.

/**
* used to sort events
*/
export function orderByTime(first: ResolverEvent, second: ResolverEvent): number {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathan-buttner this now does a tie breaker with an arbitrary comparison of event ID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks!

@@ -214,9 +214,9 @@ export const ProcessEventListNarrowedByType = memo(function ProcessEventListNarr
eventCategory: `${eventType}`,
eventType: `${event.ecsEventType(resolverEvent)}`,
name: event.descriptiveName(resolverEvent),
entityId,
entityId: String(entityId),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior here is changed. Before, if the event was a legacy event and the id was undefined or 0this would be ''. Now it will be '0' or 'undefined'. I'm not sure that either behavior is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's undefined I wonder if we should mark it as an empty string here. I would think '0' would be fine if that is what was sent by the sensor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm also the field name here is a bit misleading, we're setting entityId with eventId. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went to track down what its used for. its not used. removing it.

@@ -61,7 +61,7 @@ export class PaginationBuilder {
const lastResult = results[results.length - 1];
const cursor = {
timestamp: lastResult['@timestamp'],
eventID: eventId(lastResult),
eventID: String(eventId(lastResult)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior here is changed. Before, if the event was a legacy event and the id was undefined or 0this would be ''. Now it will be '0' or 'undefined'. I'm not sure that either behavior is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for point this out. I think we'll want to check if it is undefined and set it to an empty string here. If 0 is returned we'll likely want to keep it as 0 because I think that's a valid value for the legacy events.

@oatkiller
Copy link
Contributor Author

github isn't recognizing my pushes unless i close and open?

@oatkiller oatkiller closed this Jul 15, 2020
@oatkiller oatkiller mentioned this pull request Jul 15, 2020
2 tasks
@oatkiller
Copy link
Contributor Author

closing in favor of this: #71887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants