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

report: split topbar features #12926

Merged
merged 17 commits into from
Sep 1, 2021
Merged

report: split topbar features #12926

merged 17 commits into from
Sep 1, 2021

Conversation

connorjclark
Copy link
Collaborator

ref #12254 (comment)

Initially I wanted to split off the topbar features and automatically enable them in ReportRenderer, but there are numerous issues involving how we use classes (relying on method overrides to provide/change behavior in the viewer, for example) that makes me want to break this up into two steps. This first PR is moving all the topbar features to its own class, and instantiating an instance of it in ReportUIFeatures such that the API of that class won't change in this PR.

There's some shared functionality between "topbar features" and "the other stuff" that necessitates some helper modules: open-tab.js and feature-util.js (I thought util.js should probably be free of dom stuff).

As for next steps, I'm not sure yet how to untangle the getReportHtml/saveAsGist/resetUIState mess we have here.

@connorjclark connorjclark requested a review from a team as a code owner August 18, 2021 00:05
@connorjclark connorjclark requested review from adamraine and removed request for a team August 18, 2021 00:05
@google-cla google-cla bot added the cla: yes label Aug 18, 2021
* @param {Node=} target DOM node to fire the event on.
* @param {*=} detail Custom data to include.
*/
fireEventOn(name, target = this._document, detail) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this seems dom-y to me.

@connorjclark
Copy link
Collaborator Author

../../front_end/panels/lighthouse/LighthousePanel.ts(264,38): error TS2339: Property 'DOM' does not exist on type 'typeof import("/Users/cjamcl/src/lighthouse/.tmp/chromium-web-tests/devtools/devtools-frontend/out/Default/gen/front_end/third_party/lighthouse/report/report")'.
../../front_end/panels/lighthouse/LighthouseReportRenderer.ts(154,1): error TS2578: Unused '@ts-expect-error' directive.

Not sure why the first error happens.

The second error is this line, and would require us to disable the CDT test check to land:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/lighthouse/LighthouseReportRenderer.ts;l=154?q=LighthouseReportRenderer.ts&ss=chromium

I think it no longer is an error because I removed the protected tag on some method?

@connorjclark
Copy link
Collaborator Author

Not sure why the first error happens.

I'm sure now: I updated the report renderer README with info on the workaround

Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Quick comment dump

report/renderer/open-tab.js Outdated Show resolved Hide resolved
* @param {DOM} dom
* @param {boolean} [force]
*/
export function toggleDarkTheme(dom, force) {
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to be in a separate file? Couldn't this just remain a member of ReportUIFeatures which is passed to the constructor of TopbarFeatures already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It could go there, however the eventual goal of this is to remove TopbarFeatures from ReportUIFeatures, and so this function will need to be a dependency of both. So it needs to be defined outside both of them.

@connorjclark
Copy link
Collaborator Author

@brendankenny
Copy link
Member

https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3104292

is the intention to then remove the ts-ignore after this lands?

@connorjclark
Copy link
Collaborator Author

yea but I will probably forget

@brendankenny
Copy link
Member

how to untangle the getReportHtml/saveAsGist/resetUIState mess we have here

For me, at least, this is the real meat of the issue, and until they are untangled, it does feel a bit like all we can do is bikeshed on which file each function should live in, which will inevitably change as we figure out how we want to rearchitect the report hierarchy.

@connorjclark you started with topbar features, but what if we started with some of the non-topbar features that we can address without untangling from other features? e.g. we now want third-party filter enabled everywhere, so it doesn't need to be in report-ui-features. Does it make sense to embed directly in category-renderer or details-renderer? Same with add Button. Just add to performance-category-renderer? Generalize and land in dom?

@connorjclark
Copy link
Collaborator Author

Where to start splitting didn't seem too consequential, and it wasn't trivial to split up this file, so I am hesitant to throw out this work just to change where we start splitting up report-ui-features.js. I believe any solution we come up with for dealing with the mentioned tangled-functions will benefit from what this PR has started. At the least, this PR makes the rough spots clear (w/e functions topbar-features uses from report-ui-features).

[addButton ...] Generalize and land in dom?

This seems good to me.

we now want third-party filter enabled everywhere, so it doesn't need to be in report-ui-features. Does it make sense to embed directly in category-renderer or details-renderer

I plan to work on this next (haven't yet looked to see where it'd be best to move it to)

devtools-bot pushed a commit to ChromeDevTools/devtools-frontend that referenced this pull request Aug 20, 2021
Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

LGTM

@connorjclark connorjclark merged commit 39751ef into master Sep 1, 2021
@connorjclark connorjclark deleted the topbar-split branch September 1, 2021 23:42
satya-nutella pushed a commit to satya-nutella/lighthouse that referenced this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants