Skip to content

Commit a8f061f

Browse files
authored
Merge branch 'main' into fix-migration-dns-error
2 parents 4dea49e + 3725fa2 commit a8f061f

File tree

20 files changed

+222
-17
lines changed

20 files changed

+222
-17
lines changed

integrations/api_team_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"code.gitea.io/gitea/models/organization"
14+
"code.gitea.io/gitea/models/repo"
1415
"code.gitea.io/gitea/models/unit"
1516
"code.gitea.io/gitea/models/unittest"
1617
user_model "code.gitea.io/gitea/models/user"
@@ -239,3 +240,26 @@ func TestAPITeamSearch(t *testing.T) {
239240
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s&token=%s", org.Name, "team", token5)
240241
MakeRequest(t, req, http.StatusForbidden)
241242
}
243+
244+
func TestAPIGetTeamRepo(t *testing.T) {
245+
defer prepareTestEnv(t)()
246+
247+
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 15}).(*user_model.User)
248+
teamRepo := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 24}).(*repo.Repository)
249+
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 5}).(*organization.Team)
250+
251+
var results api.Repository
252+
253+
token := getUserToken(t, user.Name)
254+
req := NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token)
255+
resp := MakeRequest(t, req, http.StatusOK)
256+
DecodeJSON(t, resp, &results)
257+
assert.Equal(t, "big_test_private_4", teamRepo.Name)
258+
259+
// no access if not organization member
260+
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
261+
token5 := getUserToken(t, user5.Name)
262+
263+
req = NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token5)
264+
MakeRequest(t, req, http.StatusNotFound)
265+
}

routers/api/v1/api.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ func Routes() *web.Route {
11211121
m.Get("", org.GetTeamRepos)
11221122
m.Combo("/{org}/{reponame}").
11231123
Put(org.AddTeamRepository).
1124-
Delete(org.RemoveTeamRepository)
1124+
Delete(org.RemoveTeamRepository).
1125+
Get(org.GetTeamRepo)
11251126
})
11261127
}, orgAssignment(false, true), reqToken(), reqTeamMembership())
11271128

routers/api/v1/org/team.go

+49
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,55 @@ func GetTeamRepos(ctx *context.APIContext) {
558558
ctx.JSON(http.StatusOK, repos)
559559
}
560560

561+
// GetTeamRepo api for get a particular repo of team
562+
func GetTeamRepo(ctx *context.APIContext) {
563+
// swagger:operation GET /teams/{id}/repos/{org}/{repo} organization orgListTeamRepo
564+
// ---
565+
// summary: List a particular repo of team
566+
// produces:
567+
// - application/json
568+
// parameters:
569+
// - name: id
570+
// in: path
571+
// description: id of the team
572+
// type: integer
573+
// format: int64
574+
// required: true
575+
// - name: org
576+
// in: path
577+
// description: organization that owns the repo to list
578+
// type: string
579+
// required: true
580+
// - name: repo
581+
// in: path
582+
// description: name of the repo to list
583+
// type: string
584+
// required: true
585+
// responses:
586+
// "200":
587+
// "$ref": "#/responses/Repository"
588+
// "404":
589+
// "$ref": "#/responses/notFound"
590+
591+
repo := getRepositoryByParams(ctx)
592+
if ctx.Written() {
593+
return
594+
}
595+
596+
if !organization.HasTeamRepo(ctx, ctx.Org.Team.OrgID, ctx.Org.Team.ID, repo.ID) {
597+
ctx.NotFound()
598+
return
599+
}
600+
601+
access, err := models.AccessLevel(ctx.Doer, repo)
602+
if err != nil {
603+
ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
604+
return
605+
}
606+
607+
ctx.JSON(http.StatusOK, convert.ToRepo(repo, access))
608+
}
609+
561610
// getRepositoryByParams get repository by a team's organization ID and repo name
562611
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
563612
repo, err := repo_model.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))

templates/admin/auth/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111
</h4>
1212
<div class="ui attached table segment">
13-
<table class="ui very basic striped table">
13+
<table class="ui very basic striped table unstackable">
1414
<thead>
1515
<tr>
1616
<th>ID</th>

templates/admin/cron.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</h4>
44
<div class="ui attached table segment">
55
<form method="post" action="{{AppSubUrl}}/admin">
6-
<table class="ui very basic striped table">
6+
<table class="ui very basic striped table unstackable">
77
<thead>
88
<tr>
99
<th></th>

templates/admin/emails/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</form>
3131
</div>
3232
<div class="ui attached table segment">
33-
<table class="ui very basic striped table">
33+
<table class="ui very basic striped table unstackable">
3434
<thead>
3535
<tr>
3636
<th data-sortt-asc="username" data-sortt-desc="reverseusername">

templates/admin/monitor.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{.i18n.Tr "admin.monitor.queues"}}
99
</h4>
1010
<div class="ui attached table segment">
11-
<table class="ui very basic striped table">
11+
<table class="ui very basic striped table unstackable">
1212
<thead>
1313
<tr>
1414
<th>{{.i18n.Tr "admin.monitor.queue.name"}}</th>

templates/admin/notice.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}})
88
</h4>
99
<div class="ui attached table segment">
10-
<table id="notice-table" class="ui very basic select selectable table">
10+
<table id="notice-table" class="ui very basic select selectable table unstackable">
1111
<thead>
1212
<tr>
1313
<th></th>

