Skip to content

Commit 9a2e154

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Use <devtools-new-data-grid> in EndpointsGrid.
Bug: 390346490 Change-Id: I5772e9131c65739102ab382c714c2690c3e7e8c3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6179488 Reviewed-by: Wolfgang Beyer <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent ffe4138 commit 9a2e154

File tree

6 files changed

+34
-62
lines changed

6 files changed

+34
-62
lines changed

front_end/panels/application/components/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ devtools_module("components") {
7070
"../../../ui/components/text_prompt:bundle",
7171
"../../../ui/components/tree_outline:bundle",
7272
"../../../ui/legacy:bundle",
73+
"../../../ui/legacy/components/data_grid:bundle",
7374
"../../../ui/legacy/components/source_frame:bundle",
7475
"../../../ui/legacy/components/utils:bundle",
7576
]

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,30 @@
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 {getHeaderCells, getValuesOfAllBodyRows} from '../../../testing/DataGridHelpers.js';
65
import {
7-
getElementWithinComponent,
86
renderElementIntoDOM,
97
} from '../../../testing/DOMHelpers.js';
108
import {describeWithLocale} from '../../../testing/EnvironmentHelpers.js';
11-
import * as DataGrid from '../../../ui/components/data_grid/data_grid.js';
129
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
1310

1411
import * as ApplicationComponents from './components.js';
1512

