Folders: Create default folder permissions within transaction (#97812)

create default folder permissions within transaction
This commit is contained in:
owensmallwood
2024-12-12 14:08:46 -06:00
committed by GitHub
parent 3345f860dc
commit 0e8702369a
+10 -8
View File
@@ -675,6 +675,7 @@ func (s *Service) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (
var nestedFolder *folder.Folder
var dash *dashboards.Dashboard
var f *folder.Folder
err = s.db.InTransaction(ctx, func(ctx context.Context) error {
if dash, err = s.dashboardStore.SaveDashboard(ctx, *saveDashboardCmd); err != nil {
return toFolderError(err)
@@ -696,17 +697,18 @@ func (s *Service) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (
return err
}
f = dashboards.FromDashboard(dash)
if nestedFolder != nil && nestedFolder.ParentUID != "" {
f.ParentUID = nestedFolder.ParentUID
}
if err = s.setDefaultFolderPermissions(ctx, cmd.OrgID, user, f); err != nil {
return err
}
return nil
})
if err != nil {
return nil, err
}
f := dashboards.FromDashboard(dash)
if nestedFolder != nil && nestedFolder.ParentUID != "" {
f.ParentUID = nestedFolder.ParentUID
}
if err = s.setDefaultFolderPermissions(ctx, cmd.OrgID, user, f); err != nil {
if err != nil {
return nil, err
}