Team dashboards (#14159)
This commit is contained in:
parent
25f8970b2c
commit
40274b4a93
12 changed files with 148 additions and 47 deletions
|
@ -70,6 +70,11 @@ func Search(ctx *context.APIContext) {
|
|||
// description: repo owner to prioritize in the results
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: team_id
|
||||
// in: query
|
||||
// description: search only for repos that belong to the given team id
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: starredBy
|
||||
// in: query
|
||||
// description: search only for repos that the user with the given id has starred
|
||||
|
@ -131,6 +136,7 @@ func Search(ctx *context.APIContext) {
|
|||
Keyword: strings.Trim(ctx.Query("q"), " "),
|
||||
OwnerID: ctx.QueryInt64("uid"),
|
||||
PriorityOwnerID: ctx.QueryInt64("priority_owner_id"),
|
||||
TeamID: ctx.QueryInt64("team_id"),
|
||||
TopicOnly: ctx.QueryBool("topic"),
|
||||
Collaborate: util.OptionalBoolNone,
|
||||
Private: ctx.IsSigned && (ctx.Query("private") == "" || ctx.QueryBool("private")),
|
||||
|
|
|
@ -444,13 +444,15 @@ func RegisterMacaronRoutes(m *macaron.Macaron) {
|
|||
|
||||
m.Group("/:org", func() {
|
||||
m.Get("/dashboard", user.Dashboard)
|
||||
m.Get("/dashboard/:team", user.Dashboard)
|
||||
m.Get("/^:type(issues|pulls)$", user.Issues)
|
||||
m.Get("/^:type(issues|pulls)$/:team", user.Issues)
|
||||
m.Get("/milestones", reqMilestonesDashboardPageEnabled, user.Milestones)
|
||||
m.Get("/milestones/:team", reqMilestonesDashboardPageEnabled, user.Milestones)
|
||||
m.Get("/members", org.Members)
|
||||
m.Post("/members/action/:action", org.MembersAction)
|
||||
|
||||
m.Get("/teams", org.Teams)
|
||||
}, context.OrgAssignment(true))
|
||||
}, context.OrgAssignment(true, false, true))
|
||||
|
||||
m.Group("/:org", func() {
|
||||
m.Get("/teams/:team", org.TeamMembers)
|
||||
|
|
|
@ -42,17 +42,8 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
|
|||
ctxUser := ctx.User
|
||||
orgName := ctx.Params(":org")
|
||||
if len(orgName) > 0 {
|
||||
// Organization.
|
||||
org, err := models.GetUserByName(orgName)
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.NotFound("GetUserByName", err)
|
||||
} else {
|
||||
ctx.ServerError("GetUserByName", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
ctxUser = org
|
||||
ctxUser = ctx.Org.Organization
|
||||
ctx.Data["Teams"] = ctx.Org.Organization.Teams
|
||||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
|
@ -112,12 +103,13 @@ func Dashboard(ctx *context.Context) {
|
|||
ctx.Data["PageIsDashboard"] = true
|
||||
ctx.Data["PageIsNews"] = true
|
||||
ctx.Data["SearchLimit"] = setting.UI.User.RepoPagingNum
|
||||
|
||||
// no heatmap access for admins; GetUserHeatmapDataByUser ignores the calling user
|
||||
// so everyone would get the same empty heatmap
|
||||
if setting.Service.EnableUserHeatmap && !ctxUser.KeepActivityPrivate {
|
||||
data, err := models.GetUserHeatmapDataByUser(ctxUser, ctx.User)
|
||||
data, err := models.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.User)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserHeatmapDataByUser", err)
|
||||
ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["HeatmapData"] = data
|
||||
|
@ -126,12 +118,16 @@ func Dashboard(ctx *context.Context) {
|
|||
var err error
|
||||
var mirrors []*models.Repository
|
||||
if ctxUser.IsOrganization() {
|
||||
env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("AccessibleReposEnv", err)
|
||||
return
|
||||
var env models.AccessibleReposEnvironment
|
||||
if ctx.Org.Team != nil {
|
||||
env = ctxUser.AccessibleTeamReposEnv(ctx.Org.Team)
|
||||
} else {
|
||||
env, err = ctxUser.AccessibleReposEnv(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("AccessibleReposEnv", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
mirrors, err = env.MirrorRepos()
|
||||
if err != nil {
|
||||
ctx.ServerError("env.MirrorRepos", err)
|
||||
|
@ -155,6 +151,7 @@ func Dashboard(ctx *context.Context) {
|
|||
|
||||
retrieveFeeds(ctx, models.GetFeedsOptions{
|
||||
RequestedUser: ctxUser,
|
||||
RequestedTeam: ctx.Org.Team,
|
||||
Actor: ctx.User,
|
||||
IncludePrivate: true,
|
||||
OnlyPerformedBy: false,
|
||||
|
@ -183,16 +180,20 @@ func Milestones(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
var (
|
||||
repoOpts = models.SearchRepoOptions{
|
||||
Actor: ctxUser,
|
||||
OwnerID: ctxUser.ID,
|
||||
Private: true,
|
||||
AllPublic: false, // Include also all public repositories of users and public organisations
|
||||
AllLimited: false, // Include also all public repositories of limited organisations
|
||||
HasMilestones: util.OptionalBoolTrue, // Just needs display repos has milestones
|
||||
}
|
||||
repoOpts := models.SearchRepoOptions{
|
||||
Actor: ctxUser,
|
||||
OwnerID: ctxUser.ID,
|
||||
Private: true,
|
||||
AllPublic: false, // Include also all public repositories of users and public organisations
|
||||
AllLimited: false, // Include also all public repositories of limited organisations
|
||||
HasMilestones: util.OptionalBoolTrue, // Just needs display repos has milestones
|
||||
}
|
||||
|
||||
if ctxUser.IsOrganization() && ctx.Org.Team != nil {
|
||||
repoOpts.TeamID = ctx.Org.Team.ID
|
||||
}
|
||||
|
||||
var (
|
||||
userRepoCond = models.SearchRepositoryCondition(&repoOpts) // all repo condition user could visit
|
||||
repoCond = userRepoCond
|
||||
repoIDs []int64
|
||||
|
@ -412,10 +413,15 @@ func Issues(ctx *context.Context) {
|
|||
var err error
|
||||
var userRepoIDs []int64
|
||||
if ctxUser.IsOrganization() {
|
||||
env, err := ctxUser.AccessibleReposEnv(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("AccessibleReposEnv", err)
|
||||
return
|
||||
var env models.AccessibleReposEnvironment
|
||||
if ctx.Org.Team != nil {
|
||||
env = ctxUser.AccessibleTeamReposEnv(ctx.Org.Team)
|
||||
} else {
|
||||
env, err = ctxUser.AccessibleReposEnv(ctx.User.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("AccessibleReposEnv", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
userRepoIDs, err = env.RepoIDs(1, ctxUser.NumRepos)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue