Add 'Reply' as translatable

Add CODE_COMMENT_LINES setting

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz 2018-05-31 15:23:15 +02:00 committed by Jonas Franz
parent 9a0c3947e0
commit c8c1e704ed
No known key found for this signature in database
GPG Key ID: 506AEEBE80BEDECD
5 changed files with 15 additions and 9 deletions

View File

@ -67,6 +67,8 @@ EXPLORE_PAGING_NUM = 20
ISSUE_PAGING_NUM = 10
; Number of maximum commits displayed in one activity feed
FEED_MAX_COMMIT_NUM = 5
; Number of line of codes shown for a code comment
CODE_COMMENT_LINES = 4
; Value of `theme-color` meta tag, used by Android >= 5.0
; An invalid color like "none" or "disable" will have the default style
; More info: https://developers.google.com/web/updates/2014/11/Support-for-theme-color-in-Chrome-39-for-Android

View File

@ -396,7 +396,7 @@ func (c *Comment) AsDiff() (*Diff, error) {
if len(diff.Files) == 0 {
return nil, fmt.Errorf("no file found for comment ID: %d", c.ID)
}
// Limit to 4 lines around comment line
// Limit to CODE_COMMENT_LINES lines around comment line
for _, sec := range diff.Files[0].Sections {
var searchedLineIdx int
for lineIdx, line := range sec.Lines {
@ -409,9 +409,9 @@ func (c *Comment) AsDiff() (*Diff, error) {
break
}
}
if searchedLineIdx >= 3 {
first := searchedLineIdx-3
last := searchedLineIdx+1
if searchedLineIdx >= setting.UI.CodeCommentLines - 1 {
first := searchedLineIdx - setting.UI.CodeCommentLines + 1
last := searchedLineIdx + 1
sec.Lines = sec.Lines[first:last]
diff.Files[0].Sections = []*DiffSection{sec}
break
@ -428,11 +428,12 @@ func (c *Comment) AsDiff() (*Diff, error) {
func (c *Comment) MustAsDiff() *Diff {
diff, err := c.AsDiff()
if err != nil {
log.Warn( "MustAsDiff: %v", err)
log.Warn("MustAsDiff: %v", err)
}
return diff
}
// CodeCommentURL returns the url to a comment in code
func (c *Comment) CodeCommentURL() string {
err := c.LoadIssue()
if err != nil { // Silently dropping errors :unamused:
@ -465,7 +466,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
NewTitle: opts.NewTitle,
TreePath: opts.TreePath,
ReviewID: opts.ReviewID,
Patch: opts.Patch,
Patch: opts.Patch,
}
if _, err = e.Insert(comment); err != nil {
return nil, err
@ -683,7 +684,7 @@ type CreateCommentOptions struct {
NewTitle string
CommitID int64
CommitSHA string
Patch string
Patch string
LineNum int64
TreePath string
ReviewID int64
@ -786,7 +787,7 @@ func CreateCodeComment(doer *User, repo *Repository, issue *Issue, content, tree
TreePath: treePath,
CommitSHA: commit.ID.String(),
ReviewID: reviewID,
Patch: patchBuf.String(),
Patch: patchBuf.String(),
})
}

View File

@ -270,6 +270,7 @@ var (
IssuePagingNum int
RepoSearchPagingNum int
FeedMaxCommitNum int
CodeCommentLines int
ReactionMaxUserNum int
ThemeColorMetaTag string
MaxDisplayFileSize int64
@ -294,6 +295,7 @@ var (
IssuePagingNum: 10,
RepoSearchPagingNum: 10,
FeedMaxCommitNum: 5,
CodeCommentLines: 4,
ReactionMaxUserNum: 10,
ThemeColorMetaTag: `#6cc644`,
MaxDisplayFileSize: 8388608,

View File

@ -1126,6 +1126,7 @@ diff.comment.markdown_info = Styling with markdown is supported.
diff.comment.add_single_comment = Add single comment
diff.comment.add_review_comment = Add comment
diff.comment.start_review = Start review
diff.comment.reply = Reply
diff.review = Review
diff.review.header = Submit review
diff.review.placeholder = Review comment

View File

@ -1,6 +1,6 @@
{{if $.root.SignedUserID}}
{{if $.hidden}}
<button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> Reply</button>
<button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> {{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>
{{end}}
<form class="ui form {{if $.hidden}}hide comment-form{{end}}" action="{{$.root.Issue.HTMLURL}}/files/reviews/comments" method="post">
{{$.root.CsrfTokenHtml}}