Skip to content

Commit 7b8bde3

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update screenshot empty states (in Network panel)
Screenshots: https://imgur.com/a/E6WaSHB Bug: 325443331 Change-Id: Ie53b539ffae2674c0990518f790f8f8a6b2188a9 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6298127 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent 0f391e7 commit 7b8bde3

File tree

4 files changed

+53
-22
lines changed

4 files changed

+53
-22
lines changed

front_end/panels/network/NetworkPanel.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import * as Logs from '../../models/logs/logs.js';
4444
import * as Trace from '../../models/trace/trace.js';
4545
import * as Workspace from '../../models/workspace/workspace.js';
4646
import * as NetworkForward from '../../panels/network/forward/forward.js';
47+
import * as Buttons from '../../ui/components/buttons/buttons.js';
4748
import * as PerfUI from '../../ui/legacy/components/perf_ui/perf_ui.js';
4849
import * as UI from '../../ui/legacy/legacy.js';
4950
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
@@ -156,9 +157,18 @@ const UIStrings = {
156157
throttling: 'Throttling',
157158
/**
158159
*@description Text in Network Panel to tell the user to reload the page to capture screenshots.
159-
*@example {Ctrl + R} PH1
160+
*@example {Reload page} PH1
161+
*@example {Ctrl + R} PH2
160162
*/
161-
hitSToReloadAndCaptureFilmstrip: 'Hit {PH1} to reload and capture filmstrip.',
163+
reloadAndCaptureFilmstrip: 'Reload and capture filmstrip by using the "{PH1}" button or by hitting {PH2}',
164+
/**
165+
* @description A label for a button in the Network panel for reloading the page to capture screenshots.
166+
*/
167+
reloadPage: 'Reload page',
168+
/**
169+
* @description Text in Network Panel if no filmstrips have been captured
170+
*/
171+
noFilmstrips: 'No filmstrips captured',
162172
/**
163173
* @description A context menu item that is shown for resources in other panels
164174
* to open them in the Network panel.
@@ -175,11 +185,11 @@ const UIStrings = {
175185
/**
176186
*@description Text in Network Panel that is displayed whilst the recording is in progress.
177187
*/
178-
recordingFrames: 'Recording frames...',
188+
recordingFrames: 'Currenty recording frames',
179189
/**
180190
*@description Text in Network Panel that is displayed when frames are being fetched.
181191
*/
182-
fetchingFrames: 'Fetching frames...',
192+
fetchingFrames: 'Currently fetching frames',
183193
/**
184194
* @description Text of a button in the Network panel's toolbar that open Network Conditions panel in the drawer.
185195
*/
@@ -623,14 +633,23 @@ export class NetworkPanel extends UI.Panel.Panel implements
623633
}
624634

625635
private resetFilmStripView(): void {
626-
const reloadShortcut =
627-
UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('inspector-main.reload')[0];
636+
const actionId = 'inspector-main.reload';
637+
const reloadShortcut = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(actionId)[0];
638+
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(actionId);
628639

629640
if (this.filmStripView) {
630641
this.filmStripView.reset();
631-
if (reloadShortcut) {
632-
this.filmStripView.setStatusText(
633-
i18nString(UIStrings.hitSToReloadAndCaptureFilmstrip, {PH1: reloadShortcut.title()}));
642+
if (reloadShortcut && action) {
643+
const button = UI.UIUtils.createTextButton(
644+
i18nString(UIStrings.reloadPage), () => action.execute(),
645+
{jslogContext: actionId, variant: Buttons.Button.Variant.TONAL});
646+
const placeholder = new UI.EmptyWidget.EmptyWidget(
647+
i18nString(UIStrings.noFilmstrips),
648+
i18nString(
649+
UIStrings.reloadAndCaptureFilmstrip,
650+
{PH1: i18nString(UIStrings.reloadPage), PH2: reloadShortcut.title()}));
651+
placeholder.contentElement.appendChild(button);
652+
this.filmStripView.setStatusPlaceholder(placeholder);
634653
}
635654
}
636655
}
@@ -947,7 +966,7 @@ export class FilmStripRecorder implements Trace.TracingManager.TracingManagerCli
947966
startRecording(): void {
948967
this.#collectedTraceEvents = [];
949968
this.filmStripView.reset();
950-
this.filmStripView.setStatusText(i18nString(UIStrings.recordingFrames));
969+
this.filmStripView.setStatusPlaceholder(new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.recordingFrames), ''));
951970
const tracingManager =
952971
SDK.TargetManager.TargetManager.instance().scopeTarget()?.model(Trace.TracingManager.TracingManager);
953972
if (this.tracingManager || !tracingManager) {
@@ -975,7 +994,7 @@ export class FilmStripRecorder implements Trace.TracingManager.TracingManagerCli
975994
this.resourceTreeModel.suspendReload();
976995
}
977996
this.callback = callback;
978-
this.filmStripView.setStatusText(i18nString(UIStrings.fetchingFrames));
997+
this.filmStripView.setStatusPlaceholder(new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.fetchingFrames), ''));
979998
}
980999
}
9811000

