Skip to content

Commit 83ee797

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update background service recording start page
Drive-by: Fix a string in storage buckets not to be translated Before: https://imgur.com/a/A1WaaPC After: https://imgur.com/a/eZ7XZp2 Bug: 325443331 Change-Id: I536438d545b0efef2569c548d18f2e5ef0717823 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6249178 Commit-Queue: Kim-Anh Tran <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]>
1 parent b61811a commit 83ee797

File tree

4 files changed

+57
-29
lines changed

4 files changed

+57
-29
lines changed

front_end/panels/application/BackgroundServiceView.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import type * as Platform from '../../core/platform/platform.js';
5+
import * as Platform from '../../core/platform/platform.js';
66
import * as SDK from '../../core/sdk/sdk.js';
77
import * as Protocol from '../../generated/protocol.js';
8+
import {dispatchClickEvent} from '../../testing/DOMHelpers.js';
89
import {createTarget} from '../../testing/EnvironmentHelpers.js';
910
import {describeWithMockConnection} from '../../testing/MockConnection.js';
1011
import * as UI from '../../ui/legacy/legacy.js';
@@ -33,7 +34,7 @@ describeWithMockConnection('BackgroundServiceView', () => {
3334
sinon.stub(UI.ShortcutRegistry.ShortcutRegistry, 'instance').returns({
3435
shortcutTitleForAction: () => {},
3536
shortcutsForAction: () => [new UI.KeyboardShortcut.KeyboardShortcut(
36-
[{key: 0, name: ''}], '', UI.KeyboardShortcut.Type.DEFAULT_SHORTCUT)],
37+
[{key: UI.KeyboardShortcut.Keys.Ctrl.code, name: 'Ctrl'}], '', UI.KeyboardShortcut.Type.DEFAULT_SHORTCUT)],
3738
} as unknown as UI.ShortcutRegistry.ShortcutRegistry);
3839
assert.exists(backgroundServiceModel);
3940
view = new Resources.BackgroundServiceView.BackgroundServiceView(serviceName, backgroundServiceModel);
@@ -71,4 +72,24 @@ describeWithMockConnection('BackgroundServiceView', () => {
7172
];
7273
assert.deepEqual(actualData, expectedData);
7374
});
75+
76+
it('shows placeholder text', () => {
77+
assert.isNotNull(view.contentElement.querySelector('.empty-state'));
78+
const header = view.contentElement.querySelector('.empty-state-header')?.textContent;
79+
const description = view.contentElement.querySelector('.empty-state-description')?.textContent;
80+
assert.deepEqual(header, 'No recording yet');
81+
assert.deepEqual(
82+
description,
83+
'Start to debug background services by using the "Start recording events" button or by hitting Ctrl.Learn more');
84+
});
85+
86+
it('Triggers record on button click', async () => {
87+
const recordButton = view.contentElement.querySelector('.empty-state devtools-button');
88+
Platform.assertNotNullOrUndefined(recordButton);
89+
assert.deepEqual(recordButton?.textContent, 'Start recording events');
90+
91+
const recordingSpy = sinon.spy(view, 'toggleRecording');
92+
dispatchClickEvent(recordButton);
93+
assert.isTrue(recordingSpy.calledOnce);
94+
});
7495
});

