mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
22788d1d86
* Add an option to hide certain users in the UI * revert changes for admin users routes * fix sqlstore function name * Improve slice management Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> * Hidden users: convert slice to map * filter with user logins instead of IDs * put HiddenUsers in Cfg struct * hide hidden users from dashboards/folders permissions list * Update conf/defaults.ini Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * fix params order * fix tests * fix dashboard/folder update with hidden user * add team tests * add dashboard and folder permissions tests * fixes after merge * fix tests * API: add test for org users endpoints * update hidden users management for dashboard / folder permissions * improve dashboard / folder permissions tests * fixes after merge * Guardian: add hidden acl tests * API: add team members tests * fix team sql syntax for postgres * api tests update * fix linter error * fix tests errors after merge Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com> Co-authored-by: Leonard Gram <leo@xlson.com>
100 lines
2.2 KiB
Go
100 lines
2.2 KiB
Go
package models
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
// Typed errors
|
|
var (
|
|
ErrTeamNotFound = errors.New("team not found")
|
|
ErrTeamNameTaken = errors.New("team name is taken")
|
|
ErrTeamMemberNotFound = errors.New("team member not found")
|
|
ErrLastTeamAdmin = errors.New("not allowed to remove last admin")
|
|
ErrNotAllowedToUpdateTeam = errors.New("user not allowed to update team")
|
|
ErrNotAllowedToUpdateTeamInDifferentOrg = errors.New("user not allowed to update team in another org")
|
|
)
|
|
|
|
// Team model
|
|
type Team struct {
|
|
Id int64 `json:"id"`
|
|
OrgId int64 `json:"orgId"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
|
|
Created time.Time `json:"created"`
|
|
Updated time.Time `json:"updated"`
|
|
}
|
|
|
|
// ---------------------
|
|
// COMMANDS
|
|
|
|
type CreateTeamCommand struct {
|
|
Name string `json:"name" binding:"Required"`
|
|
Email string `json:"email"`
|
|
OrgId int64 `json:"-"`
|
|
|
|
Result Team `json:"-"`
|
|
}
|
|
|
|
type UpdateTeamCommand struct {
|
|
Id int64
|
|
Name string
|
|
Email string
|
|
OrgId int64 `json:"-"`
|
|
}
|
|
|
|
type DeleteTeamCommand struct {
|
|
OrgId int64
|
|
Id int64
|
|
}
|
|
|
|
type GetTeamByIdQuery struct {
|
|
OrgId int64
|
|
Id int64
|
|
SignedInUser *SignedInUser
|
|
HiddenUsers map[string]struct{}
|
|
Result *TeamDTO
|
|
}
|
|
|
|
type GetTeamsByUserQuery struct {
|
|
OrgId int64
|
|
UserId int64 `json:"userId"`
|
|
Result []*TeamDTO `json:"teams"`
|
|
}
|
|
|
|
type SearchTeamsQuery struct {
|
|
Query string
|
|
Name string
|
|
Limit int
|
|
Page int
|
|
OrgId int64
|
|
UserIdFilter int64
|
|
SignedInUser *SignedInUser
|
|
HiddenUsers map[string]struct{}
|
|
|
|
Result SearchTeamQueryResult
|
|
}
|
|
|
|
type TeamDTO struct {
|
|
Id int64 `json:"id"`
|
|
OrgId int64 `json:"orgId"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
AvatarUrl string `json:"avatarUrl"`
|
|
MemberCount int64 `json:"memberCount"`
|
|
Permission PermissionType `json:"permission"`
|
|
}
|
|
|
|
type SearchTeamQueryResult struct {
|
|
TotalCount int64 `json:"totalCount"`
|
|
Teams []*TeamDTO `json:"teams"`
|
|
Page int `json:"page"`
|
|
PerPage int `json:"perPage"`
|
|
}
|
|
|
|
type IsAdminOfTeamsQuery struct {
|
|
SignedInUser *SignedInUser
|
|
Result bool
|
|
}
|