Skip to content

Commit 68cfd0a

Browse files
authored
feat: restore Performance landing page (#179)
1 parent bc3bd7f commit 68cfd0a

File tree

5 files changed

+87
-3
lines changed

5 files changed

+87
-3
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,7 @@ grd_files_debug_sources = [
18991899
"front_end/panels/timeline/LayoutShiftsTrackAppender.js",
19001900
"front_end/panels/timeline/ModificationsManager.js",
19011901
"front_end/panels/timeline/NetworkTrackAppender.js",
1902+
"front_end/panels/timeline/ReactNativeTimelineLandingPage.js",
19021903
"front_end/panels/timeline/SaveFileFormatter.js",
19031904
"front_end/panels/timeline/TargetForEvent.js",
19041905
"front_end/panels/timeline/ThirdPartyTreeView.js",

front_end/panels/timeline/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ devtools_module("timeline") {
7272
"LayoutShiftsTrackAppender.ts",
7373
"ModificationsManager.ts",
7474
"NetworkTrackAppender.ts",
75+
"ReactNativeTimelineLandingPage.ts",
7576
"SaveFileFormatter.ts",
7677
"TargetForEvent.ts",
7778
"ThirdPartyTreeView.ts",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
// Copyright 2024 The Chromium Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style license that can be
4+
// found in the LICENSE file.
5+
6+
import * as i18n from '../../core/i18n/i18n.js';
7+
import * as UI from '../../ui/legacy/legacy.js';
8+
9+
const UIStrings = {
10+
/**
11+
* @description Text for an option to learn more about something
12+
*/
13+
learnmore: 'Learn more',
14+
/**
15+
* @description Text in Timeline Panel of the Performance panel
16+
*/
17+
wasd: 'WASD',
18+
/**
19+
* @description Text in Timeline Panel of the Performance panel
20+
* @example {record} PH1
21+
* @example {Ctrl + R} PH2
22+
*/
23+
clickTheRecordButtonSOrHitSTo: 'Click the record button {PH1} or hit {PH2} to start a new recording.',
24+
/**
25+
* @description Text in Timeline Panel of the Performance panel
26+
* @example {Ctrl + U} PH1
27+
* @example {Learn more} PH2
28+
*/
29+
afterRecordingSelectAnAreaOf:
30+
'After recording, select an area of interest in the overview by dragging. Then, zoom and pan the timeline with the mousewheel or {PH1} keys. {PH2}',
31+
} as const;
32+
33+
const str_ = i18n.i18n.registerUIStrings('panels/timeline/ReactNativeTimelineLandingPage.ts', UIStrings);
34+
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
35+
36+
export class ReactNativeTimelineLandingPage extends UI.Widget.VBox {
37+
private readonly toggleRecordAction: UI.ActionRegistration.Action;
38+
39+
constructor(toggleRecordAction: UI.ActionRegistration.Action) {
40+
super();
41+
42+
this.toggleRecordAction = toggleRecordAction;
43+
44+
this.contentElement.classList.add('timeline-landing-page', 'fill');
45+
this.renderLegacyLandingPage();
46+
}
47+
48+
private renderLegacyLandingPage(): void {
49+
function encloseWithTag(tagName: string, contents: string): HTMLElement {
50+
const e = document.createElement(tagName);
51+
e.textContent = contents;
52+
return e;
53+
}
54+
55+
const learnMoreNode = UI.XLink.XLink.create(
56+
'https://developer.chrome.com/docs/devtools/evaluate-performance/', i18nString(UIStrings.learnmore), undefined,
57+
undefined, 'learn-more');
58+
59+
const recordKey = encloseWithTag(
60+
'b',
61+
UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('timeline.toggle-recording')[0].title());
62+
const navigateNode = encloseWithTag('b', i18nString(UIStrings.wasd));
63+
64+
this.contentElement.classList.add('legacy');
65+
const centered = this.contentElement.createChild('div');
66+
67+
const recordButton = UI.UIUtils.createInlineButton(UI.Toolbar.Toolbar.createActionButton(this.toggleRecordAction));
68+
69+
centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString(
70+
str_, UIStrings.clickTheRecordButtonSOrHitSTo, {PH1: recordButton, PH2: recordKey}));
71+
72+
centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString(
73+
str_, UIStrings.afterRecordingSelectAnAreaOf, {PH1: navigateNode, PH2: learnMoreNode}));
74+
}
75+
}
76+

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {Tracker} from './FreshRecording.js';
6565
import {IsolateSelector} from './IsolateSelector.js';
6666
import {AnnotationModifiedEvent, ModificationsManager} from './ModificationsManager.js';
6767
import * as Overlays from './overlays/overlays.js';
68+
import {ReactNativeTimelineLandingPage} from './ReactNativeTimelineLandingPage.js';
6869
import {cpuprofileJsonGenerator, traceJsonGenerator} from './SaveFileFormatter.js';
6970
import {type Client, TimelineController} from './TimelineController.js';
7071
import {Tab} from './TimelineDetailsView.js';
@@ -2250,9 +2251,13 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
22502251
return;
22512252
}
22522253

2253-
const liveMetrics = new TimelineComponents.LiveMetricsView.LiveMetricsView();
2254-
liveMetrics.isNode = isNode;
2255-
this.landingPage = LegacyWrapper.LegacyWrapper.legacyWrapper(UI.Widget.Widget, liveMetrics);
2254+
if (isReactNative) {
2255+
this.landingPage = new ReactNativeTimelineLandingPage(this.toggleRecordAction);
2256+
} else {
2257+
const liveMetrics = new TimelineComponents.LiveMetricsView.LiveMetricsView();
2258+
liveMetrics.isNode = isNode;
2259+
this.landingPage = LegacyWrapper.LegacyWrapper.legacyWrapper(UI.Widget.Widget, liveMetrics);
2260+
}
22562261
this.landingPage.element.classList.add('timeline-landing-page', 'fill');
22572262
this.landingPage.contentElement.classList.add('fill');
22582263
this.landingPage.show(this.statusPaneContainer);

scripts/eslint_rules/lib/check-license-header.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const META_CODE_PATHS = [
8585
'models/react_native',
8686
'panels/react_devtools',
8787
'panels/rn_welcome',
88+
'panels/timeline/ReactNativeTimelineLandingPage.ts',
8889
];
8990

9091
const OTHER_LICENSE_HEADERS = [

0 commit comments

Comments
 (0)