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
b783fa70
Commit
b783fa70
authored
Mar 12, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
team: renames teams.CanUpdate teamguardian.CanAdmin
parent
96aa4ae1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
21 deletions
+26
-21
pkg/api/dashboard_test.go
+1
-0
pkg/api/folder_test.go
+1
-4
pkg/api/team.go
+12
-5
pkg/api/team_members.go
+4
-4
pkg/services/teamguardian/team.go
+2
-2
pkg/services/teamguardian/teams_test.go
+5
-5
public/app/types/acl.ts
+1
-1
No files found.
pkg/api/dashboard_test.go
View file @
b783fa70
...
...
@@ -1028,6 +1028,7 @@ func restoreDashboardVersionScenario(desc string, url string, routePattern strin
defer
bus
.
ClearBusHandlers
()
hs
:=
HTTPServer
{
Cfg
:
setting
.
NewCfg
(),
Bus
:
bus
.
GetBus
(),
}
...
...
pkg/api/folder_test.go
View file @
b783fa70
...
...
@@ -142,12 +142,9 @@ func createFolderScenario(desc string, url string, routePattern string, mock *fa
Convey
(
desc
+
" "
+
url
,
func
()
{
defer
bus
.
ClearBusHandlers
()
cfg
:=
setting
.
NewCfg
()
cfg
.
EditorsCanAdmin
=
true
hs
:=
HTTPServer
{
Bus
:
bus
.
GetBus
(),
Cfg
:
cfg
,
Cfg
:
setting
.
NewCfg
()
,
}
sc
:=
setupScenarioContext
(
url
)
...
...
pkg/api/team.go
View file @
b783fa70
...
...
@@ -4,7 +4,7 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/team
s
"
"github.com/grafana/grafana/pkg/services/team
guardian
"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -42,7 +42,7 @@ func UpdateTeam(c *m.ReqContext, cmd m.UpdateTeamCommand) Response {
cmd
.
OrgId
=
c
.
OrgId
cmd
.
Id
=
c
.
ParamsInt64
(
":teamId"
)
if
err
:=
team
s
.
CanUpdateTeam
(
cmd
.
OrgId
,
cmd
.
Id
,
c
.
SignedInUser
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
cmd
.
OrgId
,
cmd
.
Id
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to update team"
,
err
)
}
...
...
@@ -62,7 +62,7 @@ func DeleteTeamByID(c *m.ReqContext) Response {
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
user
:=
c
.
SignedInUser
if
err
:=
team
s
.
CanUpdateTeam
(
orgId
,
teamId
,
user
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
orgId
,
teamId
,
user
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to delete team"
,
err
)
}
...
...
@@ -132,7 +132,14 @@ func GetTeamByID(c *m.ReqContext) Response {
// GET /api/teams/:teamId/preferences
func
GetTeamPreferences
(
c
*
m
.
ReqContext
)
Response
{
return
getPreferencesFor
(
c
.
OrgId
,
0
,
c
.
ParamsInt64
(
":teamId"
))
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
orgId
:=
c
.
OrgId
if
err
:=
teamguardian
.
CanAdmin
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to view team preferences."
,
err
)
}
return
getPreferencesFor
(
orgId
,
0
,
teamId
)
}
// PUT /api/teams/:teamId/preferences
...
...
@@ -140,7 +147,7 @@ func UpdateTeamPreferences(c *m.ReqContext, dtoCmd dtos.UpdatePrefsCmd) Response
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
orgId
:=
c
.
OrgId
if
err
:=
team
s
.
CanUpdateTeam
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to update team preferences."
,
err
)
}
...
...
pkg/api/team_members.go
View file @
b783fa70
...
...
@@ -4,7 +4,7 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/team
s
"
"github.com/grafana/grafana/pkg/services/team
guardian
"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)
...
...
@@ -34,7 +34,7 @@ func AddTeamMember(c *m.ReqContext, cmd m.AddTeamMemberCommand) Response {
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
orgId
:=
c
.
OrgId
if
err
:=
team
s
.
CanUpdateTeam
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to add team member"
,
err
)
}
...
...
@@ -63,7 +63,7 @@ func UpdateTeamMember(c *m.ReqContext, cmd m.UpdateTeamMemberCommand) Response {
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
orgId
:=
c
.
OrgId
if
err
:=
team
s
.
CanUpdateTeam
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to update team member"
,
err
)
}
...
...
@@ -86,7 +86,7 @@ func RemoveTeamMember(c *m.ReqContext) Response {
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
userId
:=
c
.
ParamsInt64
(
":userId"
)
if
err
:=
team
s
.
CanUpdateTeam
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
if
err
:=
team
guardian
.
CanAdmin
(
orgId
,
teamId
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to remove team member"
,
err
)
}
...
...
pkg/services/team
s
/team.go
→
pkg/services/team
guardian
/team.go
View file @
b783fa70
package
team
s
package
team
guardian
import
(
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
)
func
Can
UpdateTeam
(
orgId
int64
,
teamId
int64
,
user
*
m
.
SignedInUser
)
error
{
func
Can
Admin
(
orgId
int64
,
teamId
int64
,
user
*
m
.
SignedInUser
)
error
{
if
user
.
OrgRole
==
m
.
ROLE_ADMIN
{
return
nil
}
...
...
pkg/services/team
s
/teams_test.go
→
pkg/services/team
guardian
/teams_test.go
View file @
b783fa70
package
team
s
package
team
guardian
import
(
"github.com/grafana/grafana/pkg/bus"
...
...
@@ -33,7 +33,7 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
Can
UpdateTeam
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
editor
)
err
:=
Can
Admin
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
editor
)
So
(
err
,
ShouldEqual
,
m
.
ErrNotAllowedToUpdateTeam
)
})
})
...
...
@@ -50,7 +50,7 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
Can
UpdateTeam
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
editor
)
err
:=
Can
Admin
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
editor
)
So
(
err
,
ShouldBeNil
)
})
})
...
...
@@ -72,14 +72,14 @@ func TestUpdateTeam(t *testing.T) {
return
nil
})
err
:=
Can
UpdateTeam
(
testTeamOtherOrg
.
OrgId
,
testTeamOtherOrg
.
Id
,
&
editor
)
err
:=
Can
Admin
(
testTeamOtherOrg
.
OrgId
,
testTeamOtherOrg
.
Id
,
&
editor
)
So
(
err
,
ShouldEqual
,
m
.
ErrNotAllowedToUpdateTeamInDifferentOrg
)
})
})
Convey
(
"Given an org admin and a team"
,
func
()
{
Convey
(
"Should be able to update the team"
,
func
()
{
err
:=
Can
UpdateTeam
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
admin
)
err
:=
Can
Admin
(
testTeam
.
OrgId
,
testTeam
.
Id
,
&
admin
)
So
(
err
,
ShouldBeNil
)
})
})
...
...
public/app/types/acl.ts
View file @
b783fa70
...
...
@@ -115,6 +115,6 @@ export const teamsPermissionLevels: TeamPermissionInfo[] = [
{
value
:
TeamPermissionLevel
.
Admin
,
label
:
'Admin'
,
description
:
'Can add/remove permissions and delete team.'
,
description
:
'Can add/remove permissions
, members
and delete team.'
,
},
];
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