mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add edit permission check for adding to playlist
This commit is contained in:
parent
850ac3837a
commit
e13f0ba234
1 changed files with 29 additions and 2 deletions
|
@ -149,6 +149,31 @@ function populatePlaylists(editorOptions: PlaylistEditorOptions, panel: DialogEl
|
|||
recursive: true
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return Promise.all((data.Items || []).map(item => {
|
||||
const playlist = {
|
||||
item,
|
||||
permissions: undefined
|
||||
};
|
||||
|
||||
if (!item.Id) return playlist;
|
||||
|
||||
return getPlaylistsApi(api)
|
||||
.getPlaylistUser({
|
||||
playlistId: item.Id,
|
||||
userId: apiClient.getCurrentUserId()
|
||||
})
|
||||
.then(({ data: permissions }) => ({
|
||||
...playlist,
|
||||
permissions
|
||||
}))
|
||||
.catch((err) => {
|
||||
console.warn('[PlaylistEditor] Failed to fetch playlist permissions', err);
|
||||
|
||||
return playlist;
|
||||
});
|
||||
}));
|
||||
})
|
||||
.then(playlists => {
|
||||
let html = '';
|
||||
|
||||
if ((editorOptions.enableAddToPlayQueue !== false && playbackManager.isPlaying()) || SyncPlay?.Manager.isSyncPlayEnabled()) {
|
||||
|
@ -157,8 +182,10 @@ function populatePlaylists(editorOptions: PlaylistEditorOptions, panel: DialogEl
|
|||
|
||||
html += `<option value="">${globalize.translate('OptionNew')}</option>`;
|
||||
|
||||
html += data.Items?.map(i => {
|
||||
return `<option value="${i.Id}">${escapeHtml(i.Name)}</option>`;
|
||||
html += playlists.map(({ item, permissions }) => {
|
||||
if (!permissions?.CanEdit) return '';
|
||||
|
||||
return `<option value="${item.Id}">${escapeHtml(item.Name)}</option>`;
|
||||
});
|
||||
|
||||
select.innerHTML = html;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue