diff --git a/routers/utils/utils.go b/routers/utils/utils.go index d6856fceacd2..1f4d11fd3cca 100644 --- a/routers/utils/utils.go +++ b/routers/utils/utils.go @@ -11,14 +11,6 @@ import ( "code.gitea.io/gitea/modules/setting" ) -// RemoveUsernameParameterSuffix returns the username parameter without the (fullname) suffix - leaving just the username -func RemoveUsernameParameterSuffix(name string) string { - if index := strings.Index(name, " ("); index >= 0 { - name = name[:index] - } - return name -} - // SanitizeFlashErrorString will sanitize a flash error string func SanitizeFlashErrorString(x string) string { return strings.ReplaceAll(html.EscapeString(x), "\n", "
") diff --git a/routers/utils/utils_test.go b/routers/utils/utils_test.go index 6d19214c88e5..440aad87c6be 100644 --- a/routers/utils/utils_test.go +++ b/routers/utils/utils_test.go @@ -11,12 +11,6 @@ import ( "github.com/stretchr/testify/assert" ) -func TestRemoveUsernameParameterSuffix(t *testing.T) { - assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar (Foo Bar)")) - assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar")) - assert.Equal(t, "", RemoveUsernameParameterSuffix("")) -} - func TestIsExternalURL(t *testing.T) { setting.AppURL = "https://try.gitea.io/" type test struct { diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 9e65c8ba9cd9..71fe99c97c70 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -24,7 +24,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" - "code.gitea.io/gitea/routers/utils" shared_user "code.gitea.io/gitea/routers/web/shared/user" "code.gitea.io/gitea/services/convert" "code.gitea.io/gitea/services/forms" @@ -127,7 +126,7 @@ func TeamsAction(ctx *context.Context) { ctx.Error(http.StatusNotFound) return } - uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname"))) + uname := strings.ToLower(ctx.FormString("uname")) var u *user_model.User u, err = user_model.GetUserByName(ctx, uname) if err != nil { diff --git a/routers/web/repo/setting/collaboration.go b/routers/web/repo/setting/collaboration.go index e217697cc0ad..c5c2a88c49cf 100644 --- a/routers/web/repo/setting/collaboration.go +++ b/routers/web/repo/setting/collaboration.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/modules/log" repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" - "code.gitea.io/gitea/routers/utils" "code.gitea.io/gitea/services/mailer" org_service "code.gitea.io/gitea/services/org" repo_service "code.gitea.io/gitea/services/repository" @@ -52,7 +51,7 @@ func Collaboration(ctx *context.Context) { // CollaborationPost response for actions for a collaboration of a repository func CollaborationPost(ctx *context.Context) { - name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("collaborator"))) + name := strings.ToLower(ctx.FormString("collaborator")) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath()) return @@ -144,7 +143,7 @@ func AddTeamPost(ctx *context.Context) { return } - name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team"))) + name := strings.ToLower(ctx.FormString("team")) if len(name) == 0 { ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return diff --git a/services/release/release.go b/services/release/release.go index c1d13126f0b3..4c522c18bed8 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -291,15 +291,13 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo } } - if !isCreated { - notify_service.UpdateRelease(gitRepo.Ctx, doer, rel) - return nil - } - if !rel.IsDraft { + if !isCreated { + notify_service.UpdateRelease(gitRepo.Ctx, doer, rel) + return nil + } notify_service.NewRelease(gitRepo.Ctx, rel) } - return nil } @@ -368,8 +366,9 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re } } - notify_service.DeleteRelease(ctx, doer, rel) - + if !rel.IsDraft { + notify_service.DeleteRelease(ctx, doer, rel) + } return nil } diff --git a/templates/repo/commit_load_branches_and_tags.tmpl b/templates/repo/commit_load_branches_and_tags.tmpl index 6d5eb29d8a3c..883230ac2952 100644 --- a/templates/repo/commit_load_branches_and_tags.tmpl +++ b/templates/repo/commit_load_branches_and_tags.tmpl @@ -9,11 +9,11 @@
{{ctx.Locale.Tr "repo.commit.contained_in"}}
{{svg "octicon-git-branch"}}
-
+
{{svg "octicon-tag"}}
-
+
diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl index bb2e25e86c10..0aeb2af178b2 100644 --- a/templates/repo/settings/lfs_file.tmpl +++ b/templates/repo/settings/lfs_file.tmpl @@ -33,7 +33,7 @@ {{else if .IsPDFFile}}
{{else}} - {{ctx.Locale.Tr "repo.file_view_raw"}} + {{ctx.Locale.Tr "repo.file_view_raw"}} {{end}} {{else if .FileSize}} diff --git a/templates/repo/unicode_escape_prompt.tmpl b/templates/repo/unicode_escape_prompt.tmpl index 8f02a489e976..d0730f23c1c7 100644 --- a/templates/repo/unicode_escape_prompt.tmpl +++ b/templates/repo/unicode_escape_prompt.tmpl @@ -1,7 +1,7 @@ {{if .EscapeStatus}} {{if .EscapeStatus.HasInvisible}}
- +
{{ctx.Locale.Tr "repo.invisible_runes_header"}}
@@ -12,7 +12,7 @@
{{else if .EscapeStatus.HasAmbiguous}}
- +
{{ctx.Locale.Tr "repo.ambiguous_runes_header"}}
diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index e6591df7e348..1f9e0b5028be 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -108,7 +108,7 @@ {{else if .IsPDFFile}}
{{else}} - {{ctx.Locale.Tr "repo.file_view_raw"}} + {{ctx.Locale.Tr "repo.file_view_raw"}} {{end}}
{{else if .FileSize}} diff --git a/web_src/css/base.css b/web_src/css/base.css index cc1f6a839761..198e87c0e202 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -196,10 +196,14 @@ a.label, .ui.search > .results { background: var(--color-body); border-color: var(--color-secondary); + overflow-wrap: anywhere; /* allow text to wrap as fomantic limits this to 18em width */ } .ui.search > .results .result { background: var(--color-body); + border-color: var(--color-secondary); + display: flex; + align-items: center; } .ui.search > .results .result .title { diff --git a/web_src/css/repo.css b/web_src/css/repo.css index dfe0d6c77f5e..55c6ec481718 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2128,14 +2128,16 @@ } #search-user-box .results .result .image { - float: left; - margin-right: 8px; + order: 0; + margin-right: 12px; width: 2em; height: 2em; + min-width: 2em; + min-height: 2em; } #search-user-box .results .result .content { - margin: 6px 0; /* this trick is used to align with the sibling avatar image */ + margin: 0; /* remove margin reserved for avatar because we move it to left via `order: 0` */ } .ui.menu .item > img:not(.ui) { diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js index 960b787fea6b..992d4ef0206d 100644 --- a/web_src/js/features/comp/SearchUserBox.js +++ b/web_src/js/features/comp/SearchUserBox.js @@ -17,14 +17,13 @@ export function initCompSearchUserBox() { const searchQuery = $searchUserBox.find('input').val(); const searchQueryUppercase = searchQuery.toUpperCase(); $.each(response.data, (_i, item) => { - let title = item.login; - if (item.full_name && item.full_name.length > 0) { - title += ` (${htmlEscape(item.full_name)})`; - } const resultItem = { - title, + title: item.login, image: item.avatar_url }; + if (item.full_name) { + resultItem.description = htmlEscape(item.full_name); + } if (searchQueryUppercase === item.login.toUpperCase()) { items.unshift(resultItem); } else { diff --git a/web_src/js/features/repo-settings.js b/web_src/js/features/repo-settings.js index 04974200bb99..75e624a6a736 100644 --- a/web_src/js/features/repo-settings.js +++ b/web_src/js/features/repo-settings.js @@ -52,9 +52,9 @@ export function initRepoSettingSearchTeamBox() { onResponse(response) { const items = []; $.each(response.data, (_i, item) => { - const title = `${item.name} (${item.permission} access)`; items.push({ - title, + title: item.name, + description: `${item.permission} access` // TODO: translate this string }); }); diff --git a/web_src/js/markup/codecopy.js b/web_src/js/markup/codecopy.js index a12802ef7347..078d74125386 100644 --- a/web_src/js/markup/codecopy.js +++ b/web_src/js/markup/codecopy.js @@ -12,8 +12,10 @@ export function renderCodeCopy() { if (!els.length) return; for (const el of els) { + if (!el.textContent) continue; const btn = makeCodeCopyButton(); - btn.setAttribute('data-clipboard-text', el.textContent); + // remove final trailing newline introduced during HTML rendering + btn.setAttribute('data-clipboard-text', el.textContent.replace(/\r?\n$/, '')); el.after(btn); } }