Skip to content

Commit 2252695

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[CombinedDiffView] Make the file name a link to open in sources panel
Fixed: 402735506 Change-Id: Icb754ba0349b22124dd5cae3a4b2dd900f5b46c0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6372359 Commit-Queue: Ergün Erdoğmuş <[email protected]> Commit-Queue: Wolfgang Beyer <[email protected]> Auto-Submit: Ergün Erdoğmuş <[email protected]> Reviewed-by: Wolfgang Beyer <[email protected]>
1 parent af25078 commit 2252695

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

front_end/panels/changes/CombinedDiffView.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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 * as Common from '../../core/common/common.js';
56
import * as Host from '../../core/host/host.js';
67
import * as i18n from '../../core/i18n/i18n.js';
78
import * as Platform from '../../core/platform/platform.js';
@@ -38,6 +39,7 @@ interface SingleDiffViewInput {
3839
diff: Diff.Diff.DiffArray;
3940
copied: boolean;
4041
onCopy: (fileUrl: string, diff: Diff.Diff.DiffArray) => void;
42+
onFileNameClick: (fileUrl: string) => void;
4143
}
4244

4345
export interface ViewInput {
@@ -47,15 +49,15 @@ export interface ViewInput {
4749
type View = (input: ViewInput, output: undefined, target: HTMLElement) => void;
4850

4951
function renderSingleDiffView(singleDiffViewInput: SingleDiffViewInput): Lit.TemplateResult {
50-
const {fileName, fileUrl, mimeType, icon, diff, copied, onCopy} = singleDiffViewInput;
52+
const {fileName, fileUrl, mimeType, icon, diff, copied, onCopy, onFileNameClick} = singleDiffViewInput;
5153

5254
return html`
5355
<details open>
5456
<summary>
5557
<div class="summary-left">
5658
<devtools-icon class="drop-down-icon" .name=${'arrow-drop-down'}></devtools-icon>
5759
${icon}
58-
<span class="file-name">${fileName}</span>
60+
<button class="file-name-link" @click=${() => onFileNameClick(fileUrl)}>${fileName}</button>
5961
</div>
6062
<div class="summary-right">
6163
${copied ? html`<span class="copied">${i18nString(UIStrings.copied)}</span>` : html`
@@ -125,6 +127,11 @@ export class CombinedDiffView extends UI.Widget.Widget {
125127
}, COPIED_TO_CLIPBOARD_TEXT_TIMEOUT_MS);
126128
}
127129

130+
#onFileNameClick(fileUrl: string): void {
131+
const uiSourceCode = this.#modifiedUISourceCodes.find(uiSourceCode => uiSourceCode.url() === fileUrl);
132+
void Common.Revealer.reveal(uiSourceCode);
133+
}
134+
128135
async #initializeModifiedUISourceCodes(): Promise<void> {
129136
if (!this.#workspaceDiff) {
130137
return;
@@ -183,6 +190,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
183190
icon: PanelUtils.PanelUtils.getIconForSourceFile(uiSourceCode, {width: 18, height: 18}),
184191
copied: this.#copiedFiles[uiSourceCode.url()],
185192
onCopy: this.#onCopyDiff.bind(this),
193+
onFileNameClick: this.#onFileNameClick.bind(this),
186194
};
187195
})
188196
.sort((a, b) => Platform.StringUtilities.compare(a.fileName, b.fileName));

front_end/panels/changes/combinedDiffView.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@
3030
align-items: center;
3131
flex-grow: 0;
3232

33-
.file-name {
33+
.file-name-link {
3434
padding-left: var(--sys-size-5);
3535
width: 100%;
3636
text-overflow: ellipsis;
3737
overflow: hidden;
3838
text-wrap-mode: nowrap;
39+
border: none;
40+
background: none;
41+
font: inherit;
42+
43+
&:hover {
44+
color: var(--sys-color-primary);
45+
text-decoration: underline;
46+
cursor: pointer;
47+
}
3948
}
4049

4150
devtools-icon {

0 commit comments

Comments
 (0)