Skip to content

Commit 4b0ce87

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update interest group tab in application panel
This updates the empty states in the interest group tabs. We only show the lower details widget if there are interest groups to inspect to begin with. Before: https://i.imgur.com/1OmvGhn.png After: https://imgur.com/a/9PQwpL5 Bug: 325443331 Change-Id: I403c59b3e6e28163b8423d24dafcc59b40a582e7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6235024 Commit-Queue: Kim-Anh Tran <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]>
1 parent c79c882 commit 4b0ce87

File tree

6 files changed

+76
-40
lines changed

6 files changed

+76
-40
lines changed

front_end/panels/application/InterestGroupStorageView.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ describeWithMockConnection('InterestGroupStorageView', () => {
6767
it('initially has placeholder sidebar', () => {
6868
const view = new View.InterestGroupStorageView(new InterestGroupDetailsGetter());
6969
assert.notDeepEqual(view.sidebarWidget()?.constructor.name, 'SearchableView');
70-
assert.isTrue(view.sidebarWidget()?.contentElement.firstChild?.textContent?.includes('Click'));
70+
71+
const placeholder = view.sidebarWidget()?.contentElement;
72+
assert.deepEqual(
73+
placeholder?.textContent,
74+
'No interest group selectedSelect any interest group event to display the group\'s current state');
7175
});
7276

7377
// Disabled due to flakiness

front_end/panels/application/InterestGroupStorageView.ts

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,35 @@ import * as ApplicationComponents from './components/components.js';
1212
import interestGroupStorageViewStyles from './interestGroupStorageView.css.js';
1313

1414
const UIStrings = {
15+
/**
16+
*@description Placeholder text shown when nothing has been selected for display
17+
*details.
18+
* An interest group is an ad targeting group stored on the browser that can
19+
* be used to show a certain set of advertisements in the future as the
20+
* outcome of a FLEDGE auction.
21+
*/
22+
noValueSelected: 'No interest group selected',
1523
/**
1624
*@description Placeholder text instructing the user how to display interest group
1725
*details.
26+
* An interest group is an ad targeting group stored on the browser that can
27+
* be used to show a certain set of advertisements in the future as the
28+
* outcome of a FLEDGE auction.
1829
*/
19-
clickToDisplayBody: 'Click on any interest group event to display the group\'s current state',
30+
clickToDisplayBody: 'Select any interest group event to display the group\'s current state',
2031
/**
2132
*@description Placeholder text telling the user no details are available for
2233
*the selected interest group.
2334
*/
24-
noDataAvailable: 'No details available for the selected interest group. The browser may have left the group.',
35+
noDataAvailable: 'No details available',
36+
/**
37+
*@description Placeholder text explaining to the user a potential reason for not having details on
38+
* the interest groups.
39+
* An interest group is an ad targeting group stored on the browser that can
40+
* be used to show a certain set of advertisements in the future as the
41+
* outcome of a FLEDGE auction.
42+
*/
43+
noDataDescription: 'The browser may have left the group.',
2544
};
2645
const str_ = i18n.i18n.registerUIStrings('panels/application/InterestGroupStorageView.ts', UIStrings);
2746
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -48,27 +67,22 @@ export class InterestGroupStorageView extends UI.SplitWidget.SplitWidget {
4867
this.detailsGetter = detailsGetter;
4968

5069
const topPanel = new UI.Widget.VBox();
51-
this.noDisplayView = new UI.Widget.VBox();
52-
this.noDataView = new UI.Widget.VBox();
70+
this.noDisplayView =
71+
new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.noValueSelected), i18nString(UIStrings.clickToDisplayBody));
72+
this.noDataView =
73+
new UI.EmptyWidget.EmptyWidget(i18nString(UIStrings.noDataAvailable), i18nString(UIStrings.noDataDescription));
5374

54-
topPanel.setMinimumSize(0, 80);
75+
topPanel.setMinimumSize(0, 120);
5576
this.setMainWidget(topPanel);
56-
this.noDisplayView.setMinimumSize(0, 40);
77+
this.noDisplayView.setMinimumSize(0, 80);
5778
this.setSidebarWidget(this.noDisplayView);
58-
this.noDataView.setMinimumSize(0, 40);
79+
this.noDataView.setMinimumSize(0, 80);
80+
this.noDisplayView.contentElement.setAttribute('jslog', `${VisualLogging.pane('details').track({resize: true})}`);
81+
this.noDataView.contentElement.setAttribute('jslog', `${VisualLogging.pane('details').track({resize: true})}`);
82+
this.hideSidebar();
5983

6084
topPanel.contentElement.appendChild(this.interestGroupGrid);
6185
this.interestGroupGrid.addEventListener('select', this.onFocus.bind(this));
62-
63-
this.noDisplayView.contentElement.classList.add('placeholder');
64-
this.noDisplayView.contentElement.setAttribute('jslog', `${VisualLogging.pane('details').track({resize: true})}`);
65-
const noDisplayDiv = this.noDisplayView.contentElement.createChild('div');
66-
noDisplayDiv.textContent = i18nString(UIStrings.clickToDisplayBody);
67-
68-
this.noDataView.contentElement.classList.add('placeholder');
69-
this.noDataView.contentElement.setAttribute('jslog', `${VisualLogging.pane('details').track({resize: true})}`);
70-
const noDataDiv = this.noDataView.contentElement.createChild('div');
71-
noDataDiv.textContent = i18nString(UIStrings.noDataAvailable);
7286
}
7387

