folder: uses service to make user admin of created folder.

This commit is contained in:
Leonard Gram
2019-03-05 16:53:16 +01:00
parent c8c004095c
commit da3dcd1918
2 changed files with 5 additions and 40 deletions
-40
View File
@@ -5,7 +5,6 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/search"
"time"
)
// FolderService service for operating on folders
@@ -115,45 +114,6 @@ func (dr *dashboardServiceImpl) CreateFolder(cmd *models.CreateFolderCommand) er
return toFolderError(err)
}
rtEditor := models.ROLE_EDITOR
rtViewer := models.ROLE_VIEWER
items := []*models.DashboardAcl{
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
UserId: saveDashboardCmd.Result.CreatedBy,
Permission: models.PERMISSION_ADMIN,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtEditor,
Permission: models.PERMISSION_EDIT,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtViewer,
Permission: models.PERMISSION_VIEW,
Created: time.Now(),
Updated: time.Now(),
},
}
aclCmd := &models.UpdateDashboardAclCommand{
DashboardId: saveDashboardCmd.Result.Id,
Items: items,
}
if err = bus.Dispatch(aclCmd); err != nil {
return err
}
query := models.GetDashboardQuery{OrgId: dr.orgId, Id: saveDashboardCmd.Result.Id}
dashFolder, err = getFolder(query)
if err != nil {