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

add uiFind icons, scroll to first match #367

Conversation

everett980
Copy link
Collaborator

@everett980 everett980 commented Apr 2, 2019

Which problem is this PR solving?

Short description of the changes

  • Moves the click handler to add a spanID to uiFind to a button next to the spanID
  • Adds a collapse and scroll to match button to TracePageSearchBar
  • Scrolls to first uiFind match when the TimelineView is mounted

Screenshots of visual changes:

Unfocused Find

Aside from the icon button changes, the uiFind input looks the same before focusing
image

Focused Find

Focusing the input results in it widening
image

Icon close up

New Icon is currently hovered to show distinction. Vertical borders have been removed.
image

Deep link icon

New deep link icon, with tooltip (and with safari's scrollbar rearing its head)
image

Focused button

Slight highlight indicates focus.
image

@ghost ghost assigned everett980 Apr 2, 2019
@ghost ghost added the review label Apr 2, 2019
Copy link
Collaborator Author

@everett980 everett980 left a comment

Choose a reason for hiding this comment

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

Very much WIP to discuss better approaches than the setTimeouts

@@ -158,6 +159,10 @@ export class VirtualizedTraceViewImpl extends React.PureComponent<VirtualizedTra
setTrace(trace, uiFind);
}

componentDidMount() {
setTimeout(this.props.scrollToFirstVisibleSpan);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without the setTimeout it scrolls to the bottom. I think the rows may not have height in the initial render.
@tiffon do you have any insight on why this would scroll too far without the setTimeout

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the constructor calls setTrace(...). When visiting the URL, directly, the setTrace(...) applies the find matching.

When coming from the search page the setTimeout has no effect; the find is already applied to the redux state via the reducer that changed the state to be viewing the trace.

So, seems like the rows are rendered but they're not collapsed, yet, when visiting a trace directly from a URL. Probably it's scrolling to the position of the row, but then the non-matching rows are collapsed and the target scroll position ends up getting truncated with the result of being scrolled to the bottom.

focusUiFind: () => {
if (trace.data) {
focusUiFind(trace.data, uiFind);
setTimeout(this._scrollManager.scrollToFirstVisibleSpan);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The scroll destination changes as a result of dispatching focusUiFind. This setTimeout achieves the desired result but definitely seems like the wrong way to achieve this.
@tiffon how would you recommend scrolling to the first match only after the rows have been expanded/collapsed and had their children shown/hidden?

Copy link
Member

Choose a reason for hiding this comment

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

That's a tough one, maybe via componentDidUpdate() with an instance property indicating whether or not the component should scroll.

Also, I recommend turning this into a method instead of creating a new function with every render.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately an instance property wouldn't work because the component that updates as a result of focusUiFind is not TracePage/index.tsx. I got around this by adding a property to the detailStates Map and childrenHiddenIDs Set made by calculateHiddenIdsAndDetailStates in TracePage/duck.tsx and reading that property in componentDidUpdate in TraceTimelineViewer/VirtualizedTraceView.tsx
It's slightly unorthodox in principle, but not so bad in practice.
Here is the commit that solely addresses setTimeout
TODO: more tests and icons

tiffon
tiffon previously requested changes Apr 4, 2019
Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

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

Looks great! Left a few comments.

Also, what do you think of this change to the aesthetics of the search bar? (The borders are removed and the icon is shifted to be the first button.)

Screen Shot 2019-04-04 at 1 22 49 AM

And, what do you think of this icon for the collapse-and-scroll?

Screen Shot 2019-04-04 at 12 51 11 AM

(Akin to the maps icon to center the map on your current location.)

Last, currently, the search bar elements have a max width which is getting kind of not long enough given how many buttons we're adding. What do you think of removing that and letting it flex-grow when it's in use? The trace-name will probably need to have flex: 0 0 auto, in that case.

focusUiFind: () => {
if (trace.data) {
focusUiFind(trace.data, uiFind);
setTimeout(this._scrollManager.scrollToFirstVisibleSpan);
Copy link
Member

Choose a reason for hiding this comment

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

That's a tough one, maybe via componentDidUpdate() with an instance property indicating whether or not the component should scroll.

Also, I recommend turning this into a method instead of creating a new function with every render.

@@ -158,6 +159,10 @@ export class VirtualizedTraceViewImpl extends React.PureComponent<VirtualizedTra
setTrace(trace, uiFind);
}

componentDidMount() {
setTimeout(this.props.scrollToFirstVisibleSpan);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the constructor calls setTrace(...). When visiting the URL, directly, the setTrace(...) applies the find matching.

When coming from the search page the setTimeout has no effect; the find is already applied to the redux state via the reducer that changed the state to be viewing the trace.

So, seems like the rows are rendered but they're not collapsed, yet, when visiting a trace directly from a URL. Probably it's scrolling to the position of the row, but then the non-matching rows are collapsed and the target scroll position ends up getting truncated with the result of being scrolled to the bottom.

TODO: Fix & add tests

Signed-off-by: Everett Ross <[email protected]>
tests, add TraceTimelineViewer/duck.tsx tests

Signed-off-by: Everett Ross <[email protected]>
@everett980 everett980 changed the title WIP - add uiFind icons, scroll to first match add uiFind icons, scroll to first match Apr 11, 2019
@codecov
Copy link

codecov bot commented Apr 11, 2019

Codecov Report

Merging #367 into master will increase coverage by 0.53%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #367      +/-   ##
==========================================
+ Coverage   88.12%   88.65%   +0.53%     
==========================================
  Files         157      157              
  Lines        3494     3518      +24     
  Branches      798      802       +4     
==========================================
+ Hits         3079     3119      +40     
+ Misses        378      364      -14     
+ Partials       37       35       -2
Impacted Files Coverage Δ
...components/TracePage/TraceTimelineViewer/index.tsx 100% <ø> (ø) ⬆️
...ents/TracePage/TracePageHeader/TracePageHeader.tsx 100% <100%> (+4.16%) ⬆️
...eger-ui/src/components/TracePage/ScrollManager.tsx 100% <100%> (+8.42%) ⬆️
.../components/TracePage/TraceTimelineViewer/duck.tsx 98.34% <100%> (+0.13%) ⬆️
...kages/jaeger-ui/src/components/common/CopyIcon.tsx 100% <100%> (ø) ⬆️
...ts/TracePage/TraceTimelineViewer/SpanDetailRow.tsx 100% <100%> (ø) ⬆️
...s/TracePage/TracePageHeader/TracePageSearchBar.tsx 100% <100%> (+12.5%) ⬆️
...ePage/TraceTimelineViewer/VirtualizedTraceView.tsx 92.37% <100%> (+3.28%) ⬆️
...kages/jaeger-ui/src/components/TracePage/index.tsx 100% <100%> (+2.27%) ⬆️
...TracePage/TraceTimelineViewer/SpanDetail/index.tsx 100% <100%> (ø) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe6c244...cdbdd9d. Read the comment docs.

@everett980 everett980 requested a review from tiffon April 15, 2019 19:55
@everett980 everett980 dismissed tiffon’s stale review April 15, 2019 19:56

Except for the possibility of removing Tween.tsx I believe all feedback has been addressed.

tiffon
tiffon previously requested changes Apr 20, 2019
Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

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

Great work. Left some comments, let me know what you think.

@everett980 everett980 dismissed tiffon’s stale review April 25, 2019 18:49

All changes have been implemented

@ghost ghost assigned tiffon Apr 26, 2019
Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

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

Looks great! Some minor comments. LMK if you want to talk about any of them.

width: 40%;
}

.TracePageSearchBar--InputGroup {
Copy link
Member

Choose a reason for hiding this comment

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

This should have an initial lowercase:

.TracePageSearchBar--inputGroup

Copy link
Member

Choose a reason for hiding this comment

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

Also, you can use the util class .ub-justify-end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice, updated
Where is the list of .ub- classes?

{/* style inline because compact overwrites the display */}
<Input.Group compact style={{ display: 'flex' }}>
<Input.Group className="TracePageSearchBar--InputGroup" compact style={{ display: 'flex' }}>
Copy link
Member

Choose a reason for hiding this comment

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

Please avoid using style unless the style is dynamic and needs to be calculated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's pre-existing. I can take a stab at fixing it though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The comment above the inline style seems to be accurate. I'm going to leave it as is.

@@ -69,6 +68,7 @@ export default function SpanDetail(props: SpanDetailProps) {
value: formatDuration(relativeStartTime),
},
];
const deepLinkCopyText = `${window.location.origin}${window.location.pathname}?uiFind=${spanID}`;
Copy link
Member

Choose a reason for hiding this comment

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

Why not just using location.origin, sans window?

Also, it's a bit strange having the magic string 'uiFind' in several places. I think this makes three. We can consolidate in a different PR.

Copy link
Collaborator Author

@everett980 everett980 May 2, 2019

Choose a reason for hiding this comment

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

I guess I'm just used to seeing window.location instead of location on its own, but location on its own works fine and is shorter so I updated.

I agree about consolidating uiFind in its own PR. Should that just be when uiFind is in a string? If so, this seems to be the only instance based on a quick search (ag --ts '['"'"'"`].+uiFind'). But I think it would make sense to be a constant whenever it is interacting with the URL (i.e.: here and when interacting with queryString.parse / queryString.stringify)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, eslint dislikes location but doesn't mind window.location. What is your preference on using window.location vs // eslint-disable-line no-restricted-globals

packages/jaeger-ui/src/components/TracePage/index.tsx Outdated Show resolved Hide resolved
packages/jaeger-ui/src/components/TracePage/index.test.js Outdated Show resolved Hide resolved
Copy link
Member

@tiffon tiffon left a comment

Choose a reason for hiding this comment

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

One quick question about focusing the find results from going back to the trace timeline view. Seems like that might be jarring?

@@ -280,6 +280,9 @@ export class TracePageImpl extends React.PureComponent<TProps, TState> {
if (this.props.trace && this.props.trace.data) {
this.traceDagEV = calculateTraceDagEV(this.props.trace.data);
}
if (traceGraphView) {
this.focusUiFindMatches();
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems kind of strange. So, it will focus the UI find matches when you go back to the timeline view?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought I had removed this... It doesn't work without more changes and as you said it may not be the desired functionality.
Will really remove and push.

@everett980 everett980 merged commit d18004f into jaegertracing:master May 3, 2019
@ghost ghost removed the review label May 3, 2019
vvvprabhakar pushed a commit to vvvprabhakar/jaeger-ui that referenced this pull request Jul 5, 2021
…0-improve-uiFind-interactions

add uiFind icons, scroll to first match
Signed-off-by: vvvprabhakar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants