Skip to content

Commit 5ec6f5a

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update Background service views
1. Hide table if no services have been registered so far 2. Update preview empty state Drive-by: update emptyWidget.css for proper scrolling behavior Screenshots: https://imgur.com/a/W4fx6vE Bug: 325443331 Change-Id: Ib62ffdf3c7152d75ff53b9c799ae74fa7f260aa8 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6286310 Commit-Queue: Kim-Anh Tran <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]>
1 parent 0b32328 commit 5ec6f5a

File tree

4 files changed

+48
-19
lines changed

4 files changed

+48
-19
lines changed

front_end/panels/application/BackgroundServiceView.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,31 @@ describeWithMockConnection('BackgroundServiceView', () => {
7373
assert.deepEqual(actualData, expectedData);
7474
});
7575

76+
it('shows placeholder text to select a value if events have been captured', () => {
77+
assert.exists(backgroundServiceModel);
78+
assert.exists(manager);
79+
backgroundServiceModel.backgroundServiceEventReceived({
80+
backgroundServiceEvent: {
81+
timestamp: 1556889085, // 2019-05-03 14:11:25.000.
82+
origin: '',
83+
storageKey: testKey,
84+
serviceWorkerRegistrationId: 42 as unknown as Protocol.ServiceWorker.RegistrationID, // invalid.
85+
service: serviceName,
86+
eventName: 'Event1',
87+
instanceId: 'Instance1',
88+
eventMetadata: [],
89+
},
90+
});
91+
manager.updateStorageKeys(new Set([testKey]));
92+
manager.setMainStorageKey(testKey);
93+
94+
assert.isNotNull(view.contentElement.querySelector('.empty-state'));
95+
const header = view.contentElement.querySelector('.empty-state-header')?.textContent;
96+
const description = view.contentElement.querySelector('.empty-state-description')?.textContent;
97+
assert.deepEqual(header, 'No event selected');
98+
assert.deepEqual(description, 'Select an event to view its metadata');
99+
});
100+
76101
it('shows placeholder text', () => {
77102
assert.isNotNull(view.contentElement.querySelector('.empty-state'));
78103
const header = view.contentElement.querySelector('.empty-state-header')?.textContent;

front_end/panels/application/BackgroundServiceView.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ const UIStrings = {
9797
*@description Text in Application Panel Sidebar of the Application panel
9898
*/
9999
backgroundServices: 'Background services',
100+
/**
101+
*@description Text in Background Service View of the Application panel.
102+
* An event here refers to a background service event that is an entry in a table.
103+
*/
104+
noEventSelected: 'No event selected',
100105
/**
101106
*@description Text in Background Service View of the Application panel
102107
*/
103-
selectAnEntryToViewMetadata: 'Select an entry to view metadata',
108+
selectAnEventToViewMetadata: 'Select an event to view its metadata',
104109
/**
105110
*@description Text in Background Service View of the Application panel
106111
*@example {Background Fetch} PH1
@@ -226,6 +231,7 @@ export class BackgroundServiceView extends UI.Widget.VBox {
226231

227232
this.splitWidget.setMainWidget(this.dataGrid.asWidget());
228233
this.splitWidget.setSidebarWidget(this.previewPanel);
234+
this.splitWidget.hideMain();
229235

230236
this.showPreview(null);
231237
}
@@ -288,6 +294,7 @@ export class BackgroundServiceView extends UI.Widget.VBox {
288294
private clearView(): void {
289295
this.selectedEventNode = null;
290296
this.dataGrid.rootNode().removeChildren();
297+
this.splitWidget.hideMain();
291298
this.saveButton.setEnabled(false);
292299
this.showPreview(null);
293300
}
@@ -356,6 +363,10 @@ export class BackgroundServiceView extends UI.Widget.VBox {
356363
const dataNode = new EventDataNode(data, serviceEvent.eventMetadata);
357364
this.dataGrid.rootNode().appendChild(dataNode);
358365

366+
if (this.splitWidget.showMode() !== UI.SplitWidget.ShowMode.BOTH) {
367+
this.splitWidget.showBoth();
368+
}
369+
359370
if (this.dataGrid.rootNode().children.length === 1) {
360371
this.saveButton.setEnabled(true);
361372
this.showPreview(this.selectedEventNode);
@@ -471,37 +482,31 @@ export class BackgroundServiceView extends UI.Widget.VBox {
471482
return;
472483
}
473484

474-
this.preview = new UI.Widget.VBox();
475-
this.preview.contentElement.classList.add('background-service-preview', 'fill');
476-
const centered = this.preview.contentElement.createChild('div');
477-
485+
const emptyWidget = new UI.EmptyWidget.EmptyWidget('', '');
478486
if (this.dataGrid.rootNode().children.length) {
479-
// Inform users that grid entries are clickable.
480-
centered.createChild('p').textContent = i18nString(UIStrings.selectAnEntryToViewMetadata);
487+
emptyWidget.header = i18nString(UIStrings.noEventSelected);
488+
emptyWidget.text = i18nString(UIStrings.selectAnEventToViewMetadata);
481489
} else if (this.recordButton.isToggled()) {
482490
// Inform users that we are recording/waiting for events.
483491
const featureName = BackgroundServiceView.getUIString(this.serviceName).toLowerCase();
484-
const emptyWidget = new UI.EmptyWidget.EmptyWidget(
485-
i18nString(UIStrings.recordingSActivity, {PH1: featureName}),
486-
i18nString(UIStrings.devtoolsWillRecordAllSActivity, {PH1: featureName}));
487-
emptyWidget.show(centered);
492+
emptyWidget.header = i18nString(UIStrings.recordingSActivity, {PH1: featureName});
493+
emptyWidget.text = i18nString(UIStrings.devtoolsWillRecordAllSActivity, {PH1: featureName});
488494
} else {
489495
const recordShortcuts =
490496
UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('background-service.toggle-recording')[0];
491-
const emptyWidget = new UI.EmptyWidget.EmptyWidget(
492-
i18nString(UIStrings.noRecording),
493-
i18nString(
494-
UIStrings.startRecordingToDebug,
495-
{PH1: i18nString(UIStrings.startRecordingEvents), PH2: recordShortcuts.title()}));
497+
emptyWidget.header = i18nString(UIStrings.noRecording);
498+
emptyWidget.text = i18nString(
499+
UIStrings.startRecordingToDebug,
500+
{PH1: i18nString(UIStrings.startRecordingEvents), PH2: recordShortcuts.title()});
496501
emptyWidget.appendLink(this.createLearnMoreLink());
497-
emptyWidget.show(centered);
498502

499503
const button = UI.UIUtils.createTextButton(
500504
i18nString(UIStrings.startRecordingEvents), () => this.toggleRecording(),
501505
{jslogContext: 'start-recording', variant: Buttons.Button.Variant.TONAL});
502506
emptyWidget.contentElement.appendChild(button);
503507
}
504508

509+
this.preview = emptyWidget;
505510
this.preview.show(this.previewPanel.contentElement);
506511
}
507512

front_end/panels/application/backgroundServiceView.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.background-service-toolbar {
88
background-color: var(--sys-color-cdt-base-container);
9-
border-bottom: var(--sys-color-divider);
9+
border-bottom: var(--sys-size-1) solid var(--sys-color-divider);
1010
}
1111

1212
.data-grid {

front_end/ui/legacy/emptyWidget.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
*/
66

77
.empty-view-scroller {
8-
justify-content: center;
98
overflow: auto;
109
}

0 commit comments

Comments
 (0)