From 7ad1e3663c0b075ac3f38adc3ccce9d6771a9c7f Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki Date: Fri, 14 Aug 2020 11:59:50 +0300 Subject: [PATCH] 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 --- pkg/api/playlist.go | 14 -------------- public/app/features/playlist/playlist_edit_ctrl.ts | 9 +-------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/pkg/api/playlist.go b/pkg/api/playlist.go index 72181772e52..cfe9956987a 100644 --- a/pkg/api/playlist.go +++ b/pkg/api/playlist.go @@ -1,8 +1,6 @@ package api import ( - "net/http" - "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/models" ) @@ -26,18 +24,6 @@ func ValidateOrgPlaylist(c *models.ReqContext) { c.JsonApiErr(403, "You are not allowed to edit/view playlist", nil) 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 { diff --git a/public/app/features/playlist/playlist_edit_ctrl.ts b/public/app/features/playlist/playlist_edit_ctrl.ts index e7fd1f42317..e93bc4568f6 100644 --- a/public/app/features/playlist/playlist_edit_ctrl.ts +++ b/public/app/features/playlist/playlist_edit_ctrl.ts @@ -46,14 +46,7 @@ export class PlaylistEditCtrl { .get('/api/playlists/' + playlistId) .then((result: any) => { this.playlist = result; - }) - ); - - promiseToDigest(this.$scope)( - getBackendSrv() - .get('/api/playlists/' + playlistId + '/items') - .then((result: any) => { - this.playlistItems = result; + this.playlistItems = result.items; }) ); }