Skip to content

Commit 6b85ba0

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update Reporting API empty states
This updates the empty states for reporting api, and also hides the bottom panel for viewing the details, if no reports have been rendered yet. Before: https://i.imgur.com/9l8UJTI.png After: https://imgur.com/a/shxzNND Bug: 325443331 Change-Id: I6678ef1ddf0c19fb5e11f313ff224fa8c2f303c4 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6233913 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent 8e13637 commit 6b85ba0

File tree

10 files changed

+70
-57
lines changed

10 files changed

+70
-57
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,6 @@ grd_files_debug_sources = [
12961296
"front_end/panels/application/preloading/helper/PreloadingForward.js",
12971297
"front_end/panels/application/preloading/preloadingView.css.js",
12981298
"front_end/panels/application/preloading/preloadingViewDropDown.css.js",
1299-
"front_end/panels/application/reportingApiReportsView.css.js",
13001299
"front_end/panels/application/resourcesPanel.css.js",
13011300
"front_end/panels/application/resourcesSidebar.css.js",
13021301
"front_end/panels/application/serviceWorkerCacheViews.css.js",

front_end/panels/application/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ generate_css("css_files") {
1818
"openedWindowDetailsView.css",
1919
"preloading/preloadingView.css",
2020
"preloading/preloadingViewDropDown.css",
21-
"reportingApiReportsView.css",
2221
"resourcesPanel.css",
2322
"resourcesSidebar.css",
2423
"serviceWorkerCacheViews.css",

front_end/panels/application/ReportingApiReportsView.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ import * as UI from '../../ui/legacy/legacy.js';
1010
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
1111

1212
import * as ApplicationComponents from './components/components.js';
13-
import reportingApiReportsViewStyles from './reportingApiReportsView.css.js';
1413

1514
const UIStrings = {
15+
/**
16+
*@description Placeholder text that shows if no report was selected for viewing
17+
*report body (https://developers.google.com/web/updates/2018/09/reportingapi#sending).
18+
*/
19+
noReportSelected: 'No report selected',
1620
/**
1721
*@description Placeholder text instructing the user how to display a Reporting API
1822
*report body (https://developers.google.com/web/updates/2018/09/reportingapi#sending).
@@ -29,35 +33,28 @@ export class ReportingApiReportsView extends UI.SplitWidget.SplitWidget {
2933
constructor(networkManager: SDK.NetworkManager.NetworkManager) {
3034
super(/* isVertical: */ false, /* secondIsSidebar: */ true);
3135
const topPanel = new UI.Widget.VBox();
32-
const bottomPanel = new UI.Widget.VBox();
36+
const bottomPanel = new UI.EmptyWidget.EmptyWidget(
37+
i18nString(UIStrings.noReportSelected), i18nString(UIStrings.clickToDisplayBody));
3338
topPanel.setMinimumSize(0, 80);
3439
this.setMainWidget(topPanel);
3540
bottomPanel.setMinimumSize(0, 40);
3641
bottomPanel.element.setAttribute('jslog', `${VisualLogging.pane('preview').track({resize: true})}`);
3742
this.setSidebarWidget(bottomPanel);
43+
this.hideSidebar();
3844

3945
topPanel.contentElement.appendChild(this.reportsGrid);
4046
this.reportsGrid.addEventListener('select', this.onFocus.bind(this));
4147

42-
bottomPanel.contentElement.classList.add('placeholder');
43-
const centered = bottomPanel.contentElement.createChild('div');
44-
centered.textContent = i18nString(UIStrings.clickToDisplayBody);
45-
4648
networkManager.addEventListener(
4749
SDK.NetworkManager.Events.ReportingApiReportAdded, event => this.onReportAdded(event.data), this);
4850
networkManager.addEventListener(
4951
SDK.NetworkManager.Events.ReportingApiReportUpdated, event => this.onReportUpdated(event.data), this);
5052
}
5153

52-
override wasShown(): void {
53-
super.wasShown();
54-
const sbw = this.sidebarWidget();
55-
if (sbw) {
56-
sbw.registerRequiredCSS(reportingApiReportsViewStyles);
57-
}
58-
}
59-
6054
private onReportAdded(report: Protocol.Network.ReportingApiReport): void {
55+
if (this.showMode() !== UI.SplitWidget.ShowMode.BOTH) {
56+
this.showBoth();
57+
}
6158
this.reports.push(report);
6259
this.reportsGrid.data = {reports: this.reports};
6360
}

front_end/panels/application/ReportingApiView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ export class ReportingApiView extends UI.SplitWidget.SplitWidget {
3232
reportingApiEndpointsView.contentElement.appendChild(this.endpointsGrid);
3333
this.setMainWidget(reportingApiReportsView);
3434
this.setSidebarWidget(reportingApiEndpointsView);
35+
this.hideSidebar();
3536
void networkManager.enableReportingApi();
3637
}
3738
}
3839

