-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: add Util.prepareReportResult method #5766
Conversation
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.
Whoops, forgot to submit the review.
This LGTM, but could we not base it on #5765 for now so we can bikeshed on that one next week?
@@ -38,6 +38,39 @@ class Util { | |||
return `%10d${NBSP}ms`; | |||
} | |||
|
|||
/** | |||
* |
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.
would be good to have a description, including that it returns a new copy of the results, doesn't mutate the original
Util.rendererFormattedStrings = clone.i18n.rendererFormattedStrings; | ||
} | ||
|
||
// TODO(phulce): we all agree this is technical debt we should fix |
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 should be moved up to cover the whole function IMO :)
sure. sg
awwwwwwwww finnnnnne |
fb85d06
to
3a81c69
Compare
This comment has been minimized.
This comment has been minimized.
CLAs look good, thanks! |
|
||
// If LHR is older (≤3.0.3), it has no locale setting. Set default. | ||
if (!clone.configSettings.locale) { | ||
clone.configSettings.locale = 'en-US'; |
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.
should this be en
or do you want to fix in #5781 after this?
|
||
container.textContent = ''; // Remove previous report. | ||
container.appendChild(this._renderReport(clone)); | ||
container.appendChild(this._renderReport(report)); | ||
|
||
// put the UIStrings back into original state | ||
ReportRenderer.updateAllUIStrings(originalUIStrings); |
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.
Method should be on ReportRenderer
or Util
, but not both :)
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.
It's pretty ugly that Util.prepareReportResult
sets the UI strings but the caller is responsible for resetting them. Would it be acceptable to make two calls for users of this?
const report = Util.prepareReportResult(result);
Util.updateAllUIStrings(report.i18n.rendererFormattedStrings);
// ...
ReportRenderer.updateAllUIStrings(originalUIStrings);
(Util.prepareReportResult
would have to at least set report.i18n.rendererFormattedStrings
to a default empty object or the original UIStrings
).
I guess on the other hand both proposed refactors have the string setting handled for the user of Util.prepareReportResult
, so maybe it's fine to be ugly for now.
@@ -40,30 +40,17 @@ class ReportRenderer { | |||
} | |||
|
|||
/** | |||
* @param {LH.ReportResult} report | |||
* @param {LH.ReportResult} result |
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.
really should be @param {LH.Result} result
7b675e3
to
4aa73f7
Compare
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.
LGTM!
wdyt
currently depends on #5765