chore: move dashboard_acl models into dashboard service (#62151)

This commit is contained in:
Kristin Laemmert
2023-01-26 08:46:30 -05:00
committed by GitHub
parent c5cb5be3cc
commit e8b8a9e276
65 changed files with 553 additions and 572 deletions
-32
View File
@@ -1,32 +0,0 @@
package models
import (
"errors"
)
type PermissionType int
const (
PERMISSION_VIEW PermissionType = 1 << iota
PERMISSION_EDIT
PERMISSION_ADMIN
)
func (p PermissionType) String() string {
names := map[int]string{
int(PERMISSION_VIEW): "View",
int(PERMISSION_EDIT): "Edit",
int(PERMISSION_ADMIN): "Admin",
}
return names[int(p)]
}
// Typed errors
var (
ErrDashboardACLInfoMissing = errors.New("user id and team id cannot both be empty for a dashboard permission")
ErrDashboardPermissionDashboardEmpty = errors.New("dashboard id must be greater than zero for a dashboard permission")
ErrFolderACLInfoMissing = errors.New("user id and team id cannot both be empty for a folder permission")
ErrFolderPermissionFolderEmpty = errors.New("folder id must be greater than zero for a folder permission")
ErrPermissionsWithRoleNotAllowed = errors.New("permissions cannot have both a user and team")
ErrPermissionsWithUserAndTeamNotAllowed = errors.New("team and user permissions cannot have an associated role")
)
-26
View File
@@ -1,26 +0,0 @@
package models
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPermissionType_String(t *testing.T) {
testCases := []struct {
permissionType PermissionType
expected string
}{
{PERMISSION_ADMIN, "Admin"},
{PERMISSION_EDIT, "Edit"},
{PERMISSION_VIEW, "View"},
}
for _, tc := range testCases {
t.Run(tc.expected, func(t *testing.T) {
assert.Equal(t, tc.expected, fmt.Sprint(tc.permissionType))
assert.Equal(t, tc.expected, tc.permissionType.String())
})
}
}
-21
View File
@@ -4,7 +4,6 @@ import (
"strings"
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
"github.com/grafana/grafana/pkg/services/user"
)
type SortOption struct {
@@ -20,26 +19,6 @@ type SortOptionFilter interface {
searchstore.FilterOrderBy
}
type FindPersistedDashboardsQuery struct {
Title string
OrgId int64
SignedInUser *user.SignedInUser
IsStarred bool
DashboardIds []int64
DashboardUIDs []string
Type string
FolderIds []int64
Tags []string
Limit int64
Page int64
Permission PermissionType
Sort SortOption
Filters []interface{}
Result HitList
}
type HitType string
const (