Dashboards+Folder: remove unused function MakeUserAdmin (#73635)
* Dashboards+Folder: remove unused function MakeUserAdmin * Remove dead branch
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/events"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
"github.com/grafana/grafana/pkg/services/store/entity"
|
||||
@@ -711,50 +709,6 @@ func (s *Service) getNestedFolders(ctx context.Context, orgID int64, uid string)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MakeUserAdmin is copy of DashboardServiceImpl.MakeUserAdmin
|
||||
func (s *Service) MakeUserAdmin(ctx context.Context, orgID int64, userID, folderID int64, setViewAndEditPermissions bool) error {
|
||||
rtEditor := org.RoleEditor
|
||||
rtViewer := org.RoleViewer
|
||||
|
||||
items := []*dashboards.DashboardACL{
|
||||
{
|
||||
OrgID: orgID,
|
||||
DashboardID: folderID,
|
||||
UserID: userID,
|
||||
Permission: dashboards.PERMISSION_ADMIN,
|
||||
Created: time.Now(),
|
||||
Updated: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
if setViewAndEditPermissions {
|
||||
items = append(items,
|
||||
&dashboards.DashboardACL{
|
||||
OrgID: orgID,
|
||||
DashboardID: folderID,
|
||||
Role: &rtEditor,
|
||||
Permission: dashboards.PERMISSION_EDIT,
|
||||
Created: time.Now(),
|
||||
Updated: time.Now(),
|
||||
},
|
||||
&dashboards.DashboardACL{
|
||||
OrgID: orgID,
|
||||
DashboardID: folderID,
|
||||
Role: &rtViewer,
|
||||
Permission: dashboards.PERMISSION_VIEW,
|
||||
Created: time.Now(),
|
||||
Updated: time.Now(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
if err := s.dashboardStore.UpdateDashboardACL(ctx, folderID, items); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BuildSaveDashboardCommand is a simplified version on DashboardServiceImpl.BuildSaveDashboardCommand
|
||||
// keeping only the meaningful functionality for folders
|
||||
func (s *Service) BuildSaveDashboardCommand(ctx context.Context, dto *dashboards.SaveDashboardDTO) (*dashboards.SaveDashboardCommand, error) {
|
||||
|
||||
Reference in New Issue
Block a user