Skip to content

Commit bc278d7

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix PR web route permission check (go-gitea#33636) fix: add missing locale (go-gitea#33641) Fix Untranslated Text on Actions Page (go-gitea#33635) Improve button layout on small screens (go-gitea#33633) Update README screenshots (go-gitea#33347)
2 parents f435a87 + c2e23d3 commit bc278d7

File tree

10 files changed

+174
-32
lines changed

10 files changed

+174
-32
lines changed

README.md

+59-5
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,64 @@ for the full license text.
150150
<details>
151151
<summary>Looking for an overview of the interface? Check it out!</summary>
152152

153-
|![Dashboard](https://dl.gitea.com/screenshots/home_timeline.png)|![User Profile](https://dl.gitea.com/screenshots/user_profile.png)|![Global Issues](https://dl.gitea.com/screenshots/global_issues.png)|
154-
|:---:|:---:|:---:|
155-
|![Branches](https://dl.gitea.com/screenshots/branches.png)|![Web Editor](https://dl.gitea.com/screenshots/web_editor.png)|![Activity](https://dl.gitea.com/screenshots/activity.png)|
156-
|![New Migration](https://dl.gitea.com/screenshots/migration.png)|![Migrating](https://dl.gitea.com/screenshots/migration.gif)|![Pull Request View](https://image.ibb.co/e02dSb/6.png)|
157-
|![Pull Request Dark](https://dl.gitea.com/screenshots/pull_requests_dark.png)|![Diff Review Dark](https://dl.gitea.com/screenshots/review_dark.png)|![Diff Dark](https://dl.gitea.com/screenshots/diff_dark.png)|
153+
### Login/Register Page
154+
155+
![Login](https://dl.gitea.com/screenshots/login.png)
156+
![Register](https://dl.gitea.com/screenshots/register.png)
157+
158+
### User Dashboard
159+
160+
![Home](https://dl.gitea.com/screenshots/home.png)
161+
![Issues](https://dl.gitea.com/screenshots/issues.png)
162+
![Pull Requests](https://dl.gitea.com/screenshots/pull_requests.png)
163+
![Milestones](https://dl.gitea.com/screenshots/milestones.png)
164+
165+
### User Profile
166+
167+
![Profile](https://dl.gitea.com/screenshots/user_profile.png)
168+
169+
### Explore
170+
171+
![Repos](https://dl.gitea.com/screenshots/explore_repos.png)
172+
![Users](https://dl.gitea.com/screenshots/explore_users.png)
173+
![Orgs](https://dl.gitea.com/screenshots/explore_orgs.png)
174+
175+
### Repository
176+
177+
![Home](https://dl.gitea.com/screenshots/repo_home.png)
178+
![Commits](https://dl.gitea.com/screenshots/repo_commits.png)
179+
![Branches](https://dl.gitea.com/screenshots/repo_branches.png)
180+
![Labels](https://dl.gitea.com/screenshots/repo_labels.png)
181+
![Milestones](https://dl.gitea.com/screenshots/repo_milestones.png)
182+
![Releases](https://dl.gitea.com/screenshots/repo_releases.png)
183+
![Tags](https://dl.gitea.com/screenshots/repo_tags.png)
184+
185+
#### Repository Issue
186+
187+
![List](https://dl.gitea.com/screenshots/repo_issues.png)
188+
![Issue](https://dl.gitea.com/screenshots/repo_issue.png)
189+
190+
#### Repository Pull Requests
191+
192+
![List](https://dl.gitea.com/screenshots/repo_pull_requests.png)
193+
![Pull Request](https://dl.gitea.com/screenshots/repo_pull_request.png)
194+
![File](https://dl.gitea.com/screenshots/repo_pull_request_file.png)
195+
![Commits](https://dl.gitea.com/screenshots/repo_pull_request_commits.png)
196+
197+
#### Repository Actions
198+
199+
![List](https://dl.gitea.com/screenshots/repo_actions.png)
200+
![Details](https://dl.gitea.com/screenshots/repo_actions_run.png)
201+
202+
#### Repository Activity
203+
204+
![Activity](https://dl.gitea.com/screenshots/repo_activity.png)
205+
![Contributors](https://dl.gitea.com/screenshots/repo_contributors.png)
206+
![Code Frequency](https://dl.gitea.com/screenshots/repo_code_frequency.png)
207+
![Recent Commits](https://dl.gitea.com/screenshots/repo_recent_commits.png)
208+
209+
### Organization
210+
211+
![Home](https://dl.gitea.com/screenshots/org_home.png)
158212

159213
</details>

README_ZH.md

+59-5
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,64 @@ Gitea 提供官方的 [go-sdk](https://gitea.com/gitea/go-sdk),以及名为 [t
9393
<details>
9494
<summary>截图</summary>
9595

96-
|![Dashboard](https://dl.gitea.com/screenshots/home_timeline.png)|![User Profile](https://dl.gitea.com/screenshots/user_profile.png)|![Global Issues](https://dl.gitea.com/screenshots/global_issues.png)|
97-
|:---:|:---:|:---:|
98-
|![Branches](https://dl.gitea.com/screenshots/branches.png)|![Web Editor](https://dl.gitea.com/screenshots/web_editor.png)|![Activity](https://dl.gitea.com/screenshots/activity.png)|
99-
|![New Migration](https://dl.gitea.com/screenshots/migration.png)|![Migrating](https://dl.gitea.com/screenshots/migration.gif)|![Pull Request View](https://image.ibb.co/e02dSb/6.png)|
100-
|![Pull Request Dark](https://dl.gitea.com/screenshots/pull_requests_dark.png)|![Diff Review Dark](https://dl.gitea.com/screenshots/review_dark.png)|![Diff Dark](https://dl.gitea.com/screenshots/diff_dark.png)|
96+
### 登录界面
97+
98+
![登录](https://dl.gitea.com/screenshots/login.png)
99+
![注册](https://dl.gitea.com/screenshots/register.png)
100+
101+
### 用户首页
102+
103+
![首页](https://dl.gitea.com/screenshots/home.png)
104+
![工单列表](https://dl.gitea.com/screenshots/issues.png)
105+
![合并请求列表](https://dl.gitea.com/screenshots/pull_requests.png)
106+
![里程碑列表](https://dl.gitea.com/screenshots/milestones.png)
107+
108+
### 用户资料
109+
110+
![用户资料](https://dl.gitea.com/screenshots/user_profile.png)
111+
112+
### 探索
113+
114+
![仓库列表](https://dl.gitea.com/screenshots/explore_repos.png)
115+
![用户列表](https://dl.gitea.com/screenshots/explore_users.png)
116+
![组织列表](https://dl.gitea.com/screenshots/explore_orgs.png)
117+
118+
### 仓库
119+
120+
![首页](https://dl.gitea.com/screenshots/repo_home.png)
121+
![提交列表](https://dl.gitea.com/screenshots/repo_commits.png)
122+
![分支列表](https://dl.gitea.com/screenshots/repo_branches.png)
123+
![标签列表](https://dl.gitea.com/screenshots/repo_labels.png)
124+
![里程碑列表](https://dl.gitea.com/screenshots/repo_milestones.png)
125+
![版本发布](https://dl.gitea.com/screenshots/repo_releases.png)
126+
![标签列表](https://dl.gitea.com/screenshots/repo_tags.png)
127+
128+
#### 仓库工单
129+
130+
![列表](https://dl.gitea.com/screenshots/repo_issues.png)
131+
![工单](https://dl.gitea.com/screenshots/repo_issue.png)
132+
133+
#### 仓库合并请求
134+
135+
![列表](https://dl.gitea.com/screenshots/repo_pull_requests.png)
136+
![合并请求](https://dl.gitea.com/screenshots/repo_pull_request.png)
137+
![文件](https://dl.gitea.com/screenshots/repo_pull_request_file.png)
138+
![提交列表](https://dl.gitea.com/screenshots/repo_pull_request_commits.png)
139+
140+
#### 仓库 Actions
141+
142+
![列表](https://dl.gitea.com/screenshots/repo_actions.png)
143+
![Run](https://dl.gitea.com/screenshots/repo_actions_run.png)
144+
145+
#### 仓库动态
146+
147+
![动态](https://dl.gitea.com/screenshots/repo_activity.png)
148+
![贡献者](https://dl.gitea.com/screenshots/repo_contributors.png)
149+
![代码频率](https://dl.gitea.com/screenshots/repo_code_frequency.png)
150+
![最近的提交](https://dl.gitea.com/screenshots/repo_recent_commits.png)
151+
152+
### 组织
153+
154+
![首页](https://dl.gitea.com/screenshots/org_home.png)
101155

102156
</details>

models/actions/run_list.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
repo_model "code.gitea.io/gitea/models/repo"
1111
user_model "code.gitea.io/gitea/models/user"
1212
"code.gitea.io/gitea/modules/container"
13+
"code.gitea.io/gitea/modules/translation"
1314
webhook_module "code.gitea.io/gitea/modules/webhook"
1415

1516
"xorm.io/builder"
@@ -112,14 +113,14 @@ type StatusInfo struct {
112113
}
113114

114115
// GetStatusInfoList returns a slice of StatusInfo
115-
func GetStatusInfoList(ctx context.Context) []StatusInfo {
116+
func GetStatusInfoList(ctx context.Context, lang translation.Locale) []StatusInfo {
116117
// same as those in aggregateJobStatus
117118
allStatus := []Status{StatusSuccess, StatusFailure, StatusWaiting, StatusRunning}
118119
statusInfoList := make([]StatusInfo, 0, 4)
119120
for _, s := range allStatus {
120121
statusInfoList = append(statusInfoList, StatusInfo{
121122
Status: int(s),
122-
DisplayedStatus: s.String(),
123+
DisplayedStatus: s.LocaleString(lang),
123124
})
124125
}
125126
return statusInfoList

models/perm/access/repo_permission.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (p *Permission) ReadableUnitTypes() []unit.Type {
152152
}
153153

154154
func (p *Permission) LogString() string {
155-
format := "<Permission AccessMode=%s, %d Units, %d UnitsMode(s): [ "
155+
format := "<Permission AccessMode=%s, %d Units, %d UnitsMode(s): ["
156156
args := []any{p.AccessMode.ToString(), len(p.units), len(p.unitsMode)}
157157

158158
for i, u := range p.units {
@@ -164,14 +164,16 @@ func (p *Permission) LogString() string {
164164
config = err.Error()
165165
}
166166
}
167-
format += "\nUnits[%d]: ID: %d RepoID: %d Type: %s Config: %s"
167+
format += "\n\tunits[%d]: ID=%d RepoID=%d Type=%s Config=%s"
168168
args = append(args, i, u.ID, u.RepoID, u.Type.LogString(), config)
169169
}
170170
for key, value := range p.unitsMode {
171-
format += "\nUnitMode[%-v]: %-v"
171+
format += "\n\tunitsMode[%-v]: %-v"
172172
args = append(args, key.LogString(), value.LogString())
173173
}
174-
format += " ]>"
174+
format += "\n\teveryoneAccessMode: %-v"
175+
args = append(args, p.everyoneAccessMode)
176+
format += "\n\t]>"
175177
return fmt.Sprintf(format, args...)
176178
}
177179

modules/log/logger_impl.go

+19-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package log
55

66
import (
77
"context"
8+
"reflect"
89
"runtime"
910
"strings"
1011
"sync"
@@ -175,6 +176,20 @@ func (l *LoggerImpl) IsEnabled() bool {
175176
return l.level.Load() < int32(FATAL) && len(l.eventWriters) > 0
176177
}
177178

179+
func asLogStringer(v any) LogStringer {
180+
if s, ok := v.(LogStringer); ok {
181+
return s
182+
} else if a := reflect.ValueOf(v); a.Kind() == reflect.Struct {
183+
// in case the receiver is a pointer, but the value is a struct
184+
vp := reflect.New(a.Type())
185+
vp.Elem().Set(a)
186+
if s, ok := vp.Interface().(LogStringer); ok {
187+
return s
188+
}
189+
}
190+
return nil
191+
}
192+
178193
// Log prepares the log event, if the level matches, the event will be sent to the writers
179194
func (l *LoggerImpl) Log(skip int, level Level, format string, logArgs ...any) {
180195
if Level(l.level.Load()) > level {
@@ -207,11 +222,11 @@ func (l *LoggerImpl) Log(skip int, level Level, format string, logArgs ...any) {
207222
// handle LogStringer values
208223
for i, v := range msgArgs {
209224
if cv, ok := v.(*ColoredValue); ok {
210-
if s, ok := cv.v.(LogStringer); ok {
211-
cv.v = logStringFormatter{v: s}
225+
if ls := asLogStringer(cv.v); ls != nil {
226+
cv.v = logStringFormatter{v: ls}
212227
}
213-
} else if s, ok := v.(LogStringer); ok {
214-
msgArgs[i] = logStringFormatter{v: s}
228+
} else if ls := asLogStringer(v); ls != nil {
229+
msgArgs[i] = logStringFormatter{v: ls}
215230
}
216231
}
217232

modules/log/logger_test.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ func (t testLogString) LogString() string {
116116
return "log-string"
117117
}
118118

119+
type testLogStringPtrReceiver struct {
120+
Field string
121+
}
122+
123+
func (t *testLogStringPtrReceiver) LogString() string {
124+
return "log-string-ptr-receiver"
125+
}
126+
119127
func TestLoggerLogString(t *testing.T) {
120128
logger := NewLoggerWithWriters(context.Background(), "test")
121129

@@ -124,9 +132,13 @@ func TestLoggerLogString(t *testing.T) {
124132
logger.AddWriters(w1)
125133

126134
logger.Info("%s %s %#v %v", testLogString{}, &testLogString{}, testLogString{Field: "detail"}, NewColoredValue(testLogString{}, FgRed))
135+
logger.Info("%s %s %#v %v", testLogStringPtrReceiver{}, &testLogStringPtrReceiver{}, testLogStringPtrReceiver{Field: "detail"}, NewColoredValue(testLogStringPtrReceiver{}, FgRed))
127136
logger.Close()
128137

129-
assert.Equal(t, []string{"log-string log-string log.testLogString{Field:\"detail\"} \x1b[31mlog-string\x1b[0m\n"}, w1.GetLogs())
138+
assert.Equal(t, []string{
139+
"log-string log-string log.testLogString{Field:\"detail\"} \x1b[31mlog-string\x1b[0m\n",
140+
"log-string-ptr-receiver log-string-ptr-receiver &log.testLogStringPtrReceiver{Field:\"detail\"} \x1b[31mlog-string-ptr-receiver\x1b[0m\n",
141+
}, w1.GetLogs())
130142
}
131143

132144
func TestLoggerExpressionFilter(t *testing.T) {

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,9 @@ issues.time_estimate_invalid = Time estimate format is invalid
17021702
issues.start_tracking_history = started working %s
17031703
issues.tracker_auto_close = Timer will be stopped automatically when this issue gets closed
17041704
issues.tracking_already_started = `You have already started time tracking on <a href="%s">another issue</a>!`
1705+
issues.stop_tracking = Stop Timer
17051706
issues.stop_tracking_history = worked for <b>%[1]s</b> %[2]s
1707+
issues.cancel_tracking = Discard
17061708
issues.cancel_tracking_history = `canceled time tracking %s`
17071709
issues.del_time = Delete this time log
17081710
issues.add_time_history = added spent time <b>%[1]s</b> %[2]s

routers/web/repo/actions/actions.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func prepareWorkflowList(ctx *context.Context, workflows []Workflow) {
306306
}
307307
ctx.Data["Actors"] = shared_user.MakeSelfOnTop(ctx.Doer, actors)
308308

309-
ctx.Data["StatusInfoList"] = actions_model.GetStatusInfoList(ctx)
309+
ctx.Data["StatusInfoList"] = actions_model.GetStatusInfoList(ctx, ctx.Locale)
310310

311311
pager := context.NewPagination(int(total), opts.PageSize, opts.Page, 5)
312312
pager.AddParamFromRequest(ctx.Req)

routers/web/web.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -1196,16 +1196,17 @@ func registerRoutes(m *web.Router) {
11961196
})
11971197
})
11981198
}
1199+
// FIXME: many "pulls" requests are sent to "issues" endpoints correctly, so the issue endpoints have to tolerate pull request permissions at the moment
1200+
m.Group("/{username}/{reponame}/{type:issues}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, context.RequireUnitReader(unit.TypeIssues, unit.TypePullRequests))
1201+
m.Group("/{username}/{reponame}/{type:pulls}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitPullsReader)
1202+
11991203
m.Group("/{username}/{reponame}", func() {
12001204
m.Get("/comments/{id}/attachments", repo.GetCommentAttachments)
12011205
m.Get("/labels", repo.RetrieveLabelsForList, repo.Labels)
12021206
m.Get("/milestones", repo.Milestones)
12031207
m.Get("/milestone/{id}", context.RepoRef(), repo.MilestoneIssuesAndPulls)
12041208
m.Get("/issues/suggestions", repo.IssueSuggestions)
12051209
}, optSignIn, context.RepoAssignment, reqRepoIssuesOrPullsReader) // issue/pull attachments, labels, milestones
1206-
1207-
m.Group("/{username}/{reponame}/{type:issues}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitIssuesReader)
1208-
m.Group("/{username}/{reponame}/{type:pulls}", addIssuesPullsViewRoutes, optSignIn, context.RepoAssignment, reqUnitPullsReader)
12091210
// end "/{username}/{reponame}": view milestone, label, issue, pull, etc
12101211

12111212
m.Group("/{username}/{reponame}/{type:issues}", func() {
@@ -1224,7 +1225,7 @@ func registerRoutes(m *web.Router) {
12241225
m.Get("/search", repo.SearchRepoIssuesJSON)
12251226
}, reqUnitIssuesReader)
12261227

1227-
addIssuesPullsRoutes := func() {
1228+
addIssuesPullsUpdateRoutes := func() {
12281229
// for "/{username}/{reponame}/issues" or "/{username}/{reponame}/pulls"
12291230
m.Group("/{index}", func() {
12301231
m.Post("/title", repo.UpdateIssueTitle)
@@ -1267,8 +1268,9 @@ func registerRoutes(m *web.Router) {
12671268
m.Delete("/unpin/{index}", reqRepoAdmin, repo.IssueUnpin)
12681269
m.Post("/move_pin", reqRepoAdmin, repo.IssuePinMove)
12691270
}
1270-
m.Group("/{type:issues}", addIssuesPullsRoutes, reqUnitIssuesReader, context.RepoMustNotBeArchived())
1271-
m.Group("/{type:pulls}", addIssuesPullsRoutes, reqUnitPullsReader, context.RepoMustNotBeArchived())
1271+
// FIXME: many "pulls" requests are sent to "issues" endpoints incorrectly, so the issue endpoints have to tolerate pull request permissions at the moment
1272+
m.Group("/{type:issues}", addIssuesPullsUpdateRoutes, context.RequireUnitReader(unit.TypeIssues, unit.TypePullRequests), context.RepoMustNotBeArchived())
1273+
m.Group("/{type:pulls}", addIssuesPullsUpdateRoutes, reqUnitPullsReader, context.RepoMustNotBeArchived())
12721274

12731275
m.Group("/comments/{id}", func() {
12741276
m.Post("", repo.UpdateCommentContent)
@@ -1292,7 +1294,7 @@ func registerRoutes(m *web.Router) {
12921294
m.Post("/delete", repo.DeleteMilestone)
12931295
}, reqRepoIssuesOrPullsWriter, context.RepoRef())
12941296

1295-
// FIXME: need to move these routes to the proper place
1297+
// FIXME: many "pulls" requests are sent to "issues" endpoints incorrectly, need to move these routes to the proper place
12961298
m.Group("/issues", func() {
12971299
m.Post("/request_review", repo.UpdatePullReviewRequest)
12981300
m.Post("/dismiss_review", reqRepoAdmin, web.Bind(forms.DismissReviewForm{}), repo.DismissReview)

templates/org/home.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
{{if .ShowMemberAndTeamTab}}
1717
<div class="ui five wide column">
1818
{{if .CanCreateOrgRepo}}
19-
<div class="center aligned tw-mb-4">
20-
<a class="ui primary button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{ctx.Locale.Tr "new_repo"}}</a>
19+
<div class="tw-flex tw-flex-wrap tw-justify-center tw-gap-x-1 tw-gap-y-2 tw-mb-4">
20+
<a class="ui primary button tw-grow" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}">{{ctx.Locale.Tr "new_repo"}}</a>
2121
{{if not .DisableNewPullMirrors}}
22-
<a class="ui primary button" href="{{AppSubUrl}}/repo/migrate?org={{.Org.ID}}&mirror=1">{{ctx.Locale.Tr "new_migrate"}}</a>
22+
<a class="ui primary button tw-grow" href="{{AppSubUrl}}/repo/migrate?org={{.Org.ID}}&mirror=1">{{ctx.Locale.Tr "new_migrate"}}</a>
2323
{{end}}
2424
</div>
2525
<div class="divider"></div>

0 commit comments

Comments
 (0)