mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 12:33:37 -06:00
add migrator to drop folder create actions that was set fromt he folder (#49878)
This commit is contained in:
parent
e04f84fd1b
commit
f4f25d911b
@ -41,13 +41,11 @@ var folderPermissionTranslation = map[models.PermissionType][]string{
|
||||
dashboards.ActionDashboardsCreate,
|
||||
dashboards.ActionFoldersRead,
|
||||
dashboards.ActionFoldersWrite,
|
||||
dashboards.ActionFoldersCreate,
|
||||
dashboards.ActionFoldersDelete,
|
||||
}...),
|
||||
models.PERMISSION_ADMIN: append(dashboardPermissionTranslation[models.PERMISSION_ADMIN], []string{
|
||||
dashboards.ActionFoldersRead,
|
||||
dashboards.ActionFoldersWrite,
|
||||
dashboards.ActionFoldersCreate,
|
||||
dashboards.ActionFoldersDelete,
|
||||
dashboards.ActionFoldersPermissionsRead,
|
||||
dashboards.ActionFoldersPermissionsWrite,
|
||||
@ -57,6 +55,7 @@ var folderPermissionTranslation = map[models.PermissionType][]string{
|
||||
func AddDashboardPermissionsMigrator(mg *migrator.Migrator) {
|
||||
mg.AddMigration("dashboard permissions", &dashboardPermissionsMigrator{})
|
||||
mg.AddMigration("dashboard permissions uid scopes", &dashboardUidPermissionMigrator{})
|
||||
mg.AddMigration("drop managed folder create actions", &managedFolderCreateAction{})
|
||||
}
|
||||
|
||||
var _ migrator.CodeMigration = new(dashboardPermissionsMigrator)
|
||||
@ -280,3 +279,18 @@ func (d *dashboardUidPermissionMigrator) migrateIdScopes(sess *xorm.Session) err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type managedFolderCreateAction struct {
|
||||
migrator.MigrationBase
|
||||
}
|
||||
|
||||
func (m *managedFolderCreateAction) SQL(dialect migrator.Dialect) string {
|
||||
return CodeMigrationSQL
|
||||
}
|
||||
|
||||
func (m *managedFolderCreateAction) Exec(sess *xorm.Session, migrator *migrator.Migrator) error {
|
||||
if _, err := sess.Exec("DELETE FROM permission WHERE action = 'folders:create' AND scope LIKE 'folders:uid:%'"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user