front_end/panels/application/BackgroundServiceView.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as Platform from '../../core/platform/platform.js';
1010
import * as SDK from '../../core/sdk/sdk.js';
1111
import * as Protocol from '../../generated/protocol.js';
1212
import * as Bindings from '../../models/bindings/bindings.js';
13+
import * as Buttons from '../../ui/components/buttons/buttons.js';
1314
import * as DataGrid from '../../ui/legacy/components/data_grid/data_grid.js';
1415
// eslint-disable-next-line rulesdir/es-modules-import
1516
import emptyWidgetStyles from '../../ui/legacy/emptyWidget.css.js';
@@ -96,10 +97,6 @@ const UIStrings = {
9697
*@description Text in Application Panel Sidebar of the Application panel
9798
*/
9899
backgroundServices: 'Background services',
99-
/**
100-
*@description Text that is usually a hyperlink to more documentation
101-
*/
102-
learnMore: 'Learn more',
103100
/**
104101
*@description Text in Background Service View of the Application panel
105102
*/
@@ -109,17 +106,23 @@ const UIStrings = {
109106
*@example {Background Fetch} PH1
110107
*/
111108
recordingSActivity: 'Recording {PH1} activity...',
109+
/**
110+
*@description Text in Background Service View of the Application panel
111+
*/
112+
noRecording: 'No recording yet',
112113
/**
113114
*@description Inform users that DevTools are recording/waiting for events in the Periodic Background Sync tool of the Application panel
114115
*@example {Background Fetch} PH1
115116
*/
116117
devtoolsWillRecordAllSActivity: 'DevTools will record all {PH1} activity for up to 3 days, even when closed.',
117118
/**
118-
*@description Text in Background Service View of the Application panel
119-
*@example {record} PH1
120-
*@example {Ctrl + R} PH2
119+
*@description Text in Background Service View of the Application panel to instruct the user on how to start a recording for
120+
* background services.
121+
*
122+
*@example {Start recording events} PH1
123+
*@example {Ctrl + E} PH2
121124
*/
122-
clickTheRecordButtonSOrHitSTo: 'Click the record button {PH1} or hit {PH2} to start recording.',
125+
startRecordingToDebug: 'Start to debug background services by using the "{PH1}" button or by hitting {PH2}.',
123126
/**
124127
*@description Text to show an item is empty
125128
*/
@@ -429,7 +432,7 @@ export class BackgroundServiceView extends UI.Widget.VBox {
429432
this.storageKeyManager.storageKeys().includes(storageKey);
430433
}
431434

432-
private createLearnMoreLink(): Element {
435+
private createLearnMoreLink(): Platform.DevToolsPath.UrlString {
433436
let url = 'https://developer.chrome.com/docs/devtools/javascript/background-services/?utm_source=devtools';
434437

435438
switch (this.serviceName) {
@@ -449,7 +452,7 @@ export class BackgroundServiceView extends UI.Widget.VBox {
449452
break;
450453
}
451454

452-
return UI.XLink.XLink.create(url, i18nString(UIStrings.learnMore), undefined, undefined, 'learn-more');
455+
return url as Platform.DevToolsPath.UrlString;
453456
}
454457

455458
private showPreview(dataNode: EventDataNode|null): void {
@@ -479,23 +482,25 @@ export class BackgroundServiceView extends UI.Widget.VBox {
479482
} else if (this.recordButton.isToggled()) {
480483
// Inform users that we are recording/waiting for events.
481484
const featureName = BackgroundServiceView.getUIString(this.serviceName).toLowerCase();
482-
centered.createChild('p').textContent = i18nString(UIStrings.recordingSActivity, {PH1: featureName});
483-
centered.createChild('p').textContent = i18nString(UIStrings.devtoolsWillRecordAllSActivity, {PH1: featureName});
485+
const emptyWidget = new UI.EmptyWidget.EmptyWidget(
486+
i18nString(UIStrings.recordingSActivity, {PH1: featureName}),
487+
i18nString(UIStrings.devtoolsWillRecordAllSActivity, {PH1: featureName}));
488+
emptyWidget.show(centered);
484489
} else {
485-
const landingRecordButton = UI.Toolbar.Toolbar.createActionButton(this.recordAction);
486-
487-
const recordKey = document.createElement('b');
488-
recordKey.classList.add('background-service-shortcut');
489-
recordKey.textContent = UI.ShortcutRegistry.ShortcutRegistry.instance()
490-
.shortcutsForAction('background-service.toggle-recording')[0]
491-
.title();
492-
493-
const inlineButton = UI.UIUtils.createInlineButton(landingRecordButton);
494-
inlineButton.classList.add('background-service-record-inline-button');
495-
centered.createChild('p').appendChild(i18n.i18n.getFormatLocalizedString(
496-
str_, UIStrings.clickTheRecordButtonSOrHitSTo, {PH1: inlineButton, PH2: recordKey}));
497-
498-
centered.appendChild(this.createLearnMoreLink());
490+
const recordShortcuts =
491+
UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('background-service.toggle-recording')[0];
492+
const emptyWidget = new UI.EmptyWidget.EmptyWidget(
493+
i18nString(UIStrings.noRecording),
494+
i18nString(
495+
UIStrings.startRecordingToDebug,
496+
{PH1: i18nString(UIStrings.startRecordingEvents), PH2: recordShortcuts.title()}));
497+
emptyWidget.appendLink(this.createLearnMoreLink());
498+
emptyWidget.show(centered);
499+
500+
const button = UI.UIUtils.createTextButton(
501+
i18nString(UIStrings.startRecordingEvents), () => this.toggleRecording(),
502+
{jslogContext: 'start-recording', variant: Buttons.Button.Variant.PRIMARY});
503+
emptyWidget.contentElement.appendChild(button);
499504
}
500505

501506
this.preview.show(this.previewPanel.contentElement);

front_end/panels/application/StorageBucketsTreeElement.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const UIStrings = {
3636
* Storage Buckets allow developers to separate site data into buckets so that they can be
3737
* deleted independently. https://developer.chrome.com/docs/web-platform/storage-buckets.
3838
*/
39-
storageBucketsDescription: 'On this page you can view and delete storage buckets, and their associated storageAPIs.'
39+
storageBucketsDescription:
40+
'On this page you can view and delete storage buckets, and their associated `storage APIs`.'
4041
};
4142
const str_ = i18n.i18n.registerUIStrings('panels/application/StorageBucketsTreeElement.ts', UIStrings);
4243
export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);

front_end/ui/visual_logging/KnownContextValues.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,6 +3292,7 @@ export const knownContextValues = new Set([
32923292
'standard-emulated-device-list',
32933293
'start',
32943294
'start-new-chat',
3295+
'start-recording',
32953296
'start-time',
32963297
'start-url',
32973298
'start-view',

0 commit comments

Comments
 (0)