Skip to content

Commit a1eb656

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[UI] Migrate SidebarInsightsTab to UI eng vision
Fixed: 407941810 Change-Id: I91edffdee4ffc8763680223bbeb68e4e1d177784 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7230586 Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Connor Clark <[email protected]> Reviewed-by: Danil Somsikov <[email protected]>
1 parent 7f8f2c8 commit a1eb656

File tree

5 files changed

+243
-194
lines changed

5 files changed

+243
-194
lines changed

front_end/panels/timeline/components/Sidebar.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/* eslint-disable @devtools/no-imperative-dom-api */
55

66
import type * as Trace from '../../../models/trace/trace.js';
7-
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
87
import * as UI from '../../../ui/legacy/legacy.js';
98

109
import {InsightActivated, InsightDeactivated} from './insights/SidebarInsight.js';
@@ -156,7 +155,7 @@ export class SidebarWidget extends UI.Widget.VBox {
156155
}
157156

158157
class InsightsView extends UI.Widget.VBox {
159-
#component = new SidebarInsightsTab();
158+
#component = SidebarInsightsTab.createWidgetElement();
160159

161160
constructor() {
162161
super();
@@ -165,21 +164,31 @@ class InsightsView extends UI.Widget.VBox {
165164
}
166165

167166
setParsedTrace(parsedTrace: Trace.TraceModel.ParsedTrace|null): void {
168-
this.#component.parsedTrace = parsedTrace;
167+
this.#component.widgetConfig = UI.Widget.widgetConfig(SidebarInsightsTab, {parsedTrace});
169168
}
170169

171170
getActiveInsight(): ActiveInsight|null {
172-
return this.#component.activeInsight;
171+
const widget = this.#component.getWidget();
172+
if (widget) {
173+
return widget.activeInsight;
174+
}
175+
176+
return null;
173177
}
174178

175179
setActiveInsight(active: ActiveInsight|null, opts: {highlight: boolean}): void {
176-
this.#component.activeInsight = active;
180+
const widget = this.#component.getWidget();
181+
if (!widget) {
182+
return;
183+
}
184+
185+
widget.activeInsight = active;
177186
if (opts.highlight && active) {
178187
// Wait for the rendering of the component to be done, otherwise we
179188
// might highlight the wrong insight. The UI needs to be fully
180189
// re-rendered before we can highlight the newly-expanded insight.
181-
void RenderCoordinator.done().then(() => {
182-
this.#component.highlightActiveInsight();
190+
void widget.updateComplete.then(() => {
191+
widget.highlightActiveInsight();
183192
});
184193
}
185194
}

front_end/panels/timeline/components/SidebarInsightsTab.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import {renderElementIntoDOM} from '../../../testing/DOMHelpers.js';
66
import {describeWithEnvironment} from '../../../testing/EnvironmentHelpers.js';
77
import {TraceLoader} from '../../../testing/TraceLoader.js';
8-
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
98

109
import * as Components from './components.js';
1110

@@ -16,11 +15,11 @@ describeWithEnvironment('SidebarInsightsTab', () => {
1615
const component = new Components.SidebarInsightsTab.SidebarInsightsTab();
1716
renderElementIntoDOM(component);
1817
component.parsedTrace = parsedTrace;
19-
await RenderCoordinator.done();
20-
assert.isOk(component.shadowRoot);
18+
await component.updateComplete;
19+
assert.isOk(component.element.shadowRoot);
2120

22-
const navigationURLs =
23-
Array.from(component.shadowRoot.querySelectorAll<HTMLElement>('details > summary')).map(elem => elem.title);
21+
const navigationURLs = Array.from(component.element.shadowRoot.querySelectorAll<HTMLElement>('details > summary'))
22+
.map(elem => elem.title);
2423
assert.deepEqual(navigationURLs, [
2524
'https://www.google.com/',
2625
'https://www.google.com/',
@@ -29,15 +28,16 @@ describeWithEnvironment('SidebarInsightsTab', () => {
2928
]);
3029

3130
const navigationURLLabels =
32-
Array.from(component.shadowRoot.querySelectorAll<HTMLElement>('details > summary')).map(elem => elem.innerText);
31+
Array.from(component.element.shadowRoot.querySelectorAll<HTMLElement>('details > summary'))
32+
.map(elem => elem.innerText);
3333
assert.deepEqual(navigationURLLabels, [
3434
'/',
3535
'/',
3636
'/imghp?hl=en&ogbl',
3737
'/search?q=dogs&hl=en&tbm=isch&source=hp&biw=738&bih=893&ei=_ER4YPD…&oq=dogs&gs_lcp=CgNpbWc…&sclient=img&ved=0ahUKEw…&uact=5',
3838
]);
3939

40-
const sets = component.shadowRoot.querySelectorAll('[data-insight-set-key]');
40+
const sets = component.element.shadowRoot.querySelectorAll('[data-insight-set-key]');
4141
assert.lengthOf(sets, 4); // same number of sets as there are navigations
4242
});
4343
});

0 commit comments

Comments
 (0)