templates/admin/org/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{template "admin/base/search" .}}
1414
</div>
1515
<div class="ui attached table segment">
16-
<table class="ui very basic striped table">
16+
<table class="ui very basic striped table unstackable">
1717
<thead>
1818
<tr>
1919
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" $.SortType false}}</th>

templates/admin/packages/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</form>
3030
</div>
3131
<div class="ui attached table segment">
32-
<table class="ui very basic striped table">
32+
<table class="ui very basic striped table unstackable">
3333
<thead>
3434
<tr>
3535
<th>ID</th>

templates/admin/repo/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{{template "admin/repo/search" .}}
1414
</div>
1515
<div class="ui attached table segment">
16-
<table class="ui very basic striped table">
16+
<table class="ui very basic striped table unstackable">
1717
<thead>
1818
<tr>
1919
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" $.SortType false}}</th>

templates/admin/user/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
</form>
6262
</div>
6363
<div class="ui attached table segment">
64-
<table class="ui very basic striped table">
64+
<table class="ui very basic striped table unstackable">
6565
<thead>
6666
<tr>
6767
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" .SortType false}}</th>

templates/repo/issue/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="page-content repository">
33
{{template "repo/header" .}}
44
<div class="ui container">
5-
<div class="ui three column stackable grid">
5+
<div class="ui three column grid issue-list-headers">
66
<div class="column">
77
{{template "repo/issue/navbar" .}}
88
</div>

templates/repo/issue/view.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="page-content repository view issue pull">
33
{{template "repo/header" .}}
44
<div class="ui container">
5-
<div class="ui two column stackable grid">
5+
<div class="ui two column grid">
66
<div class="column">
77
{{template "repo/issue/navbar" .}}
88
</div>

templates/repo/issue/view_content.tmpl

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
{{if .Repository.OriginalURL}} ({{$.i18n.Tr "repo.migrated_from" (.Repository.OriginalURL|Escape) (.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}}
4242
</span>
4343
{{else}}
44+
<a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}">
45+
{{avatar .Issue.Poster}}
46+
</a>
4447
<span class="text grey">
4548
<a class="author"{{if gt .Issue.Poster.ID 0}} href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
4649
{{.i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe}}
@@ -50,12 +53,12 @@
5053
<div class="comment-header-right actions df ac">
5154
{{if gt .Issue.ShowRole 0}}
5255
{{if (.Issue.ShowRole.HasRole "Writer")}}
53-
<div class="ui basic label">
56+
<div class="ui basic label role-label">
5457
{{$.i18n.Tr "repo.issues.collaborator"}}
5558
</div>
5659
{{end}}
5760
{{if (.Issue.ShowRole.HasRole "Owner")}}
58-
<div class="ui basic label">
61+
<div class="ui basic label role-label">
5962
{{$.i18n.Tr "repo.issues.owner"}}
6063
</div>
6164
{{end}}

templates/repo/issue/view_content/comments.tmpl

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}}
3636
</span>
3737
{{else}}
38+
{{if gt .Poster.ID 0}}
39+
<a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}">
40+
{{avatar .Poster}}
41+
</a>
42+
{{end}}
3843
<span class="text grey">
3944
<a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
4045
{{.Poster.GetDisplayName}}

templates/swagger/v1_json.tmpl

+42
Original file line numberDiff line numberDiff line change
@@ -11114,6 +11114,48 @@
1111411114
}
1111511115
},
1111611116
"/teams/{id}/repos/{org}/{repo}": {
11117+
"get": {
11118+
"produces": [
11119+
"application/json"
11120+
],
11121+
"tags": [
11122+
"organization"
11123+
],
11124+
"summary": "List a particular repo of team",
11125+
"operationId": "orgListTeamRepo",
11126+
"parameters": [
11127+
{
11128+
"type": "integer",
11129+
"format": "int64",
11130+
"description": "id of the team",
11131+
"name": "id",
11132+
"in": "path",
11133+
"required": true
11134+
},
11135+
{
11136+
"type": "string",
11137+
"description": "organization that owns the repo to list",
11138+
"name": "org",
11139+
"in": "path",
11140+
"required": true
11141+
},
11142+
{
11143+
"type": "string",
11144+
"description": "name of the repo to list",
11145+
"name": "repo",
11146+
"in": "path",
11147+
"required": true
11148+
}
11149+
],
11150+
"responses": {
11151+
"200": {
11152+
"$ref": "#/responses/Repository"
11153+
},
11154+
"404": {
11155+
"$ref": "#/responses/notFound"
11156+
}
11157+
}
11158+
},
1111711159
"put": {
1111811160
"produces": [
1111911161
"application/json"

web_src/less/_admin.less

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.table.segment {
1313
padding: 0;
1414
font-size: 13px;
15+
overflow-x: scroll;
1516

1617
&:not(.striped) {
1718
thead {
@@ -62,6 +63,9 @@
6263

6364
dd {
6465
margin-left: 275px;
66+
@media @mediaSm {
67+
margin-left: 5%;
68+
}
6569
}
6670

6771
dt {
@@ -72,6 +76,11 @@
7276
overflow: hidden;
7377
text-overflow: ellipsis;
7478
white-space: nowrap;
79+
80+
@media @mediaSm {
81+
width: auto;
82+
margin-right: .5em;
83+
}
7584
}
7685
}
7786

0 commit comments

Comments
 (0)