Snapshots: Viewers can not create a Snapshot (#84952)

This commit is contained in:
Ezequiel Victorero
2024-03-22 14:31:01 -03:00
committed by GitHub
parent 629a8808e0
commit c57c033522
6 changed files with 55 additions and 28 deletions

View File

@@ -269,6 +269,13 @@ func (b *SnapshotsAPIBuilder) GetAPIRoutes() *builder.APIRoutes {
fmt.Sprintf("user orgId does not match namespace (%d != %d)", info.OrgID, user.OrgID), nil)
return
}
cmd := dashboardsnapshots.CreateDashboardSnapshotCommand{}
if err := web.Bind(wrap.Req, &cmd); err != nil {
wrap.JsonApiErr(http.StatusBadRequest, "bad request data", err)
return
}
opts, err := b.options(info.Value)
if err != nil {
wrap.JsonApiErr(http.StatusBadRequest, "error getting options", err)
@@ -276,7 +283,7 @@ func (b *SnapshotsAPIBuilder) GetAPIRoutes() *builder.APIRoutes {
}
// Use the existing snapshot service
dashboardsnapshots.CreateDashboardSnapshot(wrap, opts.Spec, b.service)
dashboardsnapshots.CreateDashboardSnapshot(wrap, opts.Spec, cmd, b.service)
},
},
{