Remove timeline graph type radio buttons#4147
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4147 +/- ##
==========================================
+ Coverage 88.28% 88.31% +0.02%
==========================================
Files 280 280
Lines 24414 24408 -6
Branches 6490 6488 -2
==========================================
+ Hits 21554 21555 +1
+ Misses 2656 2650 -6
+ Partials 204 203 -1
Continue to review full report at Codecov.
|
julienw
left a comment
There was a problem hiding this comment.
Thanks, this looks good to me!
I only have one important comment about where we can compute the timelineType. Tell me what you think!
| ❗ The timeline type "${timelineType}" is unknown. | ||
| 💡 Valid types are: "cpu-category", "category", or "stack". | ||
| Please try again 😊 |
There was a problem hiding this comment.
Actually I copy/pasted most of it from another function here 😄
| search: '', | ||
| search: `?v=${CURRENT_URL_VERSION}`, |
There was a problem hiding this comment.
Just wondering why this is needed?
There was a problem hiding this comment.
If the version number is not there, it tries to upgrade the url first. Since we change the default value from 'category' to 'cpu-category', it prints 'category' here in this test. But this test is not checking the upgrader at all, so it should not check this path and focus only on the default parameters.
| class="photon-label photon-label-micro timelineSettingsToggleLabel" | ||
| > | ||
| <input | ||
| checked="" |
There was a problem hiding this comment.
do you know why this change happened?
There was a problem hiding this comment.
and now the full snapshot is removed so.... let's not focus on that :D
There was a problem hiding this comment.
Yeah, I removed this test, but to give you more context. We did multiple things that affected this in the first place:
- Make the cpu-category the default one
- Properly upgrade the old profiles.
So the 1 makes this unchecked and 2 makes it checked again. But since it's removed, we don't need to worry about it now.
| class="photon-label photon-label-micro timelineSettingsToggleLabel" | ||
| > | ||
| <input | ||
| checked="" |
| case 'PROFILE_LOADED': | ||
| if (!action.profile.meta.categories) { | ||
| // An imported profile did not provide its own categories. Use the stack view instead. | ||
| return 'stack'; | ||
| } | ||
| return state; |
There was a problem hiding this comment.
idea: use determineTimelineType here, and remove the property from the actions VIEW_..._PROFILE.
This looks conceptually more correct to me because (in theory) the reduces is where the computation should happen.
There was a problem hiding this comment.
It's not 100% clear to me how everything is organized at load time, but it seems to be that this would work because the sequence is:
LOAD_PROFILEUPDATE_URL_STATEfinalizeProfileViewcallingVIEW_..._PROFILE
Therefore the information from the URL would override what's set in LOAD_PROFILE, which is what we're trying to do in finalizeProfileView.
There was a problem hiding this comment.
what do you think?
I'm fine if you want to do it in a separate PR, however it would be good to do it soon while it's fresh in our heads.
There was a problem hiding this comment.
(note: if we decide to not do this, then you can remove thiscase block here)
There was a problem hiding this comment.
You are right about the order of the actions. But there is one problem with the UPDATE_URL_STATE.
When we add it to the LOAD_PROFILE it changes the url state. But then, during the UPDATE_URL_STATE, it actually replaces the whole urlState object with a new one. Because of this, whenever we update the url state during the LOAD_PROFILE, it's going to be overwritten no matter what. Because of this, we need to do it during the finalize function to make sure that we have a new url state and we can do this addition afterwards depending on the profile data. So unfortunately, we can't change it during the LOAD_PROFILE action.
I will remove this case from the reducer instead.
| urlState.profileSpecific.timelineType === 'cpu-category' | ||
| ? undefined | ||
| : urlState.profileSpecific.timelineType, |
There was a problem hiding this comment.
I was wondering about not adding it at all if the type is the default (computed) one. But we'd need the profile data, and we don't have it here. Then I'm fine with this.
There was a problem hiding this comment.
Yeah, I think it should be easiest to make the 'cpu-category' the default. Otherwise we need the profile which makes it harder.
| ❗ The timeline type "${timelineType}" is unknown. | ||
| 💡 Valid types are: "cpu-category", "category", or "stack". | ||
| Please try again 😊 |
There was a problem hiding this comment.
Actually I copy/pasted most of it from another function here 😄
| search: '', | ||
| search: `?v=${CURRENT_URL_VERSION}`, |
There was a problem hiding this comment.
If the version number is not there, it tries to upgrade the url first. Since we change the default value from 'category' to 'cpu-category', it prints 'category' here in this test. But this test is not checking the upgrader at all, so it should not check this path and focus only on the default parameters.
| class="photon-label photon-label-micro timelineSettingsToggleLabel" | ||
| > | ||
| <input | ||
| checked="" |
There was a problem hiding this comment.
Yeah, I removed this test, but to give you more context. We did multiple things that affected this in the first place:
- Make the cpu-category the default one
- Properly upgrade the old profiles.
So the 1 makes this unchecked and 2 makes it checked again. But since it's removed, we don't need to worry about it now.
| urlState.profileSpecific.timelineType === 'cpu-category' | ||
| ? undefined | ||
| : urlState.profileSpecific.timelineType, |
There was a problem hiding this comment.
Yeah, I think it should be easiest to make the 'cpu-category' the default. Otherwise we need the profile which makes it harder.
| case 'PROFILE_LOADED': | ||
| if (!action.profile.meta.categories) { | ||
| // An imported profile did not provide its own categories. Use the stack view instead. | ||
| return 'stack'; | ||
| } | ||
| return state; |
There was a problem hiding this comment.
You are right about the order of the actions. But there is one problem with the UPDATE_URL_STATE.
When we add it to the LOAD_PROFILE it changes the url state. But then, during the UPDATE_URL_STATE, it actually replaces the whole urlState object with a new one. Because of this, whenever we update the url state during the LOAD_PROFILE, it's going to be overwritten no matter what. Because of this, we need to do it during the finalize function to make sure that we have a new url state and we can do this addition afterwards depending on the profile data. So unfortunately, we can't change it during the LOAD_PROFILE action.
I will remove this case from the reducer instead.
20fd22f to
0fe0988
Compare
julienw
left a comment
There was a problem hiding this comment.
makes sense, thanks for the cleanup!
This was disabled for a long while ago and was waiting for us to re-enabled it again. But we've changed our minds about adding a checkbox here. It's not needed anymore.
0fe0988 to
20397bb
Compare
Finally I went ahead and removed our famous graph type radio buttons 😄
With this PR, it should work like explained in #3150. I've also added a function to window, so our power users still can access and change if they really need to.
This PR also removes some of the unused parts in the timeline and removes the now empty line after removing these radio buttons.
Fixes #3150
Fixes #3443
Example profile with CPU and category data: before / after
Example profile with category but without CPU data: before / after
Example profile without CPU and category data: before / after
Example chome profile: before / after
Example perf profile: before / after
Example profile for testing url upgrader: after