Skip to content

Commit 08790c5

Browse files
author
Gusted
committed
Merge branch 'main' into add-mcaptcha
2 parents 4c52706 + 5ed082b commit 08790c5

File tree

8 files changed

+74
-5
lines changed

8 files changed

+74
-5
lines changed

integrations/org_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ func TestPrivateOrg(t *testing.T) {
116116
session.MakeRequest(t, req, http.StatusOK)
117117
}
118118

119+
func TestOrgMembers(t *testing.T) {
120+
defer prepareTestEnv(t)()
121+
122+
// not logged in user
123+
req := NewRequest(t, "GET", "/org/org25/members")
124+
MakeRequest(t, req, http.StatusOK)
125+
126+
// org member
127+
session := loginUser(t, "user24")
128+
req = NewRequest(t, "GET", "/org/org25/members")
129+
session.MakeRequest(t, req, http.StatusOK)
130+
131+
// site admin
132+
session = loginUser(t, "user1")
133+
req = NewRequest(t, "GET", "/org/org25/members")
134+
session.MakeRequest(t, req, http.StatusOK)
135+
}
136+
119137
func TestOrgRestrictedUser(t *testing.T) {
120138
defer prepareTestEnv(t)()
121139

models/issues/issue_list.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010

1111
"code.gitea.io/gitea/models/db"
12+
project_model "code.gitea.io/gitea/models/project"
1213
repo_model "code.gitea.io/gitea/models/repo"
1314
user_model "code.gitea.io/gitea/models/user"
1415
"code.gitea.io/gitea/modules/container"
@@ -222,6 +223,46 @@ func (issues IssueList) loadMilestones(ctx context.Context) error {
222223
return nil
223224
}
224225

226+
func (issues IssueList) getProjectIDs() []int64 {
227+
ids := make(map[int64]struct{}, len(issues))
228+
for _, issue := range issues {
229+
projectID := issue.ProjectID()
230+
if _, ok := ids[projectID]; !ok {
231+
ids[projectID] = struct{}{}
232+
}
233+
}
234+
return container.KeysInt64(ids)
235+
}
236+
237+
func (issues IssueList) loadProjects(ctx context.Context) error {
238+
projectIDs := issues.getProjectIDs()
239+
if len(projectIDs) == 0 {
240+
return nil
241+
}
242+
243+
projectMaps := make(map[int64]*project_model.Project, len(projectIDs))
244+
left := len(projectIDs)
245+
for left > 0 {
246+
limit := db.DefaultMaxInSize
247+
if left < limit {
248+
limit = left
249+
}
250+
err := db.GetEngine(ctx).
251+
In("id", projectIDs[:limit]).
252+
Find(&projectMaps)
253+
if err != nil {
254+
return err
255+
}
256+
left -= limit
257+
projectIDs = projectIDs[limit:]
258+
}
259+
260+
for _, issue := range issues {
261+
issue.Project = projectMaps[issue.ProjectID()]
262+
}
263+
return nil
264+
}
265+
225266
func (issues IssueList) loadAssignees(ctx context.Context) error {
226267
if len(issues) == 0 {
227268
return nil
@@ -495,6 +536,10 @@ func (issues IssueList) loadAttributes(ctx context.Context) error {
495536
return fmt.Errorf("issue.loadAttributes: loadMilestones: %v", err)
496537
}
497538

539+
if err := issues.loadProjects(ctx); err != nil {
540+
return fmt.Errorf("issue.loadAttributes: loadProjects: %v", err)
541+
}
542+
498543
if err := issues.loadAssignees(ctx); err != nil {
499544
return fmt.Errorf("issue.loadAttributes: loadAssignees: %v", err)
500545
}

routers/web/repo/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func SettingsPost(ctx *context.Context) {
476476
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
477477
}
478478

479-
if form.EnablePackages && !unit_model.TypeProjects.UnitGlobalDisabled() {
479+
if form.EnablePackages && !unit_model.TypePackages.UnitGlobalDisabled() {
480480
units = append(units, repo_model.RepoUnit{
481481
RepoID: repo.ID,
482482
Type: unit_model.TypePackages,

templates/base/head_navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
</div>
115115
</div>
116116

117-
<a href="{{AppSubUrl}}/notifications" class="item tooltip not-mobile" data-content='{{.locale.Tr "notifications"}}'>
117+
<a href="{{AppSubUrl}}/notifications" class="item tooltip not-mobile" data-content="{{.locale.Tr "notifications"}}" aria-label="{{.locale.Tr "notifications"}}">
118118
<span class="text">
119119
<span class="fitted">{{svg "octicon-bell"}}</span>
120120
<span class="ui red label {{if not $notificationUnreadCount}}hidden{{end}} notification_count">

templates/org/member/members.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{{end}}
3030
</div>
3131
</div>
32-
{{if not .PublicOnly}}
32+
{{if not $.PublicOnly}}
3333
<div class="ui three wide column center">
3434
<div class="meta">
3535
{{$.locale.Tr "org.members.member_role"}}

templates/repo/clone_buttons.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
document.getElementById('repo-clone-url').value = btn ? btn.getAttribute('data-link') : '';
2020
})();
2121
</script>
22-
<button class="ui basic icon button tooltip" id="clipboard-btn" data-content="{{.locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url">
22+
<button class="ui basic icon button tooltip" id="clipboard-btn" data-content="{{.locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{.locale.Tr "copy_url"}}">
2323
{{svg "octicon-paste"}}
2424
</button>

templates/shared/issuelist.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@
8989
{{svg "octicon-milestone" 14 "mr-2"}}{{.Milestone.Name}}
9090
</a>
9191
{{end}}
92+
{{if .Project}}
93+
<a class="project" {{if $.RepoLink}}href="{{$.RepoLink}}/projects/{{.Project.ID}}"{{else}}href="{{.Repo.Link}}/projects/{{.Project.ID}}"{{end}}>
94+
{{svg "octicon-project" 14 "mr-2"}}{{.Project.Title}}
95+
</a>
96+
{{end}}
9297
{{if .Ref}}
9398
<a class="ref" {{if $.RepoLink}}href="{{index $.IssueRefURLs .ID}}"{{else}}href="{{.Repo.Link}}{{index $.IssueRefURLs .ID}}"{{end}}>
9499
{{svg "octicon-git-branch" 14 "mr-2"}}{{index $.IssueRefEndNames .ID}}

web_src/less/shared/issuelist.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
padding-left: 5px;
102102
}
103103

104-
a.milestone {
104+
a.milestone,
105+
a.project {
105106
margin-left: 5px;
106107
}
107108

0 commit comments

Comments
 (0)