Skip to content

Commit e29d3dd

Browse files
Adam RaineDevtools-frontend LUCI CQ
authored andcommitted
[ImageDelivery] Hide empty sidebar sections
Bug: 372897377 Change-Id: I87b80bbff27f8e819aa17ec056c61351fead6180 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6048718 Commit-Queue: Adam Raine <[email protected]> Auto-Submit: Adam Raine <[email protected]> Reviewed-by: Connor Clark <[email protected]>
1 parent 0c0c844 commit e29d3dd

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

front_end/panels/timeline/components/insights/ImageDelivery.ts

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,43 @@ export class ImageDelivery extends BaseInsightComponent<ImageDeliveryInsightMode
101101

102102
const optimizableImages = this.model.optimizableImages;
103103

104-
// clang-format off
105-
return html`
106-
<div class="insight-section">
107-
<devtools-performance-table
108-
.data=${{
109-
insight: this,
110-
headers: [i18nString(UIStrings.sizeAppropriately)],
111-
rows: this.#getTopImagesAsRows(optimizableImages, type => type === 'responsive-size', true),
112-
}}>
113-
</devtools-performance-table>
114-
</div>
115-
<div class="insight-section">
116-
<devtools-performance-table
117-
.data=${{
118-
insight: this,
119-
headers: [i18nString(UIStrings.optimizeFile)],
120-
rows: this.#getTopImagesAsRows(optimizableImages, type => type !== 'responsive-size'),
121-
}}>
122-
</devtools-performance-table>
123-
</div>`;
124-
// clang-format on
104+
const sections = [];
105+
106+
const responsiveSizeRows = this.#getTopImagesAsRows(optimizableImages, type => type === 'responsive-size', true);
107+
if (responsiveSizeRows.length) {
108+
// clang-format off
109+
sections.push(html`
110+
<div class="insight-section">
111+
<devtools-performance-table
112+
.data=${{
113+
insight: this,
114+
headers: [i18nString(UIStrings.sizeAppropriately)],
115+
rows: responsiveSizeRows,
116+
}}>
117+
</devtools-performance-table>
118+
</div>
119+
`);
120+
// clang-format on
121+
}
122+
123+
const optimizeFormatRows = this.#getTopImagesAsRows(optimizableImages, type => type !== 'responsive-size');
124+
if (optimizeFormatRows.length) {
125+
// clang-format off
126+
sections.push(html`
127+
<div class="insight-section">
128+
<devtools-performance-table
129+
.data=${{
130+
insight: this,
131+
headers: [i18nString(UIStrings.optimizeFile)],
132+
rows: optimizeFormatRows,
133+
}}>
134+
</devtools-performance-table>
135+
</div>
136+
`);
137+
// clang-format on
138+
}
139+
140+
return html`${sections}`;
125141
}
126142

127143
override render(): void {

0 commit comments

Comments
 (0)