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
e0b9ba75
Commit
e0b9ba75
authored
Jun 19, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring renaming dashboard folder operations
parent
34cf305d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
50 additions
and
51 deletions
+50
-51
pkg/api/api.go
+1
-1
pkg/api/dashboard_acl.go
+3
-3
pkg/api/dashboard_acl_test.go
+3
-3
pkg/models/dashboard_acl.go
+3
-3
pkg/services/sqlstore/dashboard_acl.go
+4
-4
pkg/services/sqlstore/dashboard_acl_test.go
+9
-9
pkg/services/sqlstore/dashboard_test.go
+1
-1
pkg/services/sqlstore/org_test.go
+2
-2
pkg/services/sqlstore/user_group_test.go
+1
-1
pkg/services/sqlstore/user_test.go
+21
-21
public/app/core/components/search/search.html
+2
-3
No files found.
pkg/api/api.go
View file @
e0b9ba75
...
...
@@ -250,7 +250,7 @@ func (hs *HttpServer) registerRoutes() {
r
.
Group
(
"/:id/acl"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetDashboardAcl
))
r
.
Post
(
"/"
,
quota
(
"acl"
),
bind
(
m
.
AddOrUpdateDashboardPermission
Command
{}),
wrap
(
PostDashboardAcl
))
r
.
Post
(
"/"
,
quota
(
"acl"
),
bind
(
m
.
SetDashboardAcl
Command
{}),
wrap
(
PostDashboardAcl
))
r
.
Delete
(
"/user/:userId"
,
wrap
(
DeleteDashboardAclByUser
))
r
.
Delete
(
"/user-group/:userGroupId"
,
wrap
(
DeleteDashboardAclByUserGroup
))
},
reqSignedIn
)
...
...
pkg/api/dashboard_acl.go
View file @
e0b9ba75
...
...
@@ -26,7 +26,7 @@ func GetDashboardAcl(c *middleware.Context) Response {
return
Json
(
200
,
&
query
.
Result
)
}
func
PostDashboardAcl
(
c
*
middleware
.
Context
,
cmd
m
.
AddOrUpdateDashboardPermission
Command
)
Response
{
func
PostDashboardAcl
(
c
*
middleware
.
Context
,
cmd
m
.
SetDashboardAcl
Command
)
Response
{
dashId
:=
c
.
ParamsInt64
(
":id"
)
guardian
:=
guardian
.
NewDashboardGuardian
(
dashId
,
c
.
OrgId
,
c
.
SignedInUser
)
...
...
@@ -61,7 +61,7 @@ func DeleteDashboardAclByUser(c *middleware.Context) Response {
return
dashboardGuardianResponse
(
err
)
}
cmd
:=
m
.
RemoveDashboard
Permission
Command
{
DashboardId
:
dashId
,
UserId
:
userId
,
OrgId
:
c
.
OrgId
}
cmd
:=
m
.
RemoveDashboard
Acl
Command
{
DashboardId
:
dashId
,
UserId
:
userId
,
OrgId
:
c
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to delete permission for user"
,
err
)
...
...
@@ -79,7 +79,7 @@ func DeleteDashboardAclByUserGroup(c *middleware.Context) Response {
return
dashboardGuardianResponse
(
err
)
}
cmd
:=
m
.
RemoveDashboard
Permission
Command
{
DashboardId
:
dashId
,
UserGroupId
:
userGroupId
,
OrgId
:
c
.
OrgId
}
cmd
:=
m
.
RemoveDashboard
Acl
Command
{
DashboardId
:
dashId
,
UserGroupId
:
userGroupId
,
OrgId
:
c
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to delete permission for user"
,
err
)
...
...
pkg/api/dashboard_acl_test.go
View file @
e0b9ba75
...
...
@@ -72,7 +72,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
loggedInUserScenarioWithRole
(
"When calling DELETE on"
,
"DELETE"
,
"/api/dashboards/1/acl/user/1"
,
"/api/dashboards/:id/acl/user/:userId"
,
models
.
ROLE_EDITOR
,
func
(
sc
*
scenarioContext
)
{
mockResult
=
append
(
mockResult
,
&
models
.
DashboardAcl
{
Id
:
1
,
OrgId
:
1
,
DashboardId
:
1
,
UserId
:
1
,
Permissions
:
models
.
PERMISSION_EDIT
})
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Permission
Command
)
error
{
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Acl
Command
)
error
{
return
nil
})
...
...
@@ -88,7 +88,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
loggedInUserScenarioWithRole
(
"When calling DELETE on"
,
"DELETE"
,
"/api/dashboards/1/acl/user/1"
,
"/api/dashboards/:id/acl/user/:userId"
,
models
.
ROLE_EDITOR
,
func
(
sc
*
scenarioContext
)
{
userGroupResp
=
append
(
userGroupResp
,
&
models
.
UserGroup
{
Id
:
1
,
OrgId
:
1
,
Name
:
"UG1"
})
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Permission
Command
)
error
{
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Acl
Command
)
error
{
return
nil
})
...
...
@@ -115,7 +115,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) {
loggedInUserScenarioWithRole
(
"When calling DELETE on"
,
"DELETE"
,
"/api/dashboards/1/acl/user/1"
,
"/api/dashboards/:id/acl/user/:userId"
,
models
.
ROLE_EDITOR
,
func
(
sc
*
scenarioContext
)
{
mockResult
=
append
(
mockResult
,
&
models
.
DashboardAcl
{
Id
:
1
,
OrgId
:
1
,
DashboardId
:
1
,
UserId
:
1
,
Permissions
:
models
.
PERMISSION_VIEW
})
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Permission
Command
)
error
{
bus
.
AddHandler
(
"test3"
,
func
(
cmd
*
models
.
RemoveDashboard
Acl
Command
)
error
{
return
nil
})
...
...
pkg/models/dashboard_acl.go
View file @
e0b9ba75
...
...
@@ -62,17 +62,17 @@ type DashboardAclInfoDTO struct {
// COMMANDS
//
type
AddOrUpdateDashboardPermission
Command
struct
{
type
SetDashboardAcl
Command
struct
{
DashboardId
int64
`json:"-"`
OrgId
int64
`json:"-"`
UserId
int64
`json:"userId"`
UserGroupId
int64
`json:"userGroupId"`
Permissions
PermissionType
`json:"permission
Type
" binding:"Required"`
Permissions
PermissionType
`json:"permission
s
" binding:"Required"`
Result
DashboardAcl
`json:"-"`
}
type
RemoveDashboard
Permission
Command
struct
{
type
RemoveDashboard
Acl
Command
struct
{
DashboardId
int64
`json:"dashboardId" binding:"Required"`
UserId
int64
`json:"userId"`
UserGroupId
int64
`json:"userGroupId"`
...
...
pkg/services/sqlstore/dashboard_acl.go
View file @
e0b9ba75
...
...
@@ -8,13 +8,13 @@ import (
)
func
init
()
{
bus
.
AddHandler
(
"sql"
,
AddOrUpdateDashboardPermission
)
bus
.
AddHandler
(
"sql"
,
RemoveDashboard
Permission
)
bus
.
AddHandler
(
"sql"
,
SetDashboardAcl
)
bus
.
AddHandler
(
"sql"
,
RemoveDashboard
Acl
)
bus
.
AddHandler
(
"sql"
,
GetDashboardPermissions
)
bus
.
AddHandler
(
"sql"
,
GetInheritedDashboardAcl
)
}
func
AddOrUpdateDashboardPermission
(
cmd
*
m
.
AddOrUpdateDashboardPermission
Command
)
error
{
func
SetDashboardAcl
(
cmd
*
m
.
SetDashboardAcl
Command
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
if
cmd
.
UserId
==
0
&&
cmd
.
UserGroupId
==
0
{
return
m
.
ErrDashboardPermissionUserOrUserGroupEmpty
...
...
@@ -74,7 +74,7 @@ func AddOrUpdateDashboardPermission(cmd *m.AddOrUpdateDashboardPermissionCommand
})
}
func
RemoveDashboard
Permission
(
cmd
*
m
.
RemoveDashboardPermission
Command
)
error
{
func
RemoveDashboard
Acl
(
cmd
*
m
.
RemoveDashboardAcl
Command
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
var
rawSQL
=
"DELETE FROM "
+
dialect
.
Quote
(
"dashboard_acl"
)
+
" WHERE dashboard_id =? and (user_group_id=? or user_id=?)"
_
,
err
:=
sess
.
Exec
(
rawSQL
,
cmd
.
DashboardId
,
cmd
.
UserGroupId
,
cmd
.
UserId
)
...
...
pkg/services/sqlstore/dashboard_acl_test.go
View file @
e0b9ba75
...
...
@@ -17,7 +17,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
childDash
:=
insertTestDashboard
(
"2 test dash"
,
1
,
savedFolder
.
Id
,
false
,
"prod"
,
"webapp"
)
Convey
(
"When adding dashboard permission with userId and userGroupId set to 0"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
DashboardId
:
savedFolder
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
,
...
...
@@ -26,7 +26,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Given dashboard folder permission"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
currentUser
.
Id
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -45,7 +45,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Given child dashboard permission"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
currentUser
.
Id
,
DashboardId
:
childDash
.
Id
,
...
...
@@ -67,7 +67,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Should be able to add dashboard permission"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
currentUser
.
Id
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -94,7 +94,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Should be able to update an existing permission"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
1
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -113,7 +113,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Should be able to delete an existing permission"
,
func
()
{
err
:=
RemoveDashboard
Permission
(
&
m
.
RemoveDashboardPermission
Command
{
err
:=
RemoveDashboard
Acl
(
&
m
.
RemoveDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
1
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -133,7 +133,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
So
(
err
,
ShouldBeNil
)
Convey
(
"Should be able to add a user permission for a user group"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserGroupId
:
group1
.
Result
.
Id
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -150,7 +150,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Should be able to update an existing permission for a user group"
,
func
()
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserGroupId
:
group1
.
Result
.
Id
,
DashboardId
:
savedFolder
.
Id
,
...
...
@@ -169,7 +169,7 @@ func TestDashboardAclDataAccess(t *testing.T) {
})
Convey
(
"Should be able to delete an existing permission for a user group"
,
func
()
{
err
:=
RemoveDashboard
Permission
(
&
m
.
RemoveDashboardPermission
Command
{
err
:=
RemoveDashboard
Acl
(
&
m
.
RemoveDashboardAcl
Command
{
OrgId
:
1
,
UserGroupId
:
group1
.
Result
.
Id
,
DashboardId
:
savedFolder
.
Id
,
...
...
pkg/services/sqlstore/dashboard_test.go
View file @
e0b9ba75
...
...
@@ -380,7 +380,7 @@ func createUser(name string, role string, isAdmin bool) m.User {
}
func
updateTestDashboardWithAcl
(
dashId
int64
,
userId
int64
,
permissions
m
.
PermissionType
)
{
err
:=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
err
:=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
OrgId
:
1
,
UserId
:
userId
,
DashboardId
:
dashId
,
...
...
pkg/services/sqlstore/org_test.go
View file @
e0b9ba75
...
...
@@ -174,10 +174,10 @@ func TestAccountDataAccess(t *testing.T) {
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
),
ShouldEqual
,
3
)
err
=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
DashboardId
:
1
,
OrgId
:
ac1
.
OrgId
,
UserId
:
ac3
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
})
err
=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
DashboardId
:
1
,
OrgId
:
ac1
.
OrgId
,
UserId
:
ac3
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
})
So
(
err
,
ShouldBeNil
)
err
=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
DashboardId
:
2
,
OrgId
:
ac3
.
OrgId
,
UserId
:
ac3
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
})
err
=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
DashboardId
:
2
,
OrgId
:
ac3
.
OrgId
,
UserId
:
ac3
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
})
So
(
err
,
ShouldBeNil
)
Convey
(
"When org user is deleted"
,
func
()
{
...
...
pkg/services/sqlstore/user_group_test.go
View file @
e0b9ba75
...
...
@@ -94,7 +94,7 @@ func TestUserGroupCommandsAndQueries(t *testing.T) {
So
(
err
,
ShouldBeNil
)
err
=
AddUserGroupMember
(
&
m
.
AddUserGroupMemberCommand
{
OrgId
:
1
,
UserGroupId
:
groupId
,
UserId
:
userIds
[
2
]})
So
(
err
,
ShouldBeNil
)
err
=
AddOrUpdateDashboardPermission
(
&
m
.
AddOrUpdateDashboardPermission
Command
{
DashboardId
:
1
,
OrgId
:
1
,
Permissions
:
m
.
PERMISSION_EDIT
,
UserGroupId
:
groupId
})
err
=
SetDashboardAcl
(
&
m
.
SetDashboardAcl
Command
{
DashboardId
:
1
,
OrgId
:
1
,
Permissions
:
m
.
PERMISSION_EDIT
,
UserGroupId
:
groupId
})
err
=
DeleteUserGroup
(
&
m
.
DeleteUserGroupCommand
{
Id
:
groupId
})
So
(
err
,
ShouldBeNil
)
...
...
pkg/services/sqlstore/user_test.go
View file @
e0b9ba75
...
...
@@ -6,7 +6,7 @@ import (
.
"github.com/smartystreets/goconvey/convey"
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
)
func
TestUserDataAccess
(
t
*
testing
.
T
)
{
...
...
@@ -16,10 +16,10 @@ func TestUserDataAccess(t *testing.T) {
Convey
(
"Given 5 users"
,
func
()
{
var
err
error
var
cmd
*
m
odels
.
CreateUserCommand
users
:=
[]
m
odels
.
User
{}
var
cmd
*
m
.
CreateUserCommand
users
:=
[]
m
.
User
{}
for
i
:=
0
;
i
<
5
;
i
++
{
cmd
=
&
m
odels
.
CreateUserCommand
{
cmd
=
&
m
.
CreateUserCommand
{
Email
:
fmt
.
Sprint
(
"user"
,
i
,
"@test.com"
),
Name
:
fmt
.
Sprint
(
"user"
,
i
),
Login
:
fmt
.
Sprint
(
"loginuser"
,
i
),
...
...
@@ -30,7 +30,7 @@ func TestUserDataAccess(t *testing.T) {
}
Convey
(
"Can return the first page of users and a total count"
,
func
()
{
query
:=
m
odels
.
SearchUsersQuery
{
Query
:
""
,
Page
:
1
,
Limit
:
3
}
query
:=
m
.
SearchUsersQuery
{
Query
:
""
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -39,7 +39,7 @@ func TestUserDataAccess(t *testing.T) {
})
Convey
(
"Can return the second page of users and a total count"
,
func
()
{
query
:=
m
odels
.
SearchUsersQuery
{
Query
:
""
,
Page
:
2
,
Limit
:
3
}
query
:=
m
.
SearchUsersQuery
{
Query
:
""
,
Page
:
2
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -48,28 +48,28 @@ func TestUserDataAccess(t *testing.T) {
})
Convey
(
"Can return list of users matching query on user name"
,
func
()
{
query
:=
m
odels
.
SearchUsersQuery
{
Query
:
"use"
,
Page
:
1
,
Limit
:
3
}
query
:=
m
.
SearchUsersQuery
{
Query
:
"use"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
.
Users
),
ShouldEqual
,
3
)
So
(
query
.
Result
.
TotalCount
,
ShouldEqual
,
5
)
query
=
m
odels
.
SearchUsersQuery
{
Query
:
"ser1"
,
Page
:
1
,
Limit
:
3
}
query
=
m
.
SearchUsersQuery
{
Query
:
"ser1"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
.
Users
),
ShouldEqual
,
1
)
So
(
query
.
Result
.
TotalCount
,
ShouldEqual
,
1
)
query
=
m
odels
.
SearchUsersQuery
{
Query
:
"USER1"
,
Page
:
1
,
Limit
:
3
}
query
=
m
.
SearchUsersQuery
{
Query
:
"USER1"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
.
Users
),
ShouldEqual
,
1
)
So
(
query
.
Result
.
TotalCount
,
ShouldEqual
,
1
)
query
=
m
odels
.
SearchUsersQuery
{
Query
:
"idontexist"
,
Page
:
1
,
Limit
:
3
}
query
=
m
.
SearchUsersQuery
{
Query
:
"idontexist"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -78,7 +78,7 @@ func TestUserDataAccess(t *testing.T) {
})
Convey
(
"Can return list of users matching query on email"
,
func
()
{
query
:=
m
odels
.
SearchUsersQuery
{
Query
:
"ser1@test.com"
,
Page
:
1
,
Limit
:
3
}
query
:=
m
.
SearchUsersQuery
{
Query
:
"ser1@test.com"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -87,7 +87,7 @@ func TestUserDataAccess(t *testing.T) {
})
Convey
(
"Can return list of users matching query on login name"
,
func
()
{
query
:=
m
odels
.
SearchUsersQuery
{
Query
:
"loginuser1"
,
Page
:
1
,
Limit
:
3
}
query
:=
m
.
SearchUsersQuery
{
Query
:
"loginuser1"
,
Page
:
1
,
Limit
:
3
}
err
=
SearchUsers
(
&
query
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -96,33 +96,33 @@ func TestUserDataAccess(t *testing.T) {
})
Convey
(
"when a user is an org member and has been assigned permissions"
,
func
()
{
err
=
AddOrgUser
(
&
m
odels
.
AddOrgUserCommand
{
LoginOrEmail
:
users
[
0
]
.
Login
,
Role
:
models
.
ROLE_VIEWER
,
OrgId
:
users
[
0
]
.
OrgId
})
err
=
AddOrgUser
(
&
m
.
AddOrgUserCommand
{
LoginOrEmail
:
users
[
0
]
.
Login
,
Role
:
m
.
ROLE_VIEWER
,
OrgId
:
users
[
0
]
.
OrgId
})
So
(
err
,
ShouldBeNil
)
err
=
AddOrUpdateDashboardPermission
(
&
models
.
AddOrUpdateDashboardPermissionCommand
{
DashboardId
:
1
,
OrgId
:
users
[
0
]
.
OrgId
,
UserId
:
users
[
0
]
.
Id
,
Permissions
:
models
.
PERMISSION_EDIT
})
err
=
SetDashboardAcl
(
&
m
.
SetDashboardAclCommand
{
DashboardId
:
1
,
OrgId
:
users
[
0
]
.
OrgId
,
UserId
:
users
[
0
]
.
Id
,
Permissions
:
m
.
PERMISSION_EDIT
})
So
(
err
,
ShouldBeNil
)
err
=
SavePreferences
(
&
m
odels
.
SavePreferencesCommand
{
UserId
:
users
[
0
]
.
Id
,
OrgId
:
users
[
0
]
.
OrgId
,
HomeDashboardId
:
1
,
Theme
:
"dark"
})
err
=
SavePreferences
(
&
m
.
SavePreferencesCommand
{
UserId
:
users
[
0
]
.
Id
,
OrgId
:
users
[
0
]
.
OrgId
,
HomeDashboardId
:
1
,
Theme
:
"dark"
})
So
(
err
,
ShouldBeNil
)
Convey
(
"when the user is deleted"
,
func
()
{
err
=
DeleteUser
(
&
m
odels
.
DeleteUserCommand
{
UserId
:
users
[
0
]
.
Id
})
err
=
DeleteUser
(
&
m
.
DeleteUserCommand
{
UserId
:
users
[
0
]
.
Id
})
So
(
err
,
ShouldBeNil
)
Convey
(
"Should delete connected org users and permissions"
,
func
()
{
query
:=
&
m
odels
.
GetOrgUsersQuery
{
OrgId
:
1
}
query
:=
&
m
.
GetOrgUsersQuery
{
OrgId
:
1
}
err
=
GetOrgUsersForTest
(
query
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
query
.
Result
),
ShouldEqual
,
1
)
permQuery
:=
&
m
odels
.
GetDashboardPermissionsQuery
{
DashboardId
:
1
}
permQuery
:=
&
m
.
GetDashboardPermissionsQuery
{
DashboardId
:
1
}
err
=
GetDashboardPermissions
(
permQuery
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
permQuery
.
Result
),
ShouldEqual
,
0
)
prefsQuery
:=
&
m
odels
.
GetPreferencesQuery
{
OrgId
:
users
[
0
]
.
OrgId
,
UserId
:
users
[
0
]
.
Id
}
prefsQuery
:=
&
m
.
GetPreferencesQuery
{
OrgId
:
users
[
0
]
.
OrgId
,
UserId
:
users
[
0
]
.
Id
}
err
=
GetPreferences
(
prefsQuery
)
So
(
err
,
ShouldBeNil
)
...
...
@@ -135,8 +135,8 @@ func TestUserDataAccess(t *testing.T) {
})
}
func
GetOrgUsersForTest
(
query
*
m
odels
.
GetOrgUsersQuery
)
error
{
query
.
Result
=
make
([]
*
m
odels
.
OrgUserDTO
,
0
)
func
GetOrgUsersForTest
(
query
*
m
.
GetOrgUsersQuery
)
error
{
query
.
Result
=
make
([]
*
m
.
OrgUserDTO
,
0
)
sess
:=
x
.
Table
(
"org_user"
)
sess
.
Join
(
"LEFT "
,
"user"
,
fmt
.
Sprintf
(
"org_user.user_id=%s.id"
,
x
.
Dialect
()
.
Quote
(
"user"
)))
sess
.
Where
(
"org_user.org_id=?"
,
query
.
OrgId
)
...
...
public/app/core/components/search/search.html
View file @
e0b9ba75
...
...
@@ -57,9 +57,7 @@
<h6
ng-hide=
"ctrl.results.length"
>
No dashboards matching your query were found.
</h6>
<div
bindonce
ng-repeat=
"row in ctrl.results"
>
<a
class=
"search-item pointer search-item-{{row.type}}"
ng-class=
"{'selected': $index == ctrl.selectedIndex}"
ng-href=
"{{row.url}}"
>
<a
class=
"search-item pointer search-item-{{row.type}}"
ng-class=
"{'selected': $index == ctrl.selectedIndex}"
ng-href=
"{{row.url}}"
>
<span
class=
"search-result-tags"
>
<span
ng-click=
"ctrl.filterByTag(tag, $event)"
ng-repeat=
"tag in row.tags"
tag-color-from-name=
"tag"
class=
"label label-tag"
>
{{tag}}
...
...
@@ -71,6 +69,7 @@
<i
class=
"fa search-result-icon"
></i>
<span
bo-text=
"row.title"
></span>
</span>
<a
class=
"search-item search-item-child pointer search-item-{{child.type}}"
ng-repeat=
"child in row.dashboards"
ng-class=
"{'selected': $index == ctrl.selectedIndex}"
ng-href=
"{{'dashboard/' + child.uri}}"
>
<span
class=
"search-result-tags"
>
...
...
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