-
Notifications
You must be signed in to change notification settings - Fork 621
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
feat(frontend): sync search in comparison view #661
Conversation
reference #286 |
Codecov Report
@@ Coverage Diff @@
## main #661 +/- ##
==========================================
- Coverage 77.08% 76.34% -0.73%
==========================================
Files 59 60 +1
Lines 2037 2109 +72
Branches 366 391 +25
==========================================
+ Hits 1570 1610 +40
- Misses 439 471 +32
Partials 28 28
Continue to review full report at Codecov.
|
/create-server |
/create-server |
Reposting thoughts regarding tests to get input from others: Here there are two issues I think:
So here there is a space between each ternary. so even when the ternaries return For the other part It looks from this PR like you added cc/ @eh-am |
extra space at the end in
I did some refactoring but extra space is still there unless I do some more string manipulation. Instead, is it possible to update the snapshot so it matches the latest test result?
correct, I refactored the code to use data-testid for linked search test case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, that's pretty cool! I have a few comments:
Maybe it's just me, but I found a bit weird how removing the link also deletes the search. For comparison, in grafana, when you unsync 2 time ranges, they continue the same, just unlinked.
Functionality is missing on the Adhoc Comparison page.
How is the button going to work when we add a button to clear the search, like ?
I would love to see some unit tests here!
The button is missing a hover cursor.
}; | ||
const toggleLinkedSearch = (side) => { | ||
const { isSearchLinked } = linkedSearch; | ||
if (isSearchLinked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we return early here if isSearchLinked
is false? The nesting here doesn't add much value IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
const toggleLinkedSearch = (side) => { | ||
const { isSearchLinked } = linkedSearch; | ||
if (isSearchLinked) { | ||
if (side === 'left') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use switch/case
here? This file isn't using typescript yet, but in the future we can update it to use exhaustive case checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus these cases are pretty similar, so we can just build an args
parameter and then declaratively use it?
Eg
let args;
if (side === 'right') {
args = { resetLinkedSearchSide: 'left' }
}
if (side === 'both') {
args = { sSearchLinked: false, resetLinkedSearchSide: '' }
}
(...)
setLinkedSearch((x) => {
return { ...x, ...args };
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think having all this logic here bloats this file. These files (Coparison, SingleView, ComparisonDiff) are the entrypoints for our pages, ie the first or second thing people should read to understand what the page is about. Having this logic makes it harder for people to understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eh-am where would you put this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use switch/case here
declarative way
done.
isSearchLinked={linkedSearch.isSearchLinked} | ||
setSearchQuery={setSearchQuery} | ||
linkedSearchQuery={linkedSearch.linkedSearchQuery} | ||
toggleLinkedSearch={toggleLinkedSearch} | ||
resetLinkedSearchSide={linkedSearch.resetLinkedSearchSide} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is case where lifting state up makes the parent component too bloated. I think you can infer based on the toolbar viewType
whether to show the link, and then dispatch a redux action to enable/disable the link functionality.
isSearchLinked === true ? styles.active : '' | ||
}`} | ||
> | ||
<svg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn' there a fontAwesome version of this? Example https://github.com/pyroscope-io/pyroscope/blob/main/stories/Button.stories.tsx#L26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. Found one matching link icon (solid though) https://fontawesome.com/v5.15/icons?d=gallery&p=2&q=link
title={`${ | ||
isSearchLinked === true ? 'Unsync search term' : 'Sync search term' | ||
}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of using titles for this cases, but I guess until we have proper tooltip support this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. we can replace title once we have a generic tooltip.
Is this different from |
|
You have to run the server with Then it will be enabled in the sidebar ->
Sorry, I don't see it, am I missing something? But anyway, that answers my question, it will be inside the input, so it will still look good!
That's a e2e/integration test. For that I would simply 1 - Type the search 2 - Click the link button 3 - Check if the query was copied to the other field. Now for adding the unit tests, it depends how the code is organized. You can try putting 2 toolbars side by side and seeing if the sync works. Or if that's too difficult, to put 2 flamegraphs side by side. The advantage of unit test here is that it forces you to check the API. If it's too difficult to test, then it's too difficult to (re)use the component. |
So, I was trying it and it looks like the profiler data is not able to load for the other view. |
I'm using chromium browser (edge) and it's visible when I type something into the search box. |
@eh-am I've moved the logic to redux as discussed as per my understanding. ProfileHeader › ViewSection › small mode › changes to Both view
could not find react-redux context value; please ensure the component is wrapped in a <Provider>
204 | }) {
205 | const [text, setText] = useState('');
> 206 | const isSearchLinkedState = useSelector(isSearchLinked); Should we also include the Also, let me know if there are any other changes needed. |
@eh-am I think I've addressed the mentioned changes. Please review. cc: @Rperry2174 |
* fix-single-binary-deploy * Make dashboards work for single-binary phlare
No description provided.