Skip to content

Commit c7ac387

Browse files
bmeurerDevtools-frontend LUCI CQ
authored andcommitted
[issues] Prepare the front-end for AffectedRequest change.
We are going to change the `browser_protocol.pdl` in a follow-up back-end CL to make the `url` field of `AffectedRequest` mandatory and the `requestId` field optional. This will remove the confusion with issues for early CORS errors that happen before the `ResourceLoader` is created, and for which we simply don't have a request ID (and will never have one). With this CL, the front-end works independent of whether the `requestId` is provided or not, and can even deal with absent `url` fields (which will not happen anymore after the back-end CL is landed). Drive-by-fix: Tweak the CSS a bit, to ensure that the `<button>` inherits the correct text settings. Bug: 385693302 Change-Id: Ib529fd081e582fdaa5bea40cd902cd182b30b9a2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6111100 Reviewed-by: Andres Olivares <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]> Commit-Queue: Andres Olivares <[email protected]>
1 parent e032fc2 commit c7ac387

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

front_end/ui/components/request_link_icon/RequestLinkIcon.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,17 @@ export class RequestLinkIcon extends HTMLElement {
153153
return i18nString(UIStrings.requestUnavailableInTheNetwork);
154154
}
155155

156-
#getUrlForDisplaying(): Platform.DevToolsPath.UrlString|undefined {
157-
if (!this.#request) {
158-
return this.#affectedRequest?.url as Platform.DevToolsPath.UrlString;
156+
#getUrlForDisplaying(): string|undefined {
157+
if (!this.#displayURL) {
158+
return undefined;
159+
}
160+
if (this.#request) {
161+
return this.#request.url();
159162
}
160-
return this.#request.url();
163+
return this.#affectedRequest?.url;
161164
}
162165

163166
#maybeRenderURL(): LitHtml.LitTemplate {
164-
if (!this.#displayURL) {
165-
return LitHtml.nothing;
166-
}
167-
168167
const url = this.#getUrlForDisplaying();
169168
if (!url) {
170169
return LitHtml.nothing;
@@ -174,23 +173,29 @@ export class RequestLinkIcon extends HTMLElement {
174173
return html`<span title=${url}>${this.#urlToDisplay}</span>`;
175174
}
176175

177-
const filename = extractShortPath(url);
176+
const filename = extractShortPath(url as Platform.DevToolsPath.UrlString);
178177
return html`<span aria-label=${i18nString(UIStrings.shortenedURL)} title=${url}>${filename}</span>`;
179178
}
180179

181180
async #render(): Promise<void> {
182181
return coordinator.write(() => {
183-
// clang-format off
184-
LitHtml.render(html`
185-
<button class=${LitHtml.Directives.classMap({link: Boolean(this.#request)})}
186-
title=${this.#getTooltip()}
187-
jslog=${VisualLogging.link('request').track({click: true})}
188-
@click=${this.handleClick}>
189-
<devtools-icon name="arrow-up-down-circle"></devtools-icon>
190-
${this.#maybeRenderURL()}
191-
</button>`,
192-
this.#shadow, {host: this});
193-
// clang-format on
182+
// By default we render just the URL for the request link. If we also know
183+
// the concrete network request, or at least its request ID, we surround
184+
// the URL with a button, that opens the request in the Network panel.
185+
let template = this.#maybeRenderURL();
186+
if (this.#request || this.#affectedRequest?.requestId) {
187+
// clang-format off
188+
template = html`
189+
<button class=${LitHtml.Directives.classMap({link: Boolean(this.#request)})}
190+
title=${this.#getTooltip()}
191+
jslog=${VisualLogging.link('request').track({click: true})}
192+
@click=${this.handleClick}>
193+
<devtools-icon name="arrow-up-down-circle"></devtools-icon>
194+
${template}
195+
</button>`;
196+
// clang-format on
197+
}
198+
LitHtml.render(template, this.#shadow, {host: this});
194199
});
195200
}
196201
}

front_end/ui/components/request_link_icon/requestLinkIcon.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ button {
2121
background: transparent;
2222
margin: 0;
2323
padding: 0;
24+
font-family: inherit;
25+
font-size: inherit;
26+
color: inherit;
2427

2528
&.link {
2629
cursor: pointer;

0 commit comments

Comments
 (0)