7488
override wasShown(): void {
@@ -80,6 +94,9 @@ export class InterestGroupStorageView extends UI.SplitWidget.SplitWidget {
8094
}
8195

8296
addEvent(event: Protocol.Storage.InterestGroupAccessedEvent): void {
97+
if (this.showMode() !== UI.SplitWidget.ShowMode.BOTH) {
98+
this.showBoth();
99+
}
83100
// Only add if not already present.
84101
const foundEvent = this.events.find(t => eventEquals(t, event));
85102
if (!foundEvent) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describeWithLocale('InterestGroupAccessGrid', () => {
6464
const nullGridElement = component.shadowRoot!.querySelector('devtools-data-grid');
6565
assert.isNull(nullGridElement);
6666

67-
const noEventsElement = component.shadowRoot!.querySelector('div.no-events-message');
67+
const noEventsElement = component.shadowRoot!.querySelector('.empty-state');
6868
assert.instanceOf(noEventsElement, HTMLDivElement);
6969
});
7070
});

front_end/panels/application/components/InterestGroupAccessGrid.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ 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

1114
import interestGroupAccessGridStylesRaw from './interestGroupAccessGrid.css.js';
1215

16+
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
17+
const inspectorCommonStyles = new CSSStyleSheet();
18+
inspectorCommonStyles.replaceSync(inspectorCommonStylesRaw.cssContent);
19+
1320
// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
1421
const interestGroupAccessGridStyles = new CSSStyleSheet();
1522
interestGroupAccessGridStyles.replaceSync(interestGroupAccessGridStylesRaw.cssContent);
@@ -49,9 +56,19 @@ const UIStrings = {
4956
*/
5057
groupName: 'Name',
5158
/**
52-
*@description Text shown instead of a table when the table would be empty.
59+
*@description Text shown when no interest groups are detected.
60+
* An interest group is an ad targeting group stored on the browser that can
61+
* be used to show a certain set of advertisements in the future as the
62+
* outcome of a FLEDGE auction.
63+
*/
64+
noEvents: 'No interest group events detected',
65+
/**
66+
*@description Text shown when no interest groups are detected and explains what this page is about.
67+
* An interest group is an ad targeting group stored on the browser that can
68+
* be used to show a certain set of advertisements in the future as the
69+
* outcome of a FLEDGE auction.
5370
*/
54-
noEvents: 'No interest group events recorded.',
71+
interestGroupDescription: 'On this page you can inspect and analyze interest groups',
5572
};
5673
const str_ = i18n.i18n.registerUIStrings('panels/application/components/InterestGroupAccessGrid.ts', UIStrings);
5774
export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -61,7 +78,7 @@ export class InterestGroupAccessGrid extends HTMLElement {
6178
#datastores: Array<Protocol.Storage.InterestGroupAccessedEvent> = [];
6279

6380
connectedCallback(): void {
64-
this.#shadow.adoptedStyleSheets = [interestGroupAccessGridStyles];
81+
this.#shadow.adoptedStyleSheets = [interestGroupAccessGridStyles, inspectorCommonStyles];
6582
this.#render();
6683
}
6784

@@ -71,6 +88,10 @@ export class InterestGroupAccessGrid extends HTMLElement {
7188
}
7289

7390
#render(): void {
91+
if (this.#datastores.length === 0) {
92+
Lit.render(this.#renderEmptyState(), this.#shadow, {host: this});
93+
return;
94+
}
7495
// clang-format off
7596
Lit.render(html`
7697
<div>
@@ -79,17 +100,22 @@ export class InterestGroupAccessGrid extends HTMLElement {
79100
title=${i18nString(UIStrings.allInterestGroupStorageEvents)}
80101
.data=${{iconName: 'info', color: 'var(--icon-default)', width: '16px'}}>
81102
</devtools-icon>
82-
${this.#renderGridOrNoDataMessage()}
103+
${this.#renderGrid()}
83104
</div>
84105
`, this.#shadow, {host: this});
85106
// clang-format on
86107
}
87108

88-
#renderGridOrNoDataMessage(): Lit.TemplateResult {
89-
if (this.#datastores.length === 0) {
90-
return html`<div class="no-events-message">${i18nString(UIStrings.noEvents)}</div>`;
91-
}
109+
#renderEmptyState(): Lit.TemplateResult {
110+
return html`
111+
<div class="empty-state">
112+
<span class="empty-state-header">${i18nString(UIStrings.noEvents)}</span>
113+
<span class="empty-state-description">${i18nString(UIStrings.interestGroupDescription)}</span>
114+
</div>
115+
`;
116+
}
92117

118+
#renderGrid(): Lit.TemplateResult {
93119
return html`
94120
<devtools-data-grid @select=${this.#onSelect} striped inline>
95121
<table>

front_end/panels/application/components/interestGroupAccessGrid.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* found in the LICENSE file.
55
*/
66
:host {
7+
display: flex;
78
padding: 20px;
9+
height: 100%;
810
}
911

1012
.heading {

front_end/panels/application/interestGroupStorageView.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@
77
devtools-interest-group-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)