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

clients(psi): render treemap button #12570

Merged
merged 7 commits into from
May 27, 2021
Merged

clients(psi): render treemap button #12570

merged 7 commits into from
May 27, 2021

Conversation

connorjclark
Copy link
Collaborator

ref #11254

@connorjclark connorjclark requested a review from a team as a code owner May 26, 2021 23:54
@connorjclark connorjclark requested review from patrickhulce and removed request for a team May 26, 2021 23:54
@google-cla google-cla bot added the cla: yes label May 26, 2021

let buttonsEl = metricsEl.querySelector('.lh-buttons');
if (!buttonsEl) buttonsEl = this._dom.createChildOf(metricsEl, 'div', 'lh-buttons');
const containerEl = opts.container || metricsEl;
Copy link
Collaborator Author

@connorjclark connorjclark May 26, 2021

Choose a reason for hiding this comment

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

report-ui-features doesn't have a reference to the root report el, and psi has 2 reports on the page (and not even attached to DOM when installFeatures is called..) so we need a container option to specify where the element should go.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this would make a great comment on the container: line up above, just sayin' :D

(I stared at the container querySelector being identical to the default for a bit until I scrolled down a smidge further to this comment)

icon: 'treemap',
onClick: () => ReportUIFeatures.openTreemap(lhResult, 'url'),
});
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

more copy/paste for now.

Comment on lines 142 to 147
// Defined by lib/file-namer.js, but that file does not exist in PSI. PSI doesn't use it, but
// needs some basic definition so report-ui-features.js typechecks in PSI.
// @ts-expect-error
// eslint-disable-next-line no-unused-vars
function getFilenamePrefix(lhr) {
}
Copy link
Member

Choose a reason for hiding this comment

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

was this from an old version of the change? There's no change in the dependency tree now so this shouldn't be necessary

Copy link
Collaborator Author

@connorjclark connorjclark May 27, 2021

Choose a reason for hiding this comment

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

I don't follow–report-ui-features calls getFilenamePrefix, which fails the internal BUILD.

We could include the extra file from lib but we don't need it in PSI so meh.

Copy link
Member

Choose a reason for hiding this comment

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

i think its cuz reportuifeatures wasn't being used in PSI renderer before, but now is.
and closure is whining about the use of this fn from reportuifeatures

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but now is.

ah, yeahh, that's an important bit :)

next renderer roll will add it

Copy link
Member

Choose a reason for hiding this comment

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

Ah got it, I just assumed tsc. Maybe add "closure compiler" to the comment somewhere? Not what we usually mean by typechecking and I'll probably be confused again the next time I come across this :)

lighthouse-core/report/html/renderer/psi.js Outdated Show resolved Hide resolved
@@ -81,6 +80,9 @@ function prepareLabData(LHResult, document) {
const clonedScoreTemplate = dom.cloneTemplate('#tmpl-lh-scorescale', dom.document());
const scoreScaleEl = dom.find('.lh-scorescale', clonedScoreTemplate);

const reportUIFeatures = new ReportUIFeatures(dom);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this class's scope is starting to get scary now 😆

my trail of verification that this doesn't do anything we don't want it to

  • hm, we need an instance of UIFeatures to addButton I wonder why it's not static.
  • oh it just needs _dom/_document. what else does the constructor do?
  • nothing really, initFeatures does the heavy lifting.
  • why is reportUIFeatures.json = needed then? AFAICT it isn't

Copy link
Member

Choose a reason for hiding this comment

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

this class's scope is starting to get scary now 😆

yes, definitely :) it needs a refactor (e.g. addButton could just be on dom itself or in performanceCategoryRenderer if we really want it scoped just to addMetricsSectionButton), but since I was the one who suggested not doing #12327 before the 8.0 release I figured this was fair and we can fix it up afterwards :)

Copy link
Member

Choose a reason for hiding this comment

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

  • why is reportUIFeatures.json = needed then? AFAICT it isn't

this seems right

And we could make addButton static now and pass dom in (initFeatures would just pass it along too), but that might take concurrent DevTools changes?


let buttonsEl = metricsEl.querySelector('.lh-buttons');
if (!buttonsEl) buttonsEl = this._dom.createChildOf(metricsEl, 'div', 'lh-buttons');
const containerEl = opts.container || metricsEl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this would make a great comment on the container: line up above, just sayin' :D

(I stared at the container querySelector being identical to the default for a bit until I scrolled down a smidge further to this comment)

Co-authored-by: Patrick Hulce <patrick.hulce@gmail.com>
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.

None yet

5 participants