3940
private onEndpointsChangedForOrigin(data: Protocol.Network.ReportingApiEndpointsChangedForOriginEvent): void {
41+
if (this.showMode() !== UI.SplitWidget.ShowMode.BOTH) {
42+
this.showBoth();
43+
}
4044
this.endpoints.set(data.origin, data.endpoints);
4145
this.endpointsGrid.data = {endpoints: this.endpoints};
4246
}

front_end/panels/application/components/EndpointsGrid.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ describeWithLocale('EndpointsGrid', () => {
3737
renderElementIntoDOM(component);
3838
await RenderCoordinator.done();
3939

40-
const placeholder = component.shadowRoot!.querySelector('.reporting-placeholder div');
41-
assert.strictEqual(placeholder?.textContent, 'No endpoints to display');
40+
const placeholderHeader = component.shadowRoot!.querySelector('.empty-state-header');
41+
assert.strictEqual(placeholderHeader?.textContent, 'No endpoints to display');
42+
const placeholderDescription = component.shadowRoot!.querySelector('.empty-state-description');
43+
assert.strictEqual(
44+
placeholderDescription?.textContent, 'Here you will find the list of endpoints that receive the reports');
4245
});
4346

4447
it('renders grid with correct content', async () => {

front_end/panels/application/components/EndpointsGrid.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import '../../../ui/legacy/components/data_grid/data_grid.js';
66

77
import * as i18n from '../../../core/i18n/i18n.js';
88
import type * as Protocol from '../../../generated/protocol.js';
9+
// inspectorCommonStyles is imported for the empty state styling that is used for the start view
10+
// eslint-disable-next-line rulesdir/es-modules-import
11+
import inspectorCommonStylesRaw from '../../../ui/legacy/inspectorCommon.css.js';
912
import * as Lit from '../../../ui/lit/lit.js';
1013
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1114

@@ -15,12 +18,21 @@ import reportingApiGridStylesRaw from './reportingApiGrid.css.js';
1518
const reportingApiGridStyles = new CSSStyleSheet();
1619
reportingApiGridStyles.replaceSync(reportingApiGridStylesRaw.cssContent);
1720

21+
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
22+
const inspectorCommonStyles = new CSSStyleSheet();
23+
inspectorCommonStyles.replaceSync(inspectorCommonStylesRaw.cssContent);
24+
1825
const UIStrings = {
1926
/**
2027
*@description Placeholder text when there are no Reporting API endpoints.
2128
*(https://developers.google.com/web/updates/2018/09/reportingapi#tldr)
2229
*/
2330
noEndpointsToDisplay: 'No endpoints to display',
31+
/**
32+
*@description Placeholder text when there are no Reporting API endpoints.
33+
*(https://developers.google.com/web/updates/2018/09/reportingapi#tldr)
34+
*/
35+
endpointsDescription: 'Here you will find the list of endpoints that receive the reports'
2436
};
2537
const str_ = i18n.i18n.registerUIStrings('panels/application/components/EndpointsGrid.ts', UIStrings);
2638
export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -37,7 +49,7 @@ export class EndpointsGrid extends HTMLElement {
3749
#endpoints: Map<string, Protocol.Network.ReportingApiEndpoint[]> = new Map();
3850

3951
connectedCallback(): void {
40-
this.#shadow.adoptedStyleSheets = [reportingApiGridStyles];
52+
this.#shadow.adoptedStyleSheets = [reportingApiGridStyles, inspectorCommonStyles];
4153
this.#render();
4254
}
4355

@@ -70,8 +82,9 @@ export class EndpointsGrid extends HTMLElement {
7082
</table>
7183
</devtools-data-grid>
7284
` : html`
73-
<div class="reporting-placeholder">
74-
<div>${i18nString(UIStrings.noEndpointsToDisplay)}</div>
85+
<div class="empty-state">
86+
<span class="empty-state-header">${i18nString(UIStrings.noEndpointsToDisplay)}</span>
87+
<span class="empty-state-description">${i18nString(UIStrings.endpointsDescription)}</span>
7588
</div>
7689
`}
7790
</div>

front_end/panels/application/components/ReportsGrid.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ describeWithEnvironment('ReportsGrid', () => {
4343
it('displays placeholder text if no data', async () => {
4444
const component = await renderReportsGrid();
4545

46-
const placeholder = component.shadowRoot!.querySelector('.reporting-placeholder div');
47-
assert.strictEqual(placeholder!.textContent, 'No reports to display');
46+
const placeholderHeader = component.shadowRoot!.querySelector('.empty-state-header');
47+
assert.strictEqual(placeholderHeader?.textContent, 'No reports to display');
48+
const placeholderDescription = component.shadowRoot!.querySelector('.empty-state-description');
49+
assert.isTrue(placeholderDescription?.textContent?.includes(
50+
'Here you will find reporting api reports that are generated by the page.'));
4851
});
4952

5053
it('renders grid with correct content', async () => {

front_end/panels/application/components/ReportsGrid.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import '../../../ui/legacy/legacy.js';
99
import * as i18n from '../../../core/i18n/i18n.js';
1010
import * as Root from '../../../core/root/root.js';
1111
import type * as Protocol from '../../../generated/protocol.js';
12+
// inspectorCommonStyles is imported for the empty state styling that is used for the start view
13+
// eslint-disable-next-line rulesdir/es-modules-import
14+
import inspectorCommonStylesRaw from '../../../ui/legacy/inspectorCommon.css.js';
15+
import * as UI from '../../../ui/legacy/legacy.js';
1216
import * as Lit from '../../../ui/lit/lit.js';
1317
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1418

@@ -18,12 +22,25 @@ import reportingApiGridStylesRaw from './reportingApiGrid.css.js';
1822
const reportingApiGridStyles = new CSSStyleSheet();
1923
reportingApiGridStyles.replaceSync(reportingApiGridStylesRaw.cssContent);
2024

25+
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
26+
const inspectorCommonStyles = new CSSStyleSheet();
27+
inspectorCommonStyles.replaceSync(inspectorCommonStylesRaw.cssContent);
28+
2129
const UIStrings = {
2230
/**
2331
*@description Placeholder text when there are no Reporting API reports.
2432
*(https://developers.google.com/web/updates/2018/09/reportingapi#sending)
2533
*/
2634
noReportsToDisplay: 'No reports to display',
35+
/**
36+
*@description Placeholder text that explains Reporting API reports.
37+
*(https://developers.google.com/web/updates/2018/09/reportingapi#sending)
38+
*/
39+
reportingApiDescription: 'Here you will find reporting api reports that are generated by the page.',
40+
/**
41+
* @description Link text to forward to a documentation page on reporting API.
42+
*/
43+
learnMore: 'Learn more',
2744
/**
2845
*@description Column header for a table displaying Reporting API reports.
2946
*Status is one of 'Queued', 'Pending', 'MarkedForRemoval' or 'Success'.
@@ -38,13 +55,15 @@ const UIStrings = {
3855
*@description Column header for a table displaying Reporting API reports.
3956
*The column contains the timestamp of when a report was generated.
4057
*/
41-
generatedAt: 'Generated at',
58+
generatedAt: 'Generated at'
4259
};
4360
const str_ = i18n.i18n.registerUIStrings('panels/application/components/ReportsGrid.ts', UIStrings);
4461
export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
4562

4663
const {render, html} = Lit;
4764

65+
const REPORTING_API_EXPLANATION_URL = 'https://developer.chrome.com/docs/capabilities/web-apis/reporting-api';
66+
4867
export class ReportsGridStatusHeader extends HTMLElement {
4968
readonly #shadow = this.attachShadow({mode: 'open'});
5069

@@ -82,7 +101,7 @@ export class ReportsGrid extends HTMLElement {
82101
#protocolMonitorExperimentEnabled = false;
83102

84103
connectedCallback(): void {
85-
this.#shadow.adoptedStyleSheets = [reportingApiGridStyles];
104+
this.#shadow.adoptedStyleSheets = [reportingApiGridStyles, inspectorCommonStyles];
86105
this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocol-monitor');
87106
this.#render();
88107
}
@@ -97,8 +116,8 @@ export class ReportsGrid extends HTMLElement {
97116
// clang-format off
98117
render(html`
99118
<div class="reporting-container" jslog=${VisualLogging.section('reports')}>
100-
<div class="reporting-header">${i18n.i18n.lockedString('Reports')}</div>
101119
${this.#reports.length > 0 ? html`
120+
<div class="reporting-header">${i18n.i18n.lockedString('Reports')}</div>
102121
<devtools-data-grid striped @select=${this.#onSelect}>
103122
<table>
104123
<tr>
@@ -128,8 +147,12 @@ export class ReportsGrid extends HTMLElement {
128147
</table>
129148
</devtools-data-grid>
130149
` : html`
131-
<div class="reporting-placeholder">
132-
<div>${i18nString(UIStrings.noReportsToDisplay)}</div>
150+
<div class="empty-state">
151+
<span class="empty-state-header">${i18nString(UIStrings.noReportsToDisplay)}</span>
152+
<div class="empty-state-description">
153+
<span>${i18nString(UIStrings.reportingApiDescription)}</span>
154+
${UI.XLink.XLink.create(REPORTING_API_EXPLANATION_URL, i18nString(UIStrings.learnMore), undefined, undefined, 'learn-more')}
155+
</div>
133156
</div>
134157
`}
135158
</div>

front_end/panels/application/components/reportingApiGrid.css

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@
1919
font-size: 15px;
2020
background-color: var(--sys-color-surface2);
2121
padding: 1px 4px;
22-
}
23-
24-
.reporting-placeholder {
25-
flex-grow: 1;
26-
display: flex;
27-
align-items: center;
28-
justify-content: center;
29-
font-size: 13px;
30-
color: var(--sys-color-token-subtle);
31-
min-width: min-content;
32-
text-align: center;
22+
flex-shrink: 0;
3323
}
3424

3525
devtools-data-grid {

front_end/panels/application/reportingApiReportsView.css

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)