Skip to content

Commit 97f50bb

Browse files
committed
Add missing tag name when clicking create release and also fix the old bug when there is a prefix tag name on creating release
1 parent dab398d commit 97f50bb

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

templates/repo/release/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{{end}}
3030
</h4>
3131
<div>
32-
{{if $.CanCreateRelease}}
32+
{{if and $.CanCreateRelease (not $.PageIsSingleTag)}}
3333
<a class="muted" data-tooltip-content="{{ctx.Locale.Tr "repo.release.edit"}}" href="{{$.RepoLink}}/releases/edit/{{$release.TagName | PathEscapeSegments}}" rel="nofollow">
3434
{{svg "octicon-pencil"}}
3535
</a>

templates/repo/release_tag_header.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<div class="gt-df">
66
<div class="gt-f1 gt-df gt-ac">
77
<h2 class="ui compact small menu header small-menu-items">
8-
<a class="{{if .PageIsReleaseList}}active {{end}}item" href="{{.RepoLink}}/releases">{{ctx.Locale.PrettyNumber .NumReleases}} {{ctx.Locale.TrN .NumReleases "repo.release" "repo.releases"}}</a>
8+
<a class="{{if and .PageIsReleaseList (not .PageIsSingleTag)}}active {{end}}item" href="{{.RepoLink}}/releases">{{ctx.Locale.PrettyNumber .NumReleases}} {{ctx.Locale.TrN .NumReleases "repo.release" "repo.releases"}}</a>
99
{{if $canReadCode}}
10-
<a class="{{if .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/tags">{{ctx.Locale.PrettyNumber .NumTags}} {{ctx.Locale.TrN .NumTags "repo.tag" "repo.tags"}}</a>
10+
<a class="{{if or .PageIsTagList .PageIsSingleTag}}active {{end}}item" href="{{.RepoLink}}/tags">{{ctx.Locale.PrettyNumber .NumTags}} {{ctx.Locale.TrN .NumTags "repo.tag" "repo.tags"}}</a>
1111
{{end}}
1212
</h2>
1313
</div>
@@ -17,7 +17,7 @@
1717
</a>
1818
{{end}}
1919
{{if and (not .PageIsTagList) .CanCreateRelease}}
20-
<a class="ui small primary button" href="{{$.RepoLink}}/releases/new">
20+
<a class="ui small primary button" href="{{$.RepoLink}}/releases/new{{if .PageIsSingleTag}}?tag={{.Title}}{{end}}">
2121
{{ctx.Locale.Tr "repo.release.new_release"}}
2222
</a>
2323
{{end}}

tests/integration/links_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func TestLinksNoLogin(t *testing.T) {
3636
"/user2/repo1/",
3737
"/user2/repo1/projects",
3838
"/user2/repo1/projects/1",
39+
"/user2/repo1/releases/tag/delete-tag",
3940
"/assets/img/404.png",
4041
"/assets/img/500.png",
4142
"/.well-known/security.txt",

web_src/js/features/repo-release.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export function initRepoReleaseNew() {
1919
initRepoReleaseEditor();
2020
}
2121

22+
23+
2224
function initTagNameEditor() {
2325
const el = document.getElementById('tag-name-editor');
2426
if (!el) return;
@@ -30,8 +32,9 @@ function initTagNameEditor() {
3032
const newTagHelperText = el.getAttribute('data-tag-helper-new');
3133
const existingTagHelperText = el.getAttribute('data-tag-helper-existing');
3234

33-
document.getElementById('tag-name').addEventListener('keyup', (e) => {
34-
const value = e.target.value;
35+
const tagNameInput = document.getElementById('tag-name');
36+
const hideTargetInput = function(tagNameInput) {
37+
const value = tagNameInput.value;
3538
const tagHelper = document.getElementById('tag-helper');
3639
if (existingTags.includes(value)) {
3740
// If the tag already exists, hide the target branch selector.
@@ -41,6 +44,10 @@ function initTagNameEditor() {
4144
showElem('#tag-target-selector');
4245
tagHelper.textContent = value ? newTagHelperText : defaultTagHelperText;
4346
}
47+
};
48+
hideTargetInput(tagNameInput); // update on page load because the input may have a value
49+
tagNameInput.addEventListener('change', (e) => {
50+
hideTargetInput(e.target);
4451
});
4552
}
4653

0 commit comments

Comments
 (0)