mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 23:33:15 -05:00
[FEAT] branch/tag dropdown for git-grep (#4262)
#3654 introduced support for searching non-default branches and tags. However, the results page lacked any indicator (aside from the url) on which branch/tag the searcg was performed. A branch dropdown was introduced to the code search page when git-grep is used both as an indicator and as a intrusive way to switch between branches/tags. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4262 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
153758d4de
commit
8546b01249
3 changed files with 14 additions and 2 deletions
1
release-notes/8.0.0/feat/4262.md
Normal file
1
release-notes/8.0.0/feat/4262.md
Normal file
|
@ -0,0 +1 @@
|
|||
Introduced branch/tag dropdown in code search page if using git-grep.
|
|
@ -2,6 +2,12 @@
|
|||
<div role="main" aria-label="{{.Title}}" class="page-content repository file list">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
{{if $.CodeIndexerDisabled}}
|
||||
{{$branchURLPrefix := printf "%s/search/branch/" $.RepoLink}}
|
||||
{{$tagURLPrefix := printf "%s/search/tag/" $.RepoLink}}
|
||||
{{$suffix := printf "?q=%s&fuzzy=%t" (.Keyword|QueryEscape) .IsFuzzy}}
|
||||
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mb-3" "branchURLPrefix" $branchURLPrefix "branchURLSuffix" $suffix "tagURLPrefix" $tagURLPrefix "tagURLSuffix" $suffix}}
|
||||
{{end}}
|
||||
{{template "shared/search/code/search" .}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -94,8 +94,13 @@ func testSearch(t *testing.T, url string, expected []string, indexer bool) {
|
|||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
msg := doc.Find(".repository").Find(".ui.container").Find(".ui.message[data-test-tag=grep]")
|
||||
assert.EqualValues(t, indexer, len(msg.Nodes) == 0)
|
||||
container := doc.Find(".repository").Find(".ui.container")
|
||||
|
||||
grepMsg := container.Find(".ui.message[data-test-tag=grep]")
|
||||
assert.EqualValues(t, indexer, len(grepMsg.Nodes) == 0)
|
||||
|
||||
branchDropdown := container.Find(".js-branch-tag-selector")
|
||||
assert.EqualValues(t, indexer, len(branchDropdown.Nodes) == 0)
|
||||
|
||||
filenames := resultFilenames(t, doc)
|
||||
assert.EqualValues(t, expected, filenames)
|
||||
|
|
Loading…
Reference in a new issue