Skip to content

Commit 435b93d

Browse files
Adam RaineDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Add minimal Node specific landing page
https://screenshot.googleplex.com/5tCR9VaQoZ2KDje Bug: 381886477 Change-Id: I3f728c1e524a3ccf3a45b8e46be5f3ffec2df997 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6094763 Reviewed-by: Connor Clark <[email protected]> Commit-Queue: Adam Raine <[email protected]>
1 parent 63d416a commit 435b93d

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,8 +2180,9 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
21802180
return;
21812181
}
21822182

2183-
this.landingPage = LegacyWrapper.LegacyWrapper.legacyWrapper(
2184-
UI.Widget.Widget, new TimelineComponents.LiveMetricsView.LiveMetricsView());
2183+
const liveMetrics = new TimelineComponents.LiveMetricsView.LiveMetricsView();
2184+
liveMetrics.isNode = isNode;
2185+
this.landingPage = LegacyWrapper.LegacyWrapper.legacyWrapper(UI.Widget.Widget, liveMetrics);
21852186
this.landingPage.element.classList.add('timeline-landing-page', 'fill');
21862187
this.landingPage.contentElement.classList.add('fill');
21872188
this.landingPage.show(this.statusPaneContainer);

front_end/panels/timeline/components/LiveMetricsView.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,15 @@ describeWithMockConnection('LiveMetricsView', () => {
690690
assert.strictEqual(mockHandleAction.firstCall.args[1], 'timeline.record-reload');
691691
});
692692

693+
it('should show minimal view for Node connections', async () => {
694+
const view = renderLiveMetrics();
695+
view.isNode = true;
696+
await coordinator.done();
697+
698+
const title = view.shadowRoot?.querySelector('.section-title');
699+
assert.strictEqual(title!.textContent!, 'Node performance');
700+
});
701+
693702
describe('field data', () => {
694703
let target: SDK.Target.Target;
695704
let mockFieldData: CrUXManager.PageResult;

front_end/panels/timeline/components/LiveMetricsView.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@ const UIStrings = {
278278
* @description Tooltip text for a button that will open the Chrome DevTools console to and log additional details about a user interaction.
279279
*/
280280
logToConsole: 'Log additional interaction data to the console',
281+
/**
282+
* @description Title of a view that can be used to analyze the performance of a Node process as a timeline. "Node" is a product name and should not be translated.
283+
*/
284+
nodePerformanceTimeline: 'Node performance',
285+
/**
286+
* @description Description of a view that can be used to analyze the performance of a Node process as a timeline. "Node" is a product name and should not be translated.
287+
*/
288+
nodeClickToRecord: 'Record a performance timeline of the connected Node process.',
281289
};
282290

283291
const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/LiveMetricsView.ts', UIStrings);
@@ -286,6 +294,8 @@ const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
286294
export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
287295
readonly #shadow = this.attachShadow({mode: 'open'});
288296

297+
#isNode: boolean = false;
298+
289299
#lcpValue?: LiveMetrics.LCPValue;
290300
#clsValue?: LiveMetrics.CLSValue;
291301
#inpValue?: LiveMetrics.INPValue;
@@ -311,6 +321,11 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
311321
this.#recordReloadAction = UI.ActionRegistry.ActionRegistry.instance().getAction('timeline.record-reload');
312322
}
313323

324+
set isNode(isNode: boolean) {
325+
this.#isNode = isNode;
326+
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#render);
327+
}
328+
314329
#onMetricStatus(event: {data: LiveMetrics.StatusEvent}): void {
315330
this.#lcpValue = event.data.lcp;
316331
this.#clsValue = event.data.cls;
@@ -1021,7 +1036,24 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
10211036
// clang-format on
10221037
}
10231038

1039+
#renderNodeView(): LitHtml.LitTemplate {
1040+
return html`
1041+
<div class="node-view">
1042+
<main>
1043+
<h2 class="section-title">${i18nString(UIStrings.nodePerformanceTimeline)}</h2>
1044+
<div class="node-description">${i18nString(UIStrings.nodeClickToRecord)}</div>
1045+
<div class="record-action-card">${this.#renderRecordAction(this.#toggleRecordAction)}</div>
1046+
</main>
1047+
</div>
1048+
`;
1049+
}
1050+
10241051
#render = (): void => {
1052+
if (this.#isNode) {
1053+
LitHtml.render(this.#renderNodeView(), this.#shadow, {host: this});
1054+
return;
1055+
}
1056+
10251057
const fieldEnabled = this.#cruxManager.getConfigSetting().get().enabled;
10261058
const liveMetricsTitle =
10271059
fieldEnabled ? i18nString(UIStrings.localAndFieldMetrics) : i18nString(UIStrings.localMetrics);

front_end/panels/timeline/components/liveMetricsView.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,28 @@ x-link { /* stylelint-disable-line selector-type-no-unknown */
365365
text-decoration: underline;
366366
cursor: pointer;
367367
}
368+
369+
.node-view {
370+
display: flex;
371+
align-items: center;
372+
justify-content: center;
373+
height: 100%;
374+
font-size: var(--sys-typescale-body4-size);
375+
line-height: var(--sys-typescale-body4-line-height);
376+
font-weight: var(--ref-typeface-weight-regular);
377+
user-select: text;
378+
379+
main {
380+
width: 300px;
381+
max-width: 100%;
382+
text-align: center;
383+
384+
.section-title {
385+
margin-bottom: 4px;
386+
}
387+
}
388+
}
389+
390+
.node-description {
391+
margin-bottom: 12px;
392+
}

0 commit comments

Comments
 (0)