front_end/ui/legacy/components/perf_ui/FilmStripView.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '../../../../testing/DOMHelpers.js';
1313
import {describeWithEnvironment} from '../../../../testing/EnvironmentHelpers.js';
1414
import {TraceLoader} from '../../../../testing/TraceLoader.js';
15+
import * as UI from '../../legacy.js';
1516

1617
import * as PerfUI from './perf_ui.js';
1718

@@ -57,6 +58,20 @@ describeWithEnvironment('FilmStripView', function() {
5758
filmStrip.detach();
5859
});
5960

61+
it('shows placeholder', async function() {
62+
const filmStripView = new PerfUI.FilmStripView.FilmStripView();
63+
filmStripView.markAsRoot();
64+
filmStripView.show(document.body);
65+
66+
const placeholder = new UI.Widget.Widget();
67+
placeholder.contentElement.textContent = 'Placeholder';
68+
69+
filmStripView.setStatusPlaceholder(placeholder);
70+
assert.deepEqual(filmStripView.contentElement.textContent, 'Placeholder');
71+
72+
filmStripView.detach();
73+
});
74+
6075
describe('FilmStripView Dialog', function() {
6176
async function renderDialogWithTrace(filmStrip: Trace.Extras.FilmStrip.Data, selectedFrameIndex: number):
6277
Promise<{dialog: PerfUI.FilmStripView.Dialog, shadowRoot: ShadowRoot}> {

front_end/ui/legacy/components/perf_ui/FilmStripView.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ const UIStrings = {
3737
const str_ = i18n.i18n.registerUIStrings('ui/legacy/components/perf_ui/FilmStripView.ts', UIStrings);
3838
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
3939
export class FilmStripView extends Common.ObjectWrapper.eventMixin<EventTypes, typeof UI.Widget.HBox>(UI.Widget.HBox) {
40-
private statusLabel: HTMLElement;
40+
private statusPlaceholder?: UI.Widget.Widget;
4141
private zeroTime: Trace.Types.Timing.Milli = Trace.Types.Timing.Milli(0);
4242
#filmStrip: Trace.Extras.FilmStrip.Data|null = null;
4343

4444
constructor() {
4545
super(true);
4646
this.registerRequiredCSS(filmStripViewStyles);
4747
this.contentElement.classList.add('film-strip-view');
48-
this.statusLabel = this.contentElement.createChild('div', 'label');
4948
this.reset();
5049
}
5150

@@ -98,6 +97,7 @@ export class FilmStripView extends Common.ObjectWrapper.eventMixin<EventTypes, t
9897
}
9998

10099
const frameElements = frames.map(frame => this.createFrameElement(frame));
100+
this.statusPlaceholder?.detach();
101101
this.contentElement.removeChildren();
102102
for (const element of frameElements) {
103103
this.contentElement.appendChild(element);
@@ -119,12 +119,15 @@ export class FilmStripView extends Common.ObjectWrapper.eventMixin<EventTypes, t
119119

120120
reset(): void {
121121
this.zeroTime = Trace.Types.Timing.Milli(0);
122+
this.statusPlaceholder?.detach();
122123
this.contentElement.removeChildren();
123-
this.contentElement.appendChild(this.statusLabel);
124+
this.statusPlaceholder?.show(this.contentElement);
124125
}
125126

126-
setStatusText(text: string): void {
127-
this.statusLabel.textContent = text;
127+
setStatusPlaceholder(element: UI.Widget.Widget): void {
128+
this.statusPlaceholder?.detach();
129+
this.statusPlaceholder = element;
130+
this.statusPlaceholder.show(this.contentElement);
128131
}
129132
}
130133

front_end/ui/legacy/components/perf_ui/filmStripView.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
margin-top: 2px;
1616
}
1717

18-
.film-strip-view .label {
19-
margin: auto;
20-
font-size: 18px;
21-
color: var(--sys-color-token-subtle);
22-
}
23-
2418
.film-strip-view .frame {
2519
background: none;
2620
border: none;

0 commit comments

Comments
 (0)