1613
const renderEndpointsGrid = async (data?: ApplicationComponents.EndpointsGrid.EndpointsGridData|null) => {
1714
const component = new ApplicationComponents.EndpointsGrid.EndpointsGrid();
15+
component.style.display = 'block';
16+
component.style.width = '640px';
17+
component.style.height = '480px';
1818
if (data) {
1919
component.data = data;
2020
}
2121
renderElementIntoDOM(component);
2222
assert.isNotNull(component.shadowRoot);
23-
await RenderCoordinator.done();
23+
await RenderCoordinator.done({waitForWork: true});
2424
if (!data) {
2525
return component;
2626
}
2727

28-
const controller = getElementWithinComponent(
29-
component, 'devtools-data-grid-controller', DataGrid.DataGridController.DataGridController);
30-
assert.isNotNull(controller.shadowRoot);
31-
const datagrid = getElementWithinComponent(controller, 'devtools-data-grid', DataGrid.DataGrid.DataGrid);
28+
const datagrid = component.shadowRoot.querySelector('devtools-new-data-grid')!;
3229
assert.isNotNull(datagrid.shadowRoot);
3330
return datagrid;
3431
};
@@ -64,10 +61,13 @@ describeWithLocale('EndpointsGrid', () => {
6461
const dataGrid = await renderEndpointsGrid(data);
6562
assert.isNotNull(dataGrid.shadowRoot);
6663

67-
const header = getHeaderCells(dataGrid.shadowRoot).map(({textContent}) => textContent!.trim());
64+
const header = [...dataGrid.shadowRoot!.querySelectorAll('th[jslog]')].map(({textContent}) => textContent!.trim());
6865
assert.deepEqual(header, ['Origin', 'Name', 'URL']);
6966

70-
const rowValues = getValuesOfAllBodyRows(dataGrid.shadowRoot);
67+
const rowValues = [...dataGrid.shadowRoot!.querySelectorAll('tbody tr[jslog]')].map(row => {
68+
const cells = [...row.querySelectorAll('td[jslog]')];
69+
return cells.map(cell => cell.textContent!.trim());
70+
});
7171
assert.lengthOf(rowValues, 3);
7272
assert.strictEqual(rowValues[0][0], 'https://www.my-page.com', 'Endpoint origin does not match');
7373
assert.strictEqual(rowValues[0][1], 'main-endpoint', 'Endpoint name does not match');

front_end/panels/application/components/EndpointsGrid.ts

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +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 '../../../ui/components/data_grid/data_grid.js';
5+
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-
import type * as DataGrid from '../../../ui/components/data_grid/data_grid.js';
109
import * as LitHtml from '../../../ui/lit-html/lit-html.js';
1110
import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
1211

@@ -44,41 +43,28 @@ export class EndpointsGrid extends HTMLElement {
4443
}
4544

4645
#render(): void {
47-
const endpointsGridData: DataGrid.DataGridController.DataGridControllerData = {
48-
columns: [
49-
{
50-
id: 'origin',
51-
title: i18n.i18n.lockedString('Origin'),
52-
widthWeighting: 30,
53-
hideable: false,
54-
visible: true,
55-
},
56-
{
57-
id: 'name',
58-
title: i18n.i18n.lockedString('Name'),
59-
widthWeighting: 20,
60-
hideable: false,
61-
visible: true,
62-
},
63-
{
64-
id: 'url',
65-
title: i18n.i18n.lockedString('URL'),
66-
widthWeighting: 30,
67-
hideable: false,
68-
visible: true,
69-
},
70-
],
71-
rows: this.#buildReportRows(),
72-
};
73-
7446
// Disabled until https://crbug.com/1079231 is fixed.
7547
// clang-format off
7648
render(html`
7749
<div class="reporting-container" jslog=${VisualLogging.section('endpoints')}>
7850
<div class="reporting-header">${i18n.i18n.lockedString('Endpoints')}</div>
7951
${this.#endpoints.size > 0 ? html`
80-
<devtools-data-grid-controller .data=${endpointsGridData}>
81-
</devtools-data-grid-controller>
52+
<devtools-new-data-grid striped>
53+
<table>
54+
<tr>
55+
<th id="origin" weight="30">${i18n.i18n.lockedString('Origin')}</th>
56+
<th id="name" weight="20">${i18n.i18n.lockedString('Name')}</th>
57+
<th id="url" weight="30">${i18n.i18n.lockedString('URL')}</th>
58+
</tr>
59+
${Array.from(this.#endpoints).map(([origin, endpointArray]) =>
60+
endpointArray.map(endpoint => html`<tr>
61+
<td>${origin}</td>
62+
<td>${endpoint.groupName}</td>
63+
<td>${endpoint.url}</td>
64+
</tr>`))
65+
.flat()}
66+
</table>
67+
</devtools-new-data-grid>
8268
` : html`
8369
<div class="reporting-placeholder">
8470
<div>${i18nString(UIStrings.noEndpointsToDisplay)}</div>
@@ -88,20 +74,6 @@ export class EndpointsGrid extends HTMLElement {
8874
`, this.#shadow, {host: this});
8975
// clang-format on
9076
}
91-
92-
#buildReportRows(): DataGrid.DataGridUtils.Row[] {
93-
return Array.from(this.#endpoints)
94-
.map(([origin, endpointArray]) => endpointArray.map(endpoint => {
95-
return {
96-
cells: [
97-
{columnId: 'origin', value: origin},
98-
{columnId: 'name', value: endpoint.groupName},
99-
{columnId: 'url', value: endpoint.url},
100-
],
101-
};
102-
}))
103-
.flat();
104-
}
10577
}
10678

10779
customElements.define('devtools-resources-endpoints-grid', EndpointsGrid);

front_end/panels/application/components/reportingApiGrid.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
text-align: center;
3333
}
3434

35-
devtools-data-grid-controller {
36-
border: 1px solid var(--sys-color-divider);
35+
devtools-new-data-grid {
36+
flex: auto;
3737
}
3838

3939
.inline-icon {

test/e2e/application/reporting-api_test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ describe('The Reporting API Page', () => {
6060
if (!endpointsGrid) {
6161
assert.fail('Could not find data-grid');
6262
}
63-
const dataGrid = await getDataGrid(endpointsGrid);
64-
const innerText = await getInnerTextOfDataGridCells(dataGrid, 2, true);
63+
const innerText = await getInnerTextOfDataGridCells(endpointsGrid, 2, true);
6564
assert.strictEqual(innerText[0][0], `https://localhost:${getTestServerPort()}`);
6665
assert.strictEqual(innerText[0][1], 'default');
6766
assert.strictEqual(innerText[0][2], 'https://reports.example/default');

test/e2e/helpers/datagrid-helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ export async function getDataGridRows(
1414
const handlers = await (async () => {
1515
if (matchExactNumberOfRows) {
1616
return await waitForFunction(async () => {
17-
const rows = await $$('tbody > tr:not(.padding-row):not(.hidden)', dataGrid);
17+
const rows = await $$('tbody > tr[jslog]:not(.hidden)', dataGrid);
1818
return rows.length === expectedNumberOfRows ? rows : undefined;
1919
});
2020
}
2121
return await waitForFunction(async () => {
22-
const rows = await $$('tbody > tr:not(.padding-row):not(.hidden)', dataGrid);
22+
const rows = await $$('tbody > tr[jslog]:not(.hidden)', dataGrid);
2323
return rows.length >= expectedNumberOfRows ? rows : undefined;
2424
});
2525
})();
2626

27-
return Promise.all(handlers.map(handler => $$<HTMLTableCellElement>('td[data-row-index]:not(.hidden)', handler)));
27+
return Promise.all(handlers.map(handler => $$<HTMLTableCellElement>('td[jslog]:not(.hidden)', handler)));
2828
}
2929

3030
export async function getDataGrid(root?: ElementHandle) {

0 commit comments

Comments
 (0)