Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 19:26:09 +01:00

Compare commits

..

1 commit

Author SHA1 Message Date
0ko 0b2750714c feat(i18n): include authorlink in translations
Co-authored-by: Gusted <gusted@noreply.codeberg.org>
2024-11-19 12:11:04 +05:00
6 changed files with 24 additions and 51 deletions

View file

@ -2622,9 +2622,9 @@ diff.browse_source = Browse source
diff.parent = parent diff.parent = parent
diff.commit = commit diff.commit = commit
diff.git-notes = Notes diff.git-notes = Notes
diff.git-notes.add = Add note diff.git-notes.add = Add Note
diff.git-notes.remove-header = Remove note diff.git-notes.remove-header = Remove Note
diff.git-notes.remove-body = This note will be removed. diff.git-notes.remove-body = This will remove this Note
diff.data_not_available = Diff content is not available diff.data_not_available = Diff content is not available
diff.options_button = Diff options diff.options_button = Diff options
diff.show_diff_stats = Show stats diff.show_diff_stats = Show stats

View file

@ -128,9 +128,6 @@
</form> </form>
</div> </div>
</div> </div>
<div id="commit-notes-add-button" class="item">
{{ctx.Locale.Tr "repo.diff.git-notes.add"}}
</div>
</div> </div>
</div> </div>
{{end}} {{end}}
@ -280,20 +277,20 @@
<span class="text grey" id="note-authored-time">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span> <span class="text grey" id="note-authored-time">{{DateUtils.TimeSince .NoteCommit.Author.When}}</span>
{{if or ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}} {{if or ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
<div class="ui right"> <div class="ui right">
<button id="commit-notes-edit-button" class="ui tiny primary button" data-modal="#delete-note-modal">{{ctx.Locale.Tr "edit"}}</button> <button id="commit-notes-edit-button" class="ui tiny button yellow" data-modal="#delete-note-modal">{{ctx.Locale.Tr "edit"}}</button>
<button class="ui tiny button red show-modal" data-modal="#delete-note-modal">{{ctx.Locale.Tr "remove"}}</button> <button class="ui tiny button red show-modal" data-modal="#delete-note-modal">{{ctx.Locale.Tr "remove"}}</button>
</div> </div>
<div class="ui small modal" id="delete-note-modal"> <div class="ui small modal" id="delete-note-modal">
<div class="header"> <div class="header">
{{ctx.Locale.Tr "repo.diff.git-notes.remove-header"}} {{ctx.Locale.Tr "repo.diff.git-notes.remove-header"}}
</div> </div>
<p>{{ctx.Locale.Tr "repo.diff.git-notes.remove-body"}}</p>
<div class="content"> <div class="content">
<p>{{ctx.Locale.Tr "repo.diff.git-notes.remove-body"}}</p>
<div class="text right actions"> <div class="text right actions">
<form action="{{.Link}}/notes/remove" method="post"> <form action="{{.Link}}/notes/remove" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<button type="button" class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> <button type="button" class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button>
<button type="submit" class="ui red button" href="{{.Link}}/notes/remove">{{ctx.Locale.Tr "remove"}}</button> <button type="submit" class="ui primary button red" href="{{.Link}}/notes/remove">{{ctx.Locale.Tr "remove"}}</button>
</form> </form>
</div> </div>
</div> </div>
@ -319,6 +316,7 @@
</div> </div>
{{end}} {{end}}
{{else if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}} {{else if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
<button id="commit-notes-add-button" class="ui primary button green tw-mt-3">{{ctx.Locale.Tr "repo.diff.git-notes.add"}}</button>
<div id="commit-notes-add-area" class="ui tw-mt-3 segment tw-hidden"> <div id="commit-notes-add-area" class="ui tw-mt-3 segment tw-hidden">
<form class="ui form" action="{{.Link}}/notes" method="post"> <form class="ui form" action="{{.Link}}/notes" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}

View file

@ -51,12 +51,10 @@
</div> </div>
<input id="pronouns-custom" name="pronouns" value="{{.SignedUser.Pronouns}}" maxlength="50"> <input id="pronouns-custom" name="pronouns" value="{{.SignedUser.Pronouns}}" maxlength="50">
</div> </div>
{{if not .SignedUser.KeepEmailPrivate}} <div class="field {{if .Err_Email}}error{{end}}">
<div class="field"> <label>{{ctx.Locale.Tr "email"}}</label>
<label>{{ctx.Locale.Tr "email"}}</label> <p id="signed-user-email">{{.SignedUser.Email}}</p>
<p id="signed-user-email">{{.SignedUser.Email}}</p> </div>
</div>
{{end}}
<div class="field {{if .Err_Biography}}error{{end}}"> <div class="field {{if .Err_Biography}}error{{end}}">
<label for="biography">{{ctx.Locale.Tr "user.user_bio"}}</label> <label for="biography">{{ctx.Locale.Tr "user.user_bio"}}</label>
<textarea id="biography" name="biography" rows="2" placeholder="{{ctx.Locale.Tr "settings.biography_placeholder"}}" maxlength="255">{{.SignedUser.Description}}</textarea> <textarea id="biography" name="biography" rows="2" placeholder="{{ctx.Locale.Tr "settings.biography_placeholder"}}" maxlength="255">{{.SignedUser.Description}}</textarea>

View file

@ -14,41 +14,38 @@ import (
auth_model "code.gitea.io/gitea/models/auth" auth_model "code.gitea.io/gitea/models/auth"
api "code.gitea.io/gitea/modules/structs" api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/tests"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
// TestDiscussionEvents is a test for various events displayed in the timelines of pulls and issues // TestDiscussionEvents is a test for various events displayed in the timelines of pulls and issues
func TestDiscussionEvents(t *testing.T) { func TestDiscussionEvents(t *testing.T) {
defer tests.PrepareTestEnv(t)()
repoName := "discussion-timeline-tests" repoName := "discussion-timeline-tests"
user1 := "user1" user2 := "user2"
description := "This PR will be used for testing events in discussions" description := "This PR will be used for testing events in discussions"
// Expected branch name when initializing repo automatically // Expected branch name when initializing repo automatically
defaultBranch := "master" defaultBranch := "master"
htmlCleaner := regexp.MustCompile(`[\t\n]`) htmlCleaner := regexp.MustCompile(`[\t\n]`)
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) { onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
sessionUser1 := loginUser(t, user1) sessionUser2 := loginUser(t, user2)
tokenUser1 := getTokenForLoggedInUser(t, sessionUser1, auth_model.AccessTokenScopeAll) tokenUser2 := getTokenForLoggedInUser(t, sessionUser2, auth_model.AccessTokenScopeAll)
// Create test repo // Create test repo
var repo api.Repository var repo api.Repository
resp := sessionUser1.MakeRequest(t, NewRequestWithJSON(t, "POST", "/api/v1/user/repos", &api.CreateRepoOption{ resp := sessionUser2.MakeRequest(t, NewRequestWithJSON(t, "POST", "/api/v1/user/repos", &api.CreateRepoOption{
Name: repoName, Name: repoName,
AutoInit: true, AutoInit: true,
}).AddTokenAuth(tokenUser1), http.StatusCreated) }).AddTokenAuth(tokenUser2), http.StatusCreated)
DecodeJSON(t, resp, &repo) DecodeJSON(t, resp, &repo)
// == Test pulls == // == Test pulls ==
// Open a new PR as user1 // Open a new PR as user2
testEditFileToNewBranch(t, sessionUser1, user1, repo.Name, defaultBranch, "comment-labels", "README.md", description) testEditFileToNewBranch(t, sessionUser2, user2, repo.Name, defaultBranch, "comment-labels", "README.md", description)
sessionUser1.MakeRequest(t, NewRequestWithValues(t, "POST", path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch)), sessionUser2.MakeRequest(t, NewRequestWithValues(t, "POST", path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch)),
map[string]string{ map[string]string{
"_csrf": GetCSRF(t, sessionUser1, path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch))), "_csrf": GetCSRF(t, sessionUser2, path.Join(repo.FullName, "compare", fmt.Sprintf("%s...comment-labels", defaultBranch))),
"title": description, "title": description,
}, },
), http.StatusOK) ), http.StatusOK)
@ -57,7 +54,7 @@ func TestDiscussionEvents(t *testing.T) {
testPullID := "1" testPullID := "1"
// Get the PR page and find all events // Get the PR page and find all events
response := sessionUser1.MakeRequest(t, NewRequest(t, "GET", path.Join(repo.FullName, "pulls", testPullID)), http.StatusOK) response := sessionUser2.MakeRequest(t, NewRequest(t, "GET", path.Join(repo.FullName, "pulls", testPullID)), http.StatusOK)
page := NewHTMLParser(t, response.Body) page := NewHTMLParser(t, response.Body)
events := page.Find(".timeline .timeline-item.event .text") events := page.Find(".timeline .timeline-item.event .text")
@ -65,8 +62,8 @@ func TestDiscussionEvents(t *testing.T) {
event := events.Eq(0) event := events.Eq(0)
eventHTML, _ := event.Html() eventHTML, _ := event.Html()
eventText := htmlCleaner.ReplaceAllString(strings.TrimSpace(event.Text()), "") eventText := htmlCleaner.ReplaceAllString(strings.TrimSpace(event.Text()), "")
assert.Contains(t, eventHTML, `href="/user1">user1</a>`) assert.Contains(t, eventHTML, `href="/user2">user2</a>`)
assert.Contains(t, eventHTML, `<relative-time`) assert.Contains(t, eventHTML, `<relative-time`)
assert.Contains(t, eventText, `user1 added 1 commit`) assert.Contains(t, eventText, `user2 added 1 commit`)
}) })
} }

