Skip to content

Commit

Permalink
Merge branch 'main' into fix-migration-dns-error
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored May 1, 2022
2 parents 4dea49e + 3725fa2 commit a8f061f
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 17 deletions.
24 changes: 24 additions & 0 deletions integrations/api_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
Expand Down Expand Up @@ -239,3 +240,26 @@ func TestAPITeamSearch(t *testing.T) {
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s&token=%s", org.Name, "team", token5)
MakeRequest(t, req, http.StatusForbidden)
}

func TestAPIGetTeamRepo(t *testing.T) {
defer prepareTestEnv(t)()

user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 15}).(*user_model.User)
teamRepo := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 24}).(*repo.Repository)
team := unittest.AssertExistsAndLoadBean(t, &organization.Team{ID: 5}).(*organization.Team)

var results api.Repository

token := getUserToken(t, user.Name)
req := NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token)
resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &results)
assert.Equal(t, "big_test_private_4", teamRepo.Name)

// no access if not organization member
user5 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
token5 := getUserToken(t, user5.Name)

req = NewRequestf(t, "GET", "/api/v1/teams/%d/repos/%s/?token=%s", team.ID, teamRepo.FullName(), token5)
MakeRequest(t, req, http.StatusNotFound)
}
3 changes: 2 additions & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,8 @@ func Routes() *web.Route {
m.Get("", org.GetTeamRepos)
m.Combo("/{org}/{reponame}").
Put(org.AddTeamRepository).
Delete(org.RemoveTeamRepository)
Delete(org.RemoveTeamRepository).
Get(org.GetTeamRepo)
})
}, orgAssignment(false, true), reqToken(), reqTeamMembership())

Expand Down
49 changes: 49 additions & 0 deletions routers/api/v1/org/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,55 @@ func GetTeamRepos(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, repos)
}

// GetTeamRepo api for get a particular repo of team
func GetTeamRepo(ctx *context.APIContext) {
// swagger:operation GET /teams/{id}/repos/{org}/{repo} organization orgListTeamRepo
// ---
// summary: List a particular repo of team
// produces:
// - application/json
// parameters:
// - name: id
// in: path
// description: id of the team
// type: integer
// format: int64
// required: true
// - name: org
// in: path
// description: organization that owns the repo to list
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo to list
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/Repository"
// "404":
// "$ref": "#/responses/notFound"

repo := getRepositoryByParams(ctx)
if ctx.Written() {
return
}

if !organization.HasTeamRepo(ctx, ctx.Org.Team.OrgID, ctx.Org.Team.ID, repo.ID) {
ctx.NotFound()
return
}

access, err := models.AccessLevel(ctx.Doer, repo)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
return
}

ctx.JSON(http.StatusOK, convert.ToRepo(repo, access))
}

// getRepositoryByParams get repository by a team's organization ID and repo name
func getRepositoryByParams(ctx *context.APIContext) *repo_model.Repository {
repo, err := repo_model.GetRepositoryByName(ctx.Org.Team.OrgID, ctx.Params(":reponame"))
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/auth/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
</h4>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th>ID</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/cron.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</h4>
<div class="ui attached table segment">
<form method="post" action="{{AppSubUrl}}/admin">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th></th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/emails/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</form>
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th data-sortt-asc="username" data-sortt-desc="reverseusername">
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/monitor.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{.i18n.Tr "admin.monitor.queues"}}
</h4>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th>{{.i18n.Tr "admin.monitor.queue.name"}}</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/notice.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}})
</h4>
<div class="ui attached table segment">
<table id="notice-table" class="ui very basic select selectable table">
<table id="notice-table" class="ui very basic select selectable table unstackable">
<thead>
<tr>
<th></th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/org/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{template "admin/base/search" .}}
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" $.SortType false}}</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/packages/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</form>
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th>ID</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/repo/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{template "admin/repo/search" .}}
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" $.SortType false}}</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/user/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</form>
</div>
<div class="ui attached table segment">
<table class="ui very basic striped table">
<table class="ui very basic striped table unstackable">
<thead>
<tr>
<th data-sortt-asc="oldest" data-sortt-desc="newest">ID{{SortArrow "oldest" "newest" .SortType false}}</th>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="page-content repository">
{{template "repo/header" .}}
<div class="ui container">
<div class="ui three column stackable grid">
<div class="ui three column grid issue-list-headers">
<div class="column">
{{template "repo/issue/navbar" .}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/issue/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="page-content repository view issue pull">
{{template "repo/header" .}}
<div class="ui container">
<div class="ui two column stackable grid">
<div class="ui two column grid">
<div class="column">
{{template "repo/issue/navbar" .}}
</div>
Expand Down
7 changes: 5 additions & 2 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
{{if .Repository.OriginalURL}} ({{$.i18n.Tr "repo.migrated_from" (.Repository.OriginalURL|Escape) (.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}}
</span>
{{else}}
<a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}">
{{avatar .Issue.Poster}}
</a>
<span class="text grey">
<a class="author"{{if gt .Issue.Poster.ID 0}} href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
{{.i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe}}
Expand All @@ -50,12 +53,12 @@
<div class="comment-header-right actions df ac">
{{if gt .Issue.ShowRole 0}}
{{if (.Issue.ShowRole.HasRole "Writer")}}
<div class="ui basic label">
<div class="ui basic label role-label">
{{$.i18n.Tr "repo.issues.collaborator"}}
</div>
{{end}}
{{if (.Issue.ShowRole.HasRole "Owner")}}
<div class="ui basic label">
<div class="ui basic label role-label">
{{$.i18n.Tr "repo.issues.owner"}}
</div>
{{end}}
Expand Down
5 changes: 5 additions & 0 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}}
</span>
{{else}}
{{if gt .Poster.ID 0}}
<a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}">
{{avatar .Poster}}
</a>
{{end}}
<span class="text grey">
<a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
{{.Poster.GetDisplayName}}
Expand Down
42 changes: 42 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11114,6 +11114,48 @@
}
},
"/teams/{id}/repos/{org}/{repo}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"organization"
],
"summary": "List a particular repo of team",
"operationId": "orgListTeamRepo",
"parameters": [
{
"type": "integer",
"format": "int64",
"description": "id of the team",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "organization that owns the repo to list",
"name": "org",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo to list",
"name": "repo",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/Repository"
},
"404": {
"$ref": "#/responses/notFound"
}
}
},
"put": {
"produces": [
"application/json"
Expand Down
9 changes: 9 additions & 0 deletions web_src/less/_admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.table.segment {
padding: 0;
font-size: 13px;
overflow-x: scroll;

&:not(.striped) {
thead {
Expand Down Expand Up @@ -62,6 +63,9 @@

dd {
margin-left: 275px;
@media @mediaSm {
margin-left: 5%;
}
}

dt {
Expand All @@ -72,6 +76,11 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

@media @mediaSm {
width: auto;
margin-right: .5em;
}
}
}

Expand Down
Loading

0 comments on commit a8f061f

Please sign in to comment.