Commit 7ad1e366 by Sofia Papagiannaki Committed by GitHub

Playlists: Remove API validation for empty playlists and remove redundant API call (#26982)

* Remove validation from empty playlists

* Remove redundant API call

Frontend used to call /api/playlists/:id/items directly after /api/playlists/:id but items are already included in the first response
parent bb0f17ce
package api package api
import ( import (
"net/http"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/models"
) )
...@@ -26,18 +24,6 @@ func ValidateOrgPlaylist(c *models.ReqContext) { ...@@ -26,18 +24,6 @@ func ValidateOrgPlaylist(c *models.ReqContext) {
c.JsonApiErr(403, "You are not allowed to edit/view playlist", nil) c.JsonApiErr(403, "You are not allowed to edit/view playlist", nil)
return return
} }
items, itemsErr := LoadPlaylistItemDTOs(id)
if itemsErr != nil {
c.JsonApiErr(404, "Playlist items not found", err)
return
}
if len(items) == 0 && c.Context.Req.Method != http.MethodDelete {
c.JsonApiErr(404, "Playlist is empty", itemsErr)
return
}
} }
func SearchPlaylists(c *models.ReqContext) Response { func SearchPlaylists(c *models.ReqContext) Response {
......
...@@ -46,14 +46,7 @@ export class PlaylistEditCtrl { ...@@ -46,14 +46,7 @@ export class PlaylistEditCtrl {
.get('/api/playlists/' + playlistId) .get('/api/playlists/' + playlistId)
.then((result: any) => { .then((result: any) => {
this.playlist = result; this.playlist = result;
}) this.playlistItems = result.items;
);
promiseToDigest(this.$scope)(
getBackendSrv()
.get('/api/playlists/' + playlistId + '/items')
.then((result: any) => {
this.playlistItems = result;
}) })
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment