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
c823ad5d
Commit
c823ad5d
authored
Mar 12, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
team: uses PermissionType instead of int64 for permissions.
parent
21d3d274
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
15 deletions
+16
-15
pkg/api/team.go
+1
-1
pkg/models/team_member.go
+10
-10
pkg/services/sqlstore/team.go
+1
-0
pkg/services/sqlstore/team_test.go
+4
-4
No files found.
pkg/api/team.go
View file @
c823ad5d
...
...
@@ -23,7 +23,7 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
UserId
:
c
.
SignedInUser
.
UserId
,
OrgId
:
cmd
.
OrgId
,
TeamId
:
cmd
.
Result
.
Id
,
Permission
:
int64
(
m
.
PERMISSION_ADMIN
)
,
Permission
:
m
.
PERMISSION_ADMIN
,
}
if
err
:=
bus
.
Dispatch
(
&
addMemberCmd
);
err
!=
nil
{
...
...
pkg/models/team_member.go
View file @
c823ad5d
...
...
@@ -17,7 +17,7 @@ type TeamMember struct {
TeamId
int64
UserId
int64
External
bool
Permission
int64
Permission
PermissionType
Created
time
.
Time
Updated
time
.
Time
...
...
@@ -27,18 +27,18 @@ type TeamMember struct {
// COMMANDS
type
AddTeamMemberCommand
struct
{
UserId
int64
`json:"userId" binding:"Required"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
External
bool
`json:"-"`
Permission
int64
`json:"-"`
UserId
int64
`json:"userId" binding:"Required"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
External
bool
`json:"-"`
Permission
PermissionType
`json:"-"`
}
type
UpdateTeamMemberCommand
struct
{
UserId
int64
`json:"-"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
Permission
int64
`json:"permission"`
UserId
int64
`json:"-"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
Permission
PermissionType
`json:"permission"`
}
type
RemoveTeamMemberCommand
struct
{
...
...
pkg/services/sqlstore/team.go
View file @
c823ad5d
...
...
@@ -271,6 +271,7 @@ func UpdateTeamMember(cmd *m.UpdateTeamMemberCommand) error {
return
m
.
ErrTeamMemberNotFound
}
// TODO: check to make sure that permission is a legal value
member
.
Permission
=
cmd
.
Permission
_
,
err
=
sess
.
Cols
(
"permission"
)
.
Where
(
"org_id=? and team_id=? and user_id=?"
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
.
Update
(
member
)
...
...
pkg/services/sqlstore/team_test.go
View file @
c823ad5d
...
...
@@ -91,7 +91,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
UserId
:
userId
,
OrgId
:
testOrgId
,
TeamId
:
team
.
Id
,
Permission
:
int64
(
m
.
PERMISSION_ADMIN
)
,
Permission
:
m
.
PERMISSION_ADMIN
,
})
So
(
err
,
ShouldBeNil
)
...
...
@@ -107,7 +107,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
UserId
:
1
,
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
Permission
:
int64
(
m
.
PERMISSION_ADMIN
)
,
Permission
:
m
.
PERMISSION_ADMIN
,
})
So
(
err
,
ShouldEqual
,
m
.
ErrTeamMemberNotFound
)
...
...
@@ -153,7 +153,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
})
Convey
(
"When ProtectLastAdmin is set to true"
,
func
()
{
err
=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
UserId
:
userIds
[
0
],
Permission
:
int64
(
m
.
PERMISSION_ADMIN
)
})
err
=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
UserId
:
userIds
[
0
],
Permission
:
m
.
PERMISSION_ADMIN
})
So
(
err
,
ShouldBeNil
)
Convey
(
"A user should not be able to remove the last admin"
,
func
()
{
...
...
@@ -162,7 +162,7 @@ func TestTeamCommandsAndQueries(t *testing.T) {
})
Convey
(
"A user should be able to remove an admin if there are other admins"
,
func
()
{
err
=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
UserId
:
userIds
[
1
],
Permission
:
int64
(
m
.
PERMISSION_ADMIN
)
})
err
=
AddTeamMember
(
&
m
.
AddTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
UserId
:
userIds
[
1
],
Permission
:
m
.
PERMISSION_ADMIN
})
err
=
RemoveTeamMember
(
&
m
.
RemoveTeamMemberCommand
{
OrgId
:
testOrgId
,
TeamId
:
group1
.
Result
.
Id
,
UserId
:
userIds
[
0
],
ProtectLastAdmin
:
true
})
So
(
err
,
ShouldEqual
,
nil
)
})
...
...
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