Skip to content

Commit 99e14cc

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Use <devtools-new-data-grid> in the prerendering RuleSetGrid
To make it work, call onResize to the data grid and forward click events to the config elements. Bug: 390346490 Change-Id: I2aea18013cfe7a84ca56d39e7e4a16f6d78bcdff Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6198366 Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Danil Somsikov <[email protected]>
1 parent 5fae99f commit 99e14cc

File tree

10 files changed

+160
-251
lines changed

10 files changed

+160
-251
lines changed

front_end/panels/application/preloading/PreloadingView.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ function createRuleSetView(target: SDK.Target.Target): Resources.PreloadingView.
245245
const view = new Resources.PreloadingView.PreloadingRuleSetView(model);
246246
const container = new UI.Widget.VBox();
247247
const div = document.createElement('div');
248+
view.contentElement.style.display = 'block';
249+
view.contentElement.style.width = '640px';
250+
view.contentElement.style.height = '480px';
251+
248252
renderElementIntoDOM(div);
249253
container.markAsRoot();
250254
container.show(div);
@@ -366,12 +370,7 @@ describeWithMockConnection('PreloadingRuleSetView', () => {
366370

367371
);
368372

369-
const cells = [
370-
{columnId: 'id', value: 'ruleSetId:0.2'},
371-
{columnId: 'Validity', value: 'Invalid'},
372-
];
373-
ruleSetGridComponent.dispatchEvent(
374-
new DataGrid.DataGridEvents.BodyCellFocusedEvent({columnId: 'Validity', value: 'Invalid'}, {cells}));
373+
ruleSetGridComponent.dispatchEvent(new CustomEvent('select', {detail: 'ruleSetId:0.2'}));
375374

376375
await RenderCoordinator.done();
377376

front_end/panels/application/preloading/PreloadingView.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export class PreloadingRuleSetView extends UI.Widget.VBox {
220220
this.contentElement.insertBefore(this.warningsContainer, this.contentElement.firstChild);
221221
this.warningsView.show(this.warningsContainer);
222222

223-
this.ruleSetGrid.addEventListener('cellfocused', this.onRuleSetsGridCellFocused.bind(this));
223+
this.ruleSetGrid.addEventListener('select', this.onRuleSetsGridCellFocused.bind(this));
224224

225225
const onPrettyPrintToggle = (): void => {
226226
this.shouldPrettyPrint = !this.shouldPrettyPrint;
@@ -307,9 +307,8 @@ export class PreloadingRuleSetView extends UI.Widget.VBox {
307307
}
308308

309309
private onRuleSetsGridCellFocused(event: Event): void {
310-
const focusedEvent = event as DataGrid.DataGridEvents.BodyCellFocusedEvent;
311-
this.focusedRuleSetId =
312-
focusedEvent.data.row.cells.find(cell => cell.columnId === 'id')?.value as Protocol.Preload.RuleSetId;
310+
const focusedEvent = event as CustomEvent<Protocol.Preload.RuleSetId>;
311+
this.focusedRuleSetId = focusedEvent.detail;
313312
this.render();
314313
}
315314

front_end/panels/application/preloading/components/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ devtools_module("components") {
5555
"../../../../ui/components/text_prompt:bundle",
5656
"../../../../ui/components/tree_outline:bundle",
5757
"../../../../ui/legacy:bundle",
58+
"../../../../ui/legacy/components/data_grid:bundle",
5859
"../../../../ui/legacy/components/source_frame:bundle",
5960
"../../../../ui/legacy/components/utils:bundle",
6061
"../helper:bundle",

front_end/panels/application/preloading/components/PreloadingGrid.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as Protocol from '../../../../generated/protocol.js';
88
import {assertGridContents, getCellByIndexes} from '../../../../testing/DataGridHelpers.js';
99
import {renderElementIntoDOM} from '../../../../testing/DOMHelpers.js';
1010
import {describeWithEnvironment} from '../../../../testing/EnvironmentHelpers.js';
11-
import type * as DataGrid from '../../../../ui/components/data_grid/data_grid.js';
1211
import * as RenderCoordinator from '../../../../ui/components/render_coordinator/render_coordinator.js';
1312

1413
import * as PreloadingComponents from './components.js';
@@ -17,7 +16,7 @@ const {urlString} = Platform.DevToolsPath;
1716

1817
async function assertRenderResult(
1918
rowsInput: PreloadingComponents.PreloadingGrid.PreloadingGridData, headerExpected: string[],
20-
rowsExpected: string[][]): Promise<DataGrid.DataGrid.DataGrid> {
19+
rowsExpected: string[][]): Promise<Element> {
2120
const component = new PreloadingComponents.PreloadingGrid.PreloadingGrid();
2221
component.update(rowsInput);
2322
renderElementIntoDOM(component);

front_end/panels/application/preloading/components/RuleSetGrid.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as Protocol from '../../../../generated/protocol.js';
77
import {assertGridContents} from '../../../../testing/DataGridHelpers.js';
88
import {renderElementIntoDOM} from '../../../../testing/DOMHelpers.js';
99
import {describeWithEnvironment} from '../../../../testing/EnvironmentHelpers.js';
10-
import type * as DataGrid from '../../../../ui/components/data_grid/data_grid.js';
1110
import * as RenderCoordinator from '../../../../ui/components/render_coordinator/render_coordinator.js';
1211

1312
import * as PreloadingComponents from './components.js';
@@ -16,8 +15,11 @@ const {urlString} = Platform.DevToolsPath;
1615

1716
async function assertRenderResult(
1817
rowsInput: PreloadingComponents.RuleSetGrid.RuleSetGridData, headerExpected: string[],
19-
rowsExpected: string[][]): Promise<DataGrid.DataGrid.DataGrid> {
18+
rowsExpected: string[][]): Promise<Element> {
2019
const component = new PreloadingComponents.RuleSetGrid.RuleSetGrid();
20+
component.style.display = 'block';
21+
component.style.width = '640px';
22+
component.style.height = '480px';
2123
component.update(rowsInput);
2224
renderElementIntoDOM(component);
2325
await RenderCoordinator.done();

0 commit comments

Comments
 (0)