Skip to content

Commit c9eba48

Browse files
authored
Merge branch 'main' into feature/load-referencing-branches-and-tags
2 parents 48c225e + dc3f50a commit c9eba48

File tree

10 files changed

+771
-46
lines changed

10 files changed

+771
-46
lines changed

CHANGELOG.md

Lines changed: 615 additions & 0 deletions
Large diffs are not rendered by default.

modules/web/middleware/flash.go

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ package middleware
55

66
import "net/url"
77

8-
// flashes enumerates all the flash types
9-
const (
10-
SuccessFlash = "SuccessMsg"
11-
ErrorFlash = "ErrorMsg"
12-
WarnFlash = "WarningMsg"
13-
InfoFlash = "InfoMsg"
14-
)
15-
16-
// FlashNow FIXME:
17-
var FlashNow bool
18-
198
// Flash represents a one time data transfer between two requests.
209
type Flash struct {
2110
DataStore ContextDataStore
@@ -27,15 +16,12 @@ func (f *Flash) set(name, msg string, current ...bool) {
2716
if f.Values == nil {
2817
f.Values = make(map[string][]string)
2918
}
30-
isShow := false
31-
if (len(current) == 0 && FlashNow) ||
32-
(len(current) > 0 && current[0]) {
33-
isShow = true
34-
}
35-
36-
if isShow {
19+
showInCurrentPage := len(current) > 0 && current[0]
20+
if showInCurrentPage {
21+
// assign it to the context data, then the template can use ".Flash.XxxMsg" to render the message
3722
f.DataStore.GetData()["Flash"] = f
3823
} else {
24+
// the message map will be saved into the cookie and be shown in next response (a new page response which decodes the cookie)
3925
f.Set(name, msg)
4026
}
4127
}

options/locale/locale_de-DE.ini

Lines changed: 118 additions & 3 deletions
Large diffs are not rendered by default.

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,7 @@ diff.show_more = Show More
23782378
diff.load = Load Diff
23792379
diff.generated = generated
23802380
diff.vendored = vendored
2381+
diff.comment.add_line_comment = Add line comment
23812382
diff.comment.placeholder = Leave a comment
23822383
diff.comment.markdown_info = Styling with markdown is supported.
23832384
diff.comment.add_single_comment = Add single comment

routers/web/repo/issue.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,15 @@ func UpdateIssueStatus(ctx *context.Context) {
27622762
ctx.ServerError("LoadRepositories", err)
27632763
return
27642764
}
2765+
if err := issues.LoadPullRequests(ctx); err != nil {
2766+
ctx.ServerError("LoadPullRequests", err)
2767+
return
2768+
}
2769+
27652770
for _, issue := range issues {
2771+
if issue.IsPull && issue.PullRequest.HasMerged {
2772+
continue
2773+
}
27662774
if issue.IsClosed != isClosed {
27672775
if err := issue_service.ChangeStatus(issue, ctx.Doer, "", isClosed); err != nil {
27682776
if issues_model.IsErrDependenciesLeft(err) {

routers/web/repo/milestone.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,8 @@ func Milestones(ctx *context.Context) {
3838
ctx.Data["PageIsMilestones"] = true
3939

4040
isShowClosed := ctx.FormString("state") == "closed"
41-
stats, err := issues_model.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}))
42-
if err != nil {
43-
ctx.ServerError("MilestoneStats", err)
44-
return
45-
}
46-
ctx.Data["OpenCount"] = stats.OpenCount
47-
ctx.Data["ClosedCount"] = stats.ClosedCount
48-
4941
sortType := ctx.FormString("sort")
50-
5142
keyword := ctx.FormTrim("q")
52-
5343
page := ctx.FormInt("page")
5444
if page <= 1 {
5545
page = 1
@@ -74,6 +64,15 @@ func Milestones(ctx *context.Context) {
7464
ctx.ServerError("GetMilestones", err)
7565
return
7666
}
67+
68+
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
69+
if err != nil {
70+
ctx.ServerError("GetMilestoneStats", err)
71+
return
72+
}
73+
ctx.Data["OpenCount"] = stats.OpenCount
74+
ctx.Data["ClosedCount"] = stats.ClosedCount
75+
7776
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
7877
if err := miles.LoadTotalTrackedTimes(); err != nil {
7978
ctx.ServerError("LoadTotalTrackedTimes", err)

routers/web/repo/pull.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,8 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
175175
} else if len(orgs) > 0 {
176176
ctx.Data["ContextUser"] = orgs[0]
177177
} else {
178-
msg := ctx.Tr("repo.fork_no_valid_owners")
179-
ctx.Data["Flash"] = ctx.Flash
180-
ctx.Flash.Error(msg)
181178
ctx.Data["CanForkRepo"] = false
179+
ctx.Flash.Error(ctx.Tr("repo.fork_no_valid_owners"), true)
182180
return nil
183181
}
184182

@@ -194,8 +192,7 @@ func Fork(ctx *context.Context) {
194192
} else {
195193
maxCreationLimit := ctx.Doer.MaxCreationLimit()
196194
msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", maxCreationLimit)
197-
ctx.Data["Flash"] = ctx.Flash
198-
ctx.Flash.Error(msg)
195+
ctx.Flash.Error(msg, true)
199196
}
200197

201198
getForkRepository(ctx)

templates/repo/diff/section_split.tmpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
<td class="lines-type-marker lines-type-marker-old del-code"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td>
4848
<td class="lines-code lines-code-old del-code">{{/*
4949
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
50-
*/}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
50+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
5151
*/}}{{svg "octicon-plus"}}{{/*
52-
*/}}</a>{{/*
52+
*/}}</button>{{/*
5353
*/}}{{end}}{{/*
5454
*/}}{{if $line.LeftIdx}}{{/*
5555
*/}}{{template "repo/diff/section_code" dict "diff" $leftDiff "locale" $.root.locale}}{{/*
@@ -62,9 +62,9 @@
6262
<td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="gt-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td>
6363
<td class="lines-code lines-code-new add-code">{{/*
6464
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
65-
*/}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/*
65+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/*
6666
*/}}{{svg "octicon-plus"}}{{/*
67-
*/}}</a>{{/*
67+
*/}}</button>{{/*
6868
*/}}{{end}}{{/*
6969
*/}}{{if $match.RightIdx}}{{/*
7070
*/}}{{template "repo/diff/section_code" dict "diff" $rightDiff "locale" $.root.locale}}{{/*
@@ -79,9 +79,9 @@
7979
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
8080
<td class="lines-code lines-code-old">{{/*
8181
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/*
82-
*/}}<a class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
82+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/*
8383
*/}}{{svg "octicon-plus"}}{{/*
84-
*/}}</a>{{/*
84+
*/}}</button>{{/*
8585
*/}}{{end}}{{/*
8686
*/}}{{if $line.LeftIdx}}{{/*
8787
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
@@ -94,9 +94,9 @@
9494
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
9595
<td class="lines-code lines-code-new">{{/*
9696
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/*
97-
*/}}<a class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/*
97+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/*
9898
*/}}{{svg "octicon-plus"}}{{/*
99-
*/}}</a>{{/*
99+
*/}}</button>{{/*
100100
*/}}{{end}}{{/*
101101
*/}}{{if $line.RightIdx}}{{/*
102102
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*

templates/repo/diff/section_unified.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
{{else}}
5353
<td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/*
5454
*/}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/*
55-
*/}}<a class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
55+
*/}}<button type="button" aria-label="{{$.root.locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/*
5656
*/}}{{svg "octicon-plus"}}{{/*
57-
*/}}</a>{{/*
57+
*/}}</button>{{/*
5858
*/}}{{end}}{{/*
5959
*/}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.root.locale}}{{/*
6060
*/}}</td>

web_src/css/review.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
opacity: 1;
3737
}
3838

39+
.ui.button.add-code-comment:focus {
40+
opacity: 1;
41+
}
42+
3943
.repository .diff-file-box .code-diff .add-comment-left,
4044
.repository .diff-file-box .code-diff .add-comment-right,
4145
.repository .diff-file-box .code-diff .add-code-comment .add-comment-left,

0 commit comments

Comments
 (0)