Chore: Remove folders from models pkg (#61853)
This commit is contained in:
+4
-4
@@ -169,16 +169,16 @@ func (hs *HTTPServer) CreateFolder(c *models.ReqContext) response.Response {
|
||||
|
||||
func (hs *HTTPServer) MoveFolder(c *models.ReqContext) response.Response {
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagNestedFolders) {
|
||||
cmd := models.MoveFolderCommand{}
|
||||
cmd := folder.MoveFolderCommand{}
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
var theFolder *folder.Folder
|
||||
var err error
|
||||
if cmd.ParentUID != nil {
|
||||
if cmd.NewParentUID != "" {
|
||||
moveCommand := folder.MoveFolderCommand{
|
||||
UID: web.Params(c.Req)[":uid"],
|
||||
NewParentUID: *cmd.ParentUID,
|
||||
NewParentUID: cmd.NewParentUID,
|
||||
OrgID: c.OrgID,
|
||||
}
|
||||
theFolder, err = hs.folderService.Move(c.Req.Context(), &moveCommand)
|
||||
@@ -280,7 +280,7 @@ func (hs *HTTPServer) newToFolderDto(c *models.ReqContext, g guardian.DashboardG
|
||||
Id: folder.ID,
|
||||
Uid: folder.UID,
|
||||
Title: folder.Title,
|
||||
Url: folder.Url,
|
||||
Url: folder.URL,
|
||||
HasACL: folder.HasACL,
|
||||
CanSave: canSave,
|
||||
CanEdit: canEdit,
|
||||
|
||||
@@ -34,8 +34,8 @@ func TestFoldersAPIEndpoint(t *testing.T) {
|
||||
folderService := &foldertest.FakeService{}
|
||||
|
||||
t.Run("Given a correct request for creating a folder", func(t *testing.T) {
|
||||
cmd := models.CreateFolderCommand{
|
||||
Uid: "uid",
|
||||
cmd := folder.CreateFolderCommand{
|
||||
UID: "uid",
|
||||
Title: "Folder",
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ func TestFoldersAPIEndpoint(t *testing.T) {
|
||||
{Error: dashboards.ErrFolderFailedGenerateUniqueUid, ExpectedStatusCode: 500},
|
||||
}
|
||||
|
||||
cmd := models.CreateFolderCommand{
|
||||
Uid: "uid",
|
||||
cmd := folder.CreateFolderCommand{
|
||||
UID: "uid",
|
||||
Title: "Folder",
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ func callCreateFolder(sc *scenarioContext) {
|
||||
}
|
||||
|
||||
func createFolderScenario(t *testing.T, desc string, url string, routePattern string, folderService folder.Service,
|
||||
cmd models.CreateFolderCommand, fn scenarioFunc) {
|
||||
cmd folder.CreateFolderCommand, fn scenarioFunc) {
|
||||
setUpRBACGuardian(t)
|
||||
t.Run(fmt.Sprintf("%s %s", desc, url), func(t *testing.T) {
|
||||
aclMockResp := []*dashboards.DashboardACLInfoDTO{}
|
||||
|
||||
+5
-3
@@ -10,6 +10,7 @@ import (
|
||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
pref "github.com/grafana/grafana/pkg/services/preference"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -21,11 +22,12 @@ const (
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) editorInAnyFolder(c *models.ReqContext) bool {
|
||||
hasEditPermissionInFoldersQuery := models.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser}
|
||||
if err := hs.DashboardService.HasEditPermissionInFolders(c.Req.Context(), &hasEditPermissionInFoldersQuery); err != nil {
|
||||
hasEditPermissionInFoldersQuery := folder.HasEditPermissionInFoldersQuery{SignedInUser: c.SignedInUser}
|
||||
hasEditPermissionInFoldersQueryResult, err := hs.DashboardService.HasEditPermissionInFolders(c.Req.Context(), &hasEditPermissionInFoldersQuery)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return hasEditPermissionInFoldersQuery.Result
|
||||
return hasEditPermissionInFoldersQueryResult
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) setIndexViewData(c *models.ReqContext) (*dtos.IndexViewData, error) {
|
||||
|
||||
Reference in New Issue
Block a user