Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0d61f895
Commit
0d61f895
authored
Mar 11, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: cleanup.
parent
3be1d71f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
15 deletions
+18
-15
pkg/api/team.go
+6
-1
pkg/services/teams/team.go
+1
-9
pkg/services/teams/teams_test.go
+11
-5
No files found.
pkg/api/team.go
View file @
0d61f895
...
...
@@ -41,7 +41,12 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
func
UpdateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
UpdateTeamCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
cmd
.
Id
=
c
.
ParamsInt64
(
":teamId"
)
if
err
:=
teams
.
UpdateTeam
(
c
.
SignedInUser
,
&
cmd
);
err
!=
nil
{
if
err
:=
teams
.
CanUpdateTeam
(
cmd
.
OrgId
,
cmd
.
Id
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"User not allowed to update team"
,
err
)
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
==
m
.
ErrTeamNameTaken
{
return
Error
(
400
,
"Team name taken"
,
err
)
}
...
...
pkg/services/teams/team.go
View file @
0d61f895
...
...
@@ -5,7 +5,7 @@ import (
m
"github.com/grafana/grafana/pkg/models"
)
func
c
anUpdateTeam
(
orgId
int64
,
teamId
int64
,
user
*
m
.
SignedInUser
)
error
{
func
C
anUpdateTeam
(
orgId
int64
,
teamId
int64
,
user
*
m
.
SignedInUser
)
error
{
if
user
.
OrgRole
==
m
.
ROLE_ADMIN
{
return
nil
}
...
...
@@ -34,11 +34,3 @@ func canUpdateTeam(orgId int64, teamId int64, user *m.SignedInUser) error {
return
m
.
ErrNotAllowedToUpdateTeam
}
func
UpdateTeam
(
user
*
m
.
SignedInUser
,
cmd
*
m
.
UpdateTeamCommand
)
error
{
if
err
:=
canUpdateTeam
(
cmd
.
OrgId
,
cmd
.
Id
,
user
);
err
!=
nil
{
return
err
}
return
bus
.
Dispatch
(
cmd
)
}
pkg/services/teams/teams_test.go
View file @
0d61f895
...
...
@@ -40,12 +40,12 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
UpdateTeam
(
&
editor
,
&
updateTeamCmd
)
err
:=
Can
UpdateTeam
(
&
editor
,
&
updateTeamCmd
)
So
(
err
,
ShouldEqual
,
m
.
ErrNotAllowedToUpdateTeam
)
})
})
Convey
(
"Given an editor and a team he is a
member of
"
,
func
()
{
Convey
(
"Given an editor and a team he is a
n admin in
"
,
func
()
{
Convey
(
"Should be able to update the team"
,
func
()
{
teamUpdatedCallback
:=
updateTeamCalled
()
...
...
@@ -59,7 +59,7 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
UpdateTeam
(
&
editor
,
&
updateTeamCmd
)
err
:=
Can
UpdateTeam
(
&
editor
,
&
updateTeamCmd
)
So
(
teamUpdatedCallback
(),
ShouldBeTrue
)
So
(
err
,
ShouldBeNil
)
})
...
...
@@ -88,7 +88,7 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
UpdateTeam
(
&
editor
,
&
cmd
)
err
:=
Can
UpdateTeam
(
&
editor
,
&
cmd
)
So
(
err
,
ShouldEqual
,
m
.
ErrNotAllowedToUpdateTeamInDifferentOrg
)
})
})
...
...
@@ -96,12 +96,18 @@ func TestUpdateTeam(t *testing.T) {
Convey
(
"Given an org admin and a team"
,
func
()
{
Convey
(
"Should be able to update the team"
,
func
()
{
teamUpdatedCallback
:=
updateTeamCalled
()
err
:=
UpdateTeam
(
&
admin
,
&
updateTeamCmd
)
err
:=
Can
UpdateTeam
(
&
admin
,
&
updateTeamCmd
)
So
(
teamUpdatedCallback
(),
ShouldBeTrue
)
So
(
err
,
ShouldBeNil
)
})
})
Convey
(
"Given that the editorsCanOwn feature toggle is disabled"
,
func
()
{
Convey
(
"Given an editor and a team he is an admin"
,
func
()
{
})
})
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment