mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-26 10:13:34 +00:00
feat(diff): Add search and extension filter to diff sidebar (#37068)
Adds a search box and a file-extension filter to the pull request diff sidebar, so reviewers can narrow a large diff down to the files they care about. Both filters apply to the file tree and to the diff itself. The extension menu follows GitHub: extensions sorted alphabetically, dotfiles and extension-less files in their own buckets, and the selection kept in the same `file-filters[]` query parameter, so a filtered view is shareable and survives a reload. The menu can list every extension in a diff, so `createTippy` gains an opt-in `limitSizeToViewport` option that caps a popup to the space left in the viewport and scrolls its content. Popups that do not ask for it are unchanged. Closes https://github.com/go-gitea/gitea/issues/27256 Signed-off-by: silverwind <me@silverwind.io> Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Nicolas <bircni@icloud.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -63,6 +63,7 @@ func isExcludedEntry(entry *git.TreeEntry) bool {
|
||||
// WebDiffFileItem is used by frontend, check the field names in frontend before changing
|
||||
type WebDiffFileItem struct {
|
||||
FullName string
|
||||
OldFullName string
|
||||
DisplayName string
|
||||
NameHash string
|
||||
DiffStatus string
|
||||
@@ -110,6 +111,9 @@ func transformDiffTreeForWeb(renderedIconPool *fileicon.RenderedIconPool, diffTr
|
||||
|
||||
for _, file := range diffTree.Files {
|
||||
item := &WebDiffFileItem{FullName: file.HeadPath, DiffStatus: file.Status}
|
||||
if file.BasePath != file.HeadPath {
|
||||
item.OldFullName = file.BasePath
|
||||
}
|
||||
item.IsViewed = filesViewedState[item.FullName] == pull_model.Viewed
|
||||
item.NameHash = git.HashFilePathForWebUI(item.FullName)
|
||||
item.FileIcon = fileicon.RenderEntryIconHTML(renderedIconPool, &fileicon.EntryInfo{BaseName: path.Base(file.HeadPath), EntryMode: file.HeadMode})
|
||||
|
||||
@@ -28,6 +28,12 @@ func TestTransformDiffTreeForWeb(t *testing.T) {
|
||||
HeadPath: "file1",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
},
|
||||
{
|
||||
Status: "renamed",
|
||||
BasePath: "file2-old",
|
||||
HeadPath: "file2",
|
||||
HeadMode: git.EntryModeBlob,
|
||||
},
|
||||
}}, map[string]pull_model.ViewedState{
|
||||
"dir-a/dir-a-x/file-deep": pull_model.Viewed,
|
||||
})
|
||||
@@ -62,6 +68,15 @@ func TestTransformDiffTreeForWeb(t *testing.T) {
|
||||
DiffStatus: "added",
|
||||
FileIcon: mockIconForFile(`svg-mfi-file`),
|
||||
},
|
||||
{
|
||||
EntryMode: "",
|
||||
DisplayName: "file2",
|
||||
FullName: "file2",
|
||||
OldFullName: "file2-old",
|
||||
NameHash: "cb99b709a1978bd205ab9dfd4c5aaa1fc91c7523",
|
||||
DiffStatus: "renamed",
|
||||
FileIcon: mockIconForFile(`svg-mfi-file`),
|
||||
},
|
||||
},
|
||||
},
|
||||
}, ret)
|
||||
|
||||
Reference in New Issue
Block a user