|
2 | 2 | {{$defaultBranch := $.root.BranchName}}{{if and .root.IsViewTag (not .noTag)}}{{$defaultBranch = .root.TagName}}{{end}}{{if eq $defaultBranch ""}}{{$defaultBranch = $.root.Repository.DefaultBranch}}{{end}}
|
3 | 3 | {{$type := ""}}{{if and .root.IsViewTag (not .noTag)}}{{$type = "tag"}}{{else if .root.IsViewBranch}}{{$type = "branch"}}{{else}}{{$type = "tree"}}{{end}}
|
4 | 4 | {{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
|
| 5 | + |
| 6 | +<script type="module"> |
| 7 | + const data = { |
| 8 | + 'textReleaseCompare': {{.root.locale.Tr "repo.release.compare"}}, |
| 9 | + 'textCreateTag': {{.root.locale.Tr "repo.tag.create_tag"}}, |
| 10 | + 'textCreateBranch': {{.root.locale.Tr "repo.branch.create_branch"}}, |
| 11 | + 'textCreateBranchFrom': {{.root.locale.Tr "repo.branch.create_from"}}, |
| 12 | + 'textBranches': {{.root.locale.Tr "repo.branches"}}, |
| 13 | + 'textTags': {{.root.locale.Tr "repo.tags"}}, |
| 14 | + |
| 15 | + 'mode': '{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}', |
| 16 | + 'showBranchesInDropdown': {{$showBranchesInDropdown}}, |
| 17 | + 'searchFieldPlaceholder': '{{if $.noTag}}{{.root.locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{.root.locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.locale.Tr "repo.find_tag"}}{{end}}...', |
| 18 | + 'branchForm': {{$.branchForm}}, |
| 19 | + 'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}}, |
| 20 | + 'setAction': {{.setAction}}, |
| 21 | + 'submitForm': {{.submitForm}}, |
| 22 | + 'viewType': {{$type}}, |
| 23 | + 'refName': {{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}, |
| 24 | + 'commitIdShort': {{ShortSha .root.CommitID}}, |
| 25 | + 'tagName': {{.root.TagName}}, |
| 26 | + 'branchName': {{.root.BranchName}}, |
| 27 | + 'noTag': {{.noTag}}, |
| 28 | + 'branches': {{.root.Branches}}, |
| 29 | + 'tags': {{.root.Tags}}, |
| 30 | + 'defaultBranch': {{$defaultBranch}}, |
| 31 | + 'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}', |
| 32 | + 'branchURLSuffix': '{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}', |
| 33 | + 'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if $release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}', |
| 34 | + 'tagURLSuffix': '{{if .tagURLSuffix}}{{.tagURLSuffix}}{{else if $release}}...{{if $release.IsDraft}}{{PathEscapeSegments $release.Target}}{{else}}{{if $release.TagName}}{{PathEscapeSegments $release.TagName}}{{else}}{{PathEscapeSegments $release.Sha1}}{{end}}{{end}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}', |
| 35 | + 'repoLink': {{.root.RepoLink}}, |
| 36 | + 'treePath': {{.root.TreePath}}, |
| 37 | + 'branchNameSubURL': {{.root.BranchNameSubURL}}, |
| 38 | + 'noResults': {{.root.locale.Tr "repo.pulls.no_results"}}, |
| 39 | + }; |
| 40 | + {{if .release}} |
| 41 | + data.release = { |
| 42 | + 'tagName': {{.release.TagName}}, |
| 43 | + }; |
| 44 | + {{end}} |
| 45 | + window.config.pageData.branchDropdownDataList = window.config.pageData.branchDropdownDataList || []; |
| 46 | + window.config.pageData.branchDropdownDataList.push(data); |
| 47 | +</script> |
| 48 | + |
5 | 49 | <div class="fitted item choose reference">
|
6 |
| - <div class="ui floating filter dropdown custom" |
7 |
| - data-branch-form="{{if $.branchForm}}{{$.branchForm}}{{end}}" |
8 |
| - data-can-create-branch="{{if .canCreateBranch}}{{.canCreateBranch}}{{else}}{{.root.CanCreateBranch}}{{end}}" |
9 |
| - data-no-results="{{.root.locale.Tr "repo.pulls.no_results"}}" |
10 |
| - data-set-action="{{.setAction}}" data-submit-form="{{.submitForm}}" |
11 |
| - data-view-type="{{$type}}" |
12 |
| - data-ref-name="{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}" |
13 |
| - data-branch-url-prefix="{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}" |
14 |
| - data-branch-url-suffix="{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}" |
15 |
| - data-tag-url-prefix="{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if $release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}" |
16 |
| - data-tag-url-suffix="{{if .tagURLSuffix}}{{.tagURLSuffix}}{{else if $release}}...{{if $release.IsDraft}}{{PathEscapeSegments $release.Target}}{{else}}{{if $release.TagName}}{{PathEscapeSegments $release.TagName}}{{else}}{{PathEscapeSegments $release.Sha1}}{{end}}{{end}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}"> |
| 50 | + <div class="ui floating filter dropdown custom"> |
17 | 51 | <button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
|
18 | 52 | <span class="text gt-df gt-ac gt-mr-2">
|
19 |
| - {{if $release}} |
20 |
| - {{.root.locale.Tr "repo.release.compare"}} |
21 |
| - {{else}} |
22 |
| - <span :class="{visible: isViewTag}" v-if="isViewTag" {{if not (eq $type "tag")}}v-cloak{{end}}>{{svg "octicon-tag"}}</span> |
23 |
| - <span :class="{visible: isViewBranch}" v-if="isViewBranch" {{if not (eq $type "branch")}}v-cloak{{end}}>{{svg "octicon-git-branch"}}</span> |
24 |
| - <span :class="{visible: isViewTree}" v-if="isViewTree" {{if not (eq $type "tree")}}v-cloak{{end}}>{{svg "octicon-git-branch"}}</span> |
25 |
| - <strong ref="dropdownRefName" class="gt-ml-3">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong> |
26 |
| - {{end}} |
| 53 | + {{/* v-cloak is used to hide unnecessary elements before Vue componment is mounted */}} |
| 54 | + <span v-cloak v-if="release">${ textReleaseCompare }</span> |
| 55 | + <span :class="{visible: isViewTag}" v-if="isViewTag" {{if not (eq $type "tag")}}v-cloak{{end}}>{{svg "octicon-tag"}}</span> |
| 56 | + <span :class="{visible: isViewBranch}" v-if="isViewBranch" {{if not (eq $type "branch")}}v-cloak{{end}}>{{svg "octicon-git-branch"}}</span> |
| 57 | + <span :class="{visible: isViewTree}" v-if="isViewTree" {{if not (eq $type "tree")}}v-cloak{{end}}>{{svg "octicon-git-branch"}}</span> |
| 58 | + <strong ref="dropdownRefName" class="gt-ml-3">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong> |
27 | 59 | </span>
|
28 | 60 | {{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
29 | 61 | </button>
|
30 |
| - <div class="data gt-hidden" data-mode="{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}"> |
31 |
| - {{if $showBranchesInDropdown}} |
32 |
| - {{range .root.Branches}} |
33 |
| - <div class="item branch {{if eq $defaultBranch .}}selected{{end}}" data-url="{{PathEscapeSegments .}}">{{.}}</div> |
34 |
| - {{end}} |
35 |
| - {{end}} |
36 |
| - {{if (not .noTag)}} |
37 |
| - {{range .root.Tags}} |
38 |
| - {{if $release}} |
39 |
| - <div class="item tag {{if eq $release.TagName .}}selected{{end}}" data-url="{{PathEscapeSegments .}}">{{.}}</div> |
40 |
| - {{else}} |
41 |
| - <div class="item tag {{if eq $defaultBranch .}}selected{{end}}" data-url="{{PathEscapeSegments .}}">{{.}}</div> |
42 |
| - {{end}} |
43 |
| - {{end}} |
44 |
| - {{end}} |
45 |
| - </div> |
46 | 62 | <div class="menu transition" :class="{visible: menuVisible}" v-if="menuVisible" v-cloak>
|
47 | 63 | <div class="ui icon search input">
|
48 | 64 | <i class="icon gt-df gt-ac gt-jc gt-m-0">{{svg "octicon-filter" 16}}</i>
|
49 |
| - <input name="search" ref="searchField" autocomplete="off" v-model="searchTerm" @keydown="keydown($event)" placeholder="{{if $.noTag}}{{.root.locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{.root.locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.locale.Tr "repo.find_tag"}}{{end}}..."> |
| 65 | + <input name="search" ref="searchField" autocomplete="off" v-model="searchTerm" @keydown="keydown($event)" :placeholder="searchFieldPlaceholder"> |
50 | 66 | </div>
|
51 |
| - {{if $showBranchesInDropdown}} |
| 67 | + <template v-if="showBranchesInDropdown"> |
52 | 68 | <div class="header branch-tag-choice">
|
53 | 69 | <div class="ui grid">
|
54 | 70 | <div class="two column row">
|
55 | 71 | <a class="reference column" href="#" @click="createTag = false; mode = 'branches'; focusSearchField()">
|
56 |
| - <span class="text" :class="{black: mode == 'branches'}"> |
57 |
| - {{svg "octicon-git-branch" 16 "gt-mr-2"}}{{.root.locale.Tr "repo.branches"}} |
| 72 | + <span class="text" :class="{black: mode === 'branches'}"> |
| 73 | + {{svg "octicon-git-branch" 16 "gt-mr-2"}}${ textBranches } |
58 | 74 | </span>
|
59 | 75 | </a>
|
60 |
| - {{if not .noTag}} |
| 76 | + <template v-if="!noTag"> |
61 | 77 | <a class="reference column" href="#" @click="createTag = true; mode = 'tags'; focusSearchField()">
|
62 |
| - <span class="text" :class="{black: mode == 'tags'}"> |
63 |
| - {{svg "octicon-tag" 16 "gt-mr-2"}}{{.root.locale.Tr "repo.tags"}} |
| 78 | + <span class="text" :class="{black: mode === 'tags'}"> |
| 79 | + {{svg "octicon-tag" 16 "gt-mr-2"}}${ textTags } |
64 | 80 | </span>
|
65 | 81 | </a>
|
66 |
| - {{end}} |
| 82 | + </template> |
67 | 83 | </div>
|
68 | 84 | </div>
|
69 | 85 | </div>
|
70 |
| - {{end}} |
| 86 | + </template> |
71 | 87 | <div class="scrolling menu" ref="scrollContainer">
|
72 |
| - <div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active == index}" @click="selectItem(item)" :ref="'listItem' + index">${ item.name }</div> |
73 |
| - <div class="item" v-if="showCreateNewBranch" :class="{active: active == filteredItems.length}" :ref="'listItem' + filteredItems.length"> |
| 88 | + <div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active === index}" @click="selectItem(item)" :ref="'listItem' + index">${ item.name }</div> |
| 89 | + <div class="item" v-if="showCreateNewBranch" :class="{active: active === filteredItems.length}" :ref="'listItem' + filteredItems.length"> |
74 | 90 | <a href="#" @click="createNewBranch()">
|
75 | 91 | <div v-show="createTag">
|
76 | 92 | <i class="reference tags icon"></i>
|
77 |
| - {{.root.locale.Tr "repo.tag.create_tag" `${ searchTerm }` | Safe}} |
| 93 | + <span v-html="textCreateTag.replace('%s', searchTerm)"></span> |
78 | 94 | </div>
|
79 | 95 | <div v-show="!createTag">
|
80 | 96 | {{svg "octicon-git-branch"}}
|
81 |
| - {{.root.locale.Tr "repo.branch.create_branch" `${ searchTerm }` | Safe}} |
| 97 | + <span v-html="textCreateBranch.replace('%s', searchTerm)"></span> |
82 | 98 | </div>
|
83 | 99 | <div class="text small">
|
84 |
| - {{if or .root.IsViewBranch $release}} |
85 |
| - {{.root.locale.Tr "repo.branch.create_from" .root.BranchName}} |
86 |
| - {{else if .root.IsViewTag}} |
87 |
| - {{.root.locale.Tr "repo.branch.create_from" .root.TagName}} |
88 |
| - {{else}} |
89 |
| - {{.root.locale.Tr "repo.branch.create_from" (ShortSha .root.CommitID)}} |
90 |
| - {{end}} |
| 100 | + <span v-if="isViewBranch || release">${ textCreateBranchFrom.replace('%s', branchName) }</span> |
| 101 | + <span v-else-if="isViewTag">${ textCreateBranchFrom.replace('%s', tagName) }</span> |
| 102 | + <span v-else>${ textCreateBranchFrom.replace('%s', commitIdShort) }</span> |
91 | 103 | </div>
|
92 | 104 | </a>
|
93 | 105 | <form ref="newBranchForm" action="{{.root.RepoLink}}/branches/_new/{{.root.BranchNameSubURL}}" method="post">
|
94 |
| - {{.root.CsrfTokenHtml}} |
| 106 | + <input type="hidden" name="_csrf" :value="csrfToken"> |
95 | 107 | <input type="hidden" name="new_branch_name" v-model="searchTerm">
|
96 | 108 | <input type="hidden" name="create_tag" v-model="createTag">
|
97 |
| - {{if $.root.TreePath}} |
98 |
| - <input type="hidden" name="current_path" value="{{.root.TreePath}}"> |
99 |
| - {{end}} |
| 109 | + <input type="hidden" name="current_path" v-model="treePath" v-if="treePath"> |
100 | 110 | </form>
|
101 | 111 | </div>
|
102 | 112 | </div>
|
|
0 commit comments