Skip to content

Commit f4cab69

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update shared storage empty state
Before: https://i.imgur.com/vJpuUTT.png After: https://imgur.com/a/QPkgwz6 Bug: 325443331 Change-Id: Ifc1eacdb5154247e34318ec1b9ab490402417696 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6244424 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent fd89f3f commit f4cab69

File tree

6 files changed

+103
-67
lines changed

6 files changed

+103
-67
lines changed

front_end/panels/application/SharedStorageEventsView.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describeWithMockConnection('SharedStorageEventsView', () => {
148148
it('initially has placeholder sidebar', () => {
149149
const view = new View.SharedStorageEventsView();
150150
assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
151-
assert.isTrue(view.sidebarWidget()?.contentElement.firstChild?.textContent?.includes('Click'));
151+
assert.deepEqual(view.sidebarWidget()?.contentElement.firstChild?.textContent, 'No shared storage event selected');
152152
});
153153

154154
it('updates sidebarWidget upon receiving cellFocusedEvent', async () => {
@@ -186,7 +186,7 @@ describeWithMockConnection('SharedStorageEventsView', () => {
186186
view.clearEvents();
187187
assert.isTrue(spy.calledTwice);
188188
assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
189-
assert.isTrue(view.sidebarWidget()?.contentElement.firstChild?.textContent?.includes('Click'));
189+
assert.deepEqual(view.sidebarWidget()?.contentElement.firstChild?.textContent, 'No shared storage event selected');
190190
});
191191

192192
it('records events only from the target page', () => {

front_end/panels/application/SharedStorageEventsView.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ import * as ApplicationComponents from './components/components.js';
1313
import sharedStorageEventsViewStyles from './sharedStorageEventsView.css.js';
1414

1515
const UIStrings = {
16+
/**
17+
*@description Placeholder text if no shared storage event has been selected.
18+
* Shared storage allows to store and access data that can be shared across different sites.
19+
* A shared storage event is for example an access from a site to that storage.
20+
*/
21+
noEventSelected: 'No shared storage event selected',
1622
/**
1723
*@description Placeholder text instructing the user how to display shared
18-
*storage event details.
24+
* storage event details.
25+
* Shared storage allows to store and access data that can be shared across different sites.
26+
* A shared storage event is for example an access from a site to that storage.
1927
*/
20-
clickToDisplayBody: 'Click on any shared storage event to display the event parameters.',
28+
clickToDisplayBody: 'Click on any shared storage event to display the event parameters',
2129
};
2230
const str_ = i18n.i18n.registerUIStrings('panels/application/SharedStorageEventsView.ts', UIStrings);
2331
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -39,23 +47,21 @@ export class SharedStorageEventsView extends UI.SplitWidget.SplitWidget {
3947
this.element.setAttribute('jslog', `${VisualLogging.pane('shared-storage-events')}`);
4048

4149
const topPanel = new UI.Widget.VBox();
42-
this.#noDisplayView = new UI.Widget.VBox();
50+
this.#noDisplayView =
51+
new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.noEventSelected), i18nString(UIStrings.clickToDisplayBody));
4352

4453
topPanel.setMinimumSize(0, 80);
4554
this.setMainWidget(topPanel);
4655
this.#noDisplayView.setMinimumSize(0, 40);
4756
this.setSidebarWidget(this.#noDisplayView);
57+
this.hideSidebar();
4858

4959
topPanel.contentElement.appendChild(this.#sharedStorageEventGrid);
5060
this.#sharedStorageEventGrid.addEventListener('select', this.#onFocus.bind(this));
5161
this.#sharedStorageEventGrid.setAttribute('jslog', `${VisualLogging.section('events-table')}`);
5262

5363
this.#getMainFrameResourceTreeModel()?.addEventListener(
5464
SDK.ResourceTreeModel.Events.PrimaryPageChanged, this.clearEvents, this);
55-
56-
this.#noDisplayView.contentElement.classList.add('placeholder');
57-
const noDisplayDiv = this.#noDisplayView.contentElement.createChild('div');
58-
noDisplayDiv.textContent = i18nString(UIStrings.clickToDisplayBody);
5965
}
6066

6167
#getMainFrameResourceTreeModel(): SDK.ResourceTreeModel.ResourceTreeModel|null {
@@ -90,6 +96,10 @@ export class SharedStorageEventsView extends UI.SplitWidget.SplitWidget {
9096
return;
9197
}
9298

99+
if (this.showMode() !== UI.SplitWidget.ShowMode.BOTH) {
100+
this.showBoth();
101+
}
102+
93103
this.#events.push(event);
94104
this.#sharedStorageEventGrid.data = this.#events;
95105
}
@@ -98,6 +108,7 @@ export class SharedStorageEventsView extends UI.SplitWidget.SplitWidget {
98108
this.#events = [];
99109
this.#sharedStorageEventGrid.data = this.#events;
100110
this.setSidebarWidget(this.#noDisplayView);
111+
this.hideSidebar();
101112
}
102113

103114
async #onFocus(event: Event): Promise<void> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describeWithLocale('SharedStorageAccessGrid', () => {
6868
const nullGridElement = component.shadowRoot!.querySelector('devtools-new-data');
6969
assert.isNull(nullGridElement);
7070

71-
const noEventsElement = component.shadowRoot!.querySelector('div.no-events-message');
71+
const noEventsElement = component.shadowRoot!.querySelector('.empty-state');
7272
assert.instanceOf(noEventsElement, HTMLDivElement);
7373
});
7474
});

front_end/panels/application/components/SharedStorageAccessGrid.ts

Lines changed: 80 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@ 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';
12+
import * as UI from '../../../ui/legacy/legacy.js';
913
import * as Lit from '../../../ui/lit/lit.js';
14+
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1015

1116
import sharedStorageAccessGridStylesRaw from './sharedStorageAccessGrid.css.js';
1217

1318
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
1419
const sharedStorageAccessGridStyles = new CSSStyleSheet();
1520
sharedStorageAccessGridStyles.replaceSync(sharedStorageAccessGridStylesRaw.cssContent);
1621

22+
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
23+
const inspectorCommonStyles = new CSSStyleSheet();
24+
inspectorCommonStyles.replaceSync(inspectorCommonStylesRaw.cssContent);
25+
26+
const SHARED_STORAGE_EXPLANATION_URL =
27+
'https://developers.google.com/privacy-sandbox/private-advertising/shared-storage';
28+
1729
const {render, html} = Lit;
1830

1931
const UIStrings = {
@@ -48,9 +60,23 @@ const UIStrings = {
4860
*/
4961
eventParams: 'Optional Event Params',
5062
/**
51-
*@description Text shown instead of a table when the table would be empty.
63+
*@description Text shown when no shared storage event is shown.
64+
* Shared storage allows to store and access data that can be shared across different sites.
65+
* A shared storage event is for example an access from a site to that storage.
5266
*/
53-
noEvents: 'No shared storage events recorded.',
67+
noEvents: 'No shared storage events detected',
68+
/**
69+
*@description Text shown when no shared storage event is shown. It explains the shared storage event page.
70+
* Shared storage allows to store and access data that can be shared across different sites.
71+
* A shared storage event is for example an access from a site to that storage.
72+
*/
73+
sharedStorageDescription:
74+
'On this page you can view, add, edit and delete shared storage key-value pairs and view shared storage events.',
75+
/**
76+
* @description Text used in a link to learn more about the topic.
77+
*/
78+
learnMore: 'Learn more',
79+
5480
};
5581

5682
const str_ = i18n.i18n.registerUIStrings('panels/application/components/SharedStorageAccessGrid.ts', UIStrings);
@@ -61,7 +87,7 @@ export class SharedStorageAccessGrid extends HTMLElement {
6187
#datastores: Array<Protocol.Storage.SharedStorageAccessedEvent> = [];
6288

6389
connectedCallback(): void {
64-
this.#shadow.adoptedStyleSheets = [sharedStorageAccessGridStyles];
90+
this.#shadow.adoptedStyleSheets = [sharedStorageAccessGridStyles, inspectorCommonStyles];
6591
this.#render();
6692
}
6793

@@ -71,55 +97,65 @@ export class SharedStorageAccessGrid extends HTMLElement {
7197
}
7298

7399
#render(): void {
74-
// clang-format off
75-
render(html`
76-
<div>
77-
<span class="heading">${i18nString(UIStrings.sharedStorage)}</span>
78-
<devtools-icon class="info-icon"
79-
title=${i18nString(UIStrings.allSharedStorageEvents)}
80-
.data=${{iconName: 'info', color: 'var(--icon-default)', width: '16px'}}>
81-
</devtools-icon>
82-
${this.#renderGridOrNoDataMessage()}
83-
</div>
84-
`, this.#shadow, {host: this});
85-
// clang-format on
100+
render(html`${this.#renderGridOrNoDataMessage()}`, this.#shadow, {host: this});
86101
}
87102

88103
#renderGridOrNoDataMessage(): Lit.TemplateResult {
89104
if (this.#datastores.length === 0) {
90-
return html`<div
91-
class="no-events-message">${i18nString(UIStrings.noEvents)}</div>`;
105+
return html`
106+
<div class="empty-state" jslog=${VisualLogging.section().context('empty-view')}>
107+
<div class="empty-state-header">${i18nString(UIStrings.noEvents)}</div>
108+
<div class="empty-state-description">
109+
<span>${i18nString(UIStrings.sharedStorageDescription)}</span>
110+
${
111+
UI.XLink.XLink.create(
112+
SHARED_STORAGE_EXPLANATION_URL, i18nString(UIStrings.learnMore), 'x-link', undefined, 'learn-more')}
113+
</div>
114+
</div>
115+
`;
92116
}
117+
// clang-format off
93118
return html`
94-
<devtools-data-grid striped inline @select=${this.#onSelect}>
95-
<table>
96-
<tr>
97-
<th id="event-time" weight="10" sortable>
98-
${i18nString(UIStrings.eventTime)}
99-
</th>
100-
<th id="event-type" weight="10" sortable>
101-
${i18nString(UIStrings.eventType)}
102-
</th>
103-
<th id="event-owner-origin" weight="10" sortable>
104-
${i18nString(UIStrings.ownerOrigin)}
105-
</th>
106-
<th id="event-params" weight="10" sortable>
107-
${i18nString(UIStrings.eventParams)}
108-
</th>
109-
</tr>
110-
${this.#datastores.map((event, index) => html`
111-
<tr data-index=${index}>
112-
<td data-value=${event.accessTime}>
113-
${new Date(1e3 * event.accessTime).toLocaleString()}
114-
</td>
115-
<td>${event.type}</td>
116-
<td>${event.ownerOrigin}</td>
117-
<td>${JSON.stringify(event.params)}</td>
119+
<div>
120+
<span class="heading">${i18nString(UIStrings.sharedStorage)}</span>
121+
<devtools-icon class="info-icon"
122+
title=${i18nString(UIStrings.allSharedStorageEvents)}
123+
.data=${{iconName: 'info', color: 'var(--icon-default)', width: '16px'}}>
124+
</devtools-icon>
125+
<devtools-data-grid striped inline @select=${this.#onSelect}>
126+
<table>
127+
<tr>
128+
<th id="event-time" weight="10" sortable>
129+
${i18nString(UIStrings.eventTime)}
130+
</th>
131+
<th id="event-type" weight="10" sortable>
132+
${i18nString(UIStrings.eventType)}
133+
</th>
134+
<th id="event-owner-origin" weight="10" sortable>
135+
${i18nString(UIStrings.ownerOrigin)}
136+
</th>
137+
<th id="event-params" weight="10" sortable>
138+
${i18nString(UIStrings.eventParams)}
139+
</th>
118140
</tr>
119-
`)}
120-
</table>
121-
</devtools-data-grid>
141+
${
142+
this.#datastores.map((event, index) => html`
143+
<tr data-index=${index}>
144+
<td data-value=${event.accessTime}>
145+
${
146+
new Date(1e3 * event.accessTime)
147+
.toLocaleString()}
148+
</td>
149+
<td>${event.type}</td>
150+
<td>${event.ownerOrigin}</td>
151+
<td>${JSON.stringify(event.params)}</td>
152+
</tr>
153+
`)}
154+
</table>
155+
</devtools-data-grid>
156+
</div>
122157
`;
158+
// clang-format on
123159
}
124160

125161
#onSelect(event: CustomEvent<HTMLElement>): void {

front_end/panels/application/components/sharedStorageAccessGrid.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
:host {
77
padding: 20px;
8+
height: 100%;
9+
display: flex;
810
}
911

1012
.heading {

front_end/panels/application/sharedStorageEventsView.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@
77
devtools-shared-storage-access-grid {
88
overflow: auto;
99
}
10-
11-
.placeholder {
12-
align-items: center;
13-
justify-content: center;
14-
font-size: 13px;
15-
color: var(--sys-color-token-subtle);
16-
overflow: auto;
17-
text-align: center;
18-
19-
& div {
20-
width: 100%;
21-
}
22-
}

0 commit comments

Comments
 (0)