Skip to content

Commit 7553c9a

Browse files
committed
refactor
1 parent 75022f8 commit 7553c9a

12 files changed

+350
-301
lines changed

templates/repo/branch_dropdown.tmpl

+32-66
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
{{$release := .release}}
2-
{{$defaultBranch := $.root.BranchName}}{{if and .root.IsViewTag (not .noTag)}}{{$defaultBranch = .root.TagName}}{{end}}{{if eq $defaultBranch ""}}{{$defaultBranch = $.root.Repository.DefaultBranch}}{{end}}
3-
{{$type := ""}}{{if and .root.IsViewTag (not .noTag)}}{{$type = "tag"}}{{else if .root.IsViewBranch}}{{$type = "branch"}}{{else}}{{$type = "tree"}}{{end}}
1+
{{$defaultBranch := $.root.BranchName}}
2+
{{if and .root.IsViewTag (not .noTag)}}
3+
{{$defaultBranch = .root.TagName}}
4+
{{end}}
5+
{{if eq $defaultBranch ""}}
6+
{{$defaultBranch = $.root.Repository.DefaultBranch}}
7+
{{end}}
8+
9+
{{$type := ""}}
10+
{{if and .root.IsViewTag (not .noTag)}}
11+
{{$type = "tag"}}
12+
{{else if .root.IsViewBranch}}
13+
{{$type = "branch"}}
14+
{{else}}
15+
{{$type = "tree"}}
16+
{{end}}
17+
418
{{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
519

620
<script type="module">
@@ -30,8 +44,8 @@
3044
'defaultBranch': {{$defaultBranch}},
3145
'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
3246
'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}}',
47+
'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if .release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}',
48+
'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}}',
3549
'repoLink': {{.root.RepoLink}},
3650
'treePath': {{.root.TreePath}},
3751
'branchNameSubURL': {{.root.BranchNameSubURL}},
@@ -46,71 +60,23 @@
4660
window.config.pageData.branchDropdownDataList.push(data);
4761
</script>
4862

49-
<div class="fitted item choose reference">
63+
<div class="fitted item js-branch-tag-selector">
64+
{{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}
5065
<div class="ui floating filter dropdown custom">
51-
<button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
66+
<button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df">
5267
<span class="text gt-df gt-ac gt-mr-2">
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>
68+
{{if .release}}
69+
{{.root.locale.Tr "repo.release.compare"}}
70+
{{else}}
71+
{{if eq $type "tag"}}
72+
{{svg "octicon-tag"}}
73+
{{else}}
74+
{{svg "octicon-git-branch"}}
75+
{{end}}
76+
<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>
77+
{{end}}
5978
</span>
6079
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
6180
</button>
62-
<div class="menu transition" :class="{visible: menuVisible}" v-if="menuVisible" v-cloak>
63-
<div class="ui icon search input">
64-
<i class="icon gt-df gt-ac gt-jc gt-m-0">{{svg "octicon-filter" 16}}</i>
65-
<input name="search" ref="searchField" autocomplete="off" v-model="searchTerm" @keydown="keydown($event)" :placeholder="searchFieldPlaceholder">
66-
</div>
67-
<template v-if="showBranchesInDropdown">
68-
<div class="header branch-tag-choice">
69-
<div class="ui grid">
70-
<div class="two column row">
71-
<a class="reference column" href="#" @click="createTag = false; mode = 'branches'; focusSearchField()">
72-
<span class="text" :class="{black: mode === 'branches'}">
73-
{{svg "octicon-git-branch" 16 "gt-mr-2"}}${ textBranches }
74-
</span>
75-
</a>
76-
<template v-if="!noTag">
77-
<a class="reference column" href="#" @click="createTag = true; mode = 'tags'; focusSearchField()">
78-
<span class="text" :class="{black: mode === 'tags'}">
79-
{{svg "octicon-tag" 16 "gt-mr-2"}}${ textTags }
80-
</span>
81-
</a>
82-
</template>
83-
</div>
84-
</div>
85-
</div>
86-
</template>
87-
<div class="scrolling menu" ref="scrollContainer">
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">
90-
<a href="#" @click="createNewBranch()">
91-
<div v-show="createTag">
92-
<i class="reference tags icon"></i>
93-
<span v-html="textCreateTag.replace('%s', searchTerm)"></span>
94-
</div>
95-
<div v-show="!createTag">
96-
{{svg "octicon-git-branch"}}
97-
<span v-html="textCreateBranch.replace('%s', searchTerm)"></span>
98-
</div>
99-
<div class="text small">
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>
103-
</div>
104-
</a>
105-
<form ref="newBranchForm" action="{{.root.RepoLink}}/branches/_new/{{.root.BranchNameSubURL}}" method="post">
106-
<input type="hidden" name="_csrf" :value="csrfToken">
107-
<input type="hidden" name="new_branch_name" v-model="searchTerm">
108-
<input type="hidden" name="create_tag" v-model="createTag">
109-
<input type="hidden" name="current_path" v-model="treePath" v-if="treePath">
110-
</form>
111-
</div>
112-
</div>
113-
<div class="message" v-if="showNoResults">${ noResults }</div>
114-
</div>
11581
</div>
11682
</div>

web_src/js/components/PullRequestMergeForm.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
-d '{"context": "test/context", "description": "description", "state": "${state}", "target_url": "http://localhost"}'
1111
-->
1212
<div>
13-
<!-- eslint-disable -->
14-
<div v-if="mergeForm.hasPendingPullRequestMerge" v-html="mergeForm.hasPendingPullRequestMergeTip" class="ui info message"></div>
13+
<!-- eslint-disable-next-line vue/no-v-html -->
14+
<div v-if="mergeForm.hasPendingPullRequestMerge" v-html="mergeForm.hasPendingPullRequestMergeTip" class="ui info message"/>
1515

1616
<div class="ui form" v-if="showActionForm">
1717
<form :action="mergeForm.baseLink+'/merge'" method="post">
@@ -30,7 +30,8 @@
3030
<button @click.prevent="clearMergeMessage" class="ui tertiary button">
3131
{{ mergeForm.textClearMergeMessage }}
3232
</button>
33-
<div class="ui label"><!-- TODO: Convert to tooltip once we can use tooltips in Vue templates -->
33+
<div class="ui label">
34+
<!-- TODO: Convert to tooltip once we can use tooltips in Vue templates -->
3435
{{ mergeForm.textClearMergeMessageHint }}
3536
</div>
3637
</template>

web_src/js/components/RepoBranchTagDropdown.js

-209
This file was deleted.

0 commit comments

Comments
 (0)