View file

@ -1,5 +1,4 @@
// Copyright 2017 The Gitea Authors. All rights reserved. // Copyright 2017 The Gitea Authors. All rights reserved.
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
package integration package integration
@ -157,23 +156,3 @@ func TestSettingSecurityAuthSource(t *testing.T) {
assert.Contains(t, resp.Body.String(), `gitlab-active`) assert.Contains(t, resp.Body.String(), `gitlab-active`)
assert.Contains(t, resp.Body.String(), `gitlab-inactive`) assert.Contains(t, resp.Body.String(), `gitlab-inactive`)
} }
func TestSettingShowUserEmailSettings(t *testing.T) {
defer tests.PrepareTestEnv(t)()
// user1: keep_email_private = false, user2: keep_email_private = true
// user1 can see own visible email
session := loginUser(t, "user1")
req := NewRequest(t, "GET", "/user/settings")
resp := session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
assert.Contains(t, htmlDoc.doc.Find("#signed-user-email").Text(), "user1@example.com")
// user2 cannot see own hidden email
session = loginUser(t, "user2")
req = NewRequest(t, "GET", "/user/settings")
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc = NewHTMLParser(t, resp.Body)
assert.NotContains(t, htmlDoc.doc.Find("#signed-user-email").Text(), "user2@example.com")
}

View file

@ -38,6 +38,7 @@ export function initCommitNotes() {
const notesAddButton = document.getElementById('commit-notes-add-button'); const notesAddButton = document.getElementById('commit-notes-add-button');
if (notesAddButton !== null) { if (notesAddButton !== null) {
notesAddButton.addEventListener('click', () => { notesAddButton.addEventListener('click', () => {
notesAddButton.classList.add('tw-hidden');
document.getElementById('commit-notes-add-area').classList.remove('tw-hidden'); document.getElementById('commit-notes-add-area').classList.remove('tw-hidden');